Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving scissor usage #668

Closed
lexaknyazev opened this issue Aug 2, 2016 · 6 comments
Closed

Improving scissor usage #668

lexaknyazev opened this issue Aug 2, 2016 · 6 comments

Comments

@lexaknyazev
Copy link
Member

Currently, states.functions.scissor is defined as

Floating-point value passed to scissor(). [x, y, width, height]. The default is the dimensions of the canvas when the WebGL context is created. width and height must be greater than zero.

At the same time, there is no way in glTF to define window and/or viewport dimensions, so scissor state is almost useless (since it uses window coordinates) especially in the WebGL context, because HTML canvas can have any random dimensions (and they change with window resizing and full-screen toggling).

VIEWPORT uniform parameter can't help with this, because it has the opposite purpose: provide viewport info to shader.

I can see two possible solutions for this issue:

  1. Add viewport property to states.functions dictionary and make it required when scissor is present.
    Add also width and height to asset and/or scene to declare desired window size (of course, runtime can scale everything to actual canvas dimensions). Such approach will align glTF with other multimedia formats (think of image or video) and will also make embedding glTF assets into web pages more predictable.
  2. Remove scissor from states.functions (and SCISSOR_TEST from states.enable).

For more flexible viewport / scissor positioning (relative, absolute, fixed, etc) something like "window layout" extension could be proposed later.

@pjcozzi
Copy link
Member

pjcozzi commented Aug 10, 2016

I suggest we push this post 1.0.1.

I am not sure about adding viewport and friends until we have concrete use cases that people are asking for (then it would be OK, of course) nor am I sure about removing scissor and then adding it back later.

@lexaknyazev
Copy link
Member Author

glTF declares itself as a "JPEG for 3D", so interoperability of the base spec must be one the top format's priorities. Current state of handling scissor is neither flexible for real usage nor interoperable (think of possible runtime resizes).

If we don't have enough time to collect people's feedback, I'd prefer to remove it (afair, stencil support was removed from 1.0 for similar reasons).
Otherwise, we can define a bare minimum (optional viewport defaulting to canvas size and explicit asset's dimensions) to make scissor support useful.

@pjcozzi
Copy link
Member

pjcozzi commented Aug 10, 2016

I am having a hard time coming up with a real use case for the current form other than if an app knows it will have a fixed viewport, e.g., as an embed, not a fullscreen app.

I suppose since no one is using this AFAIK if it would be fine to remove and add back when full support is thought through.

Can you open a PR to update the spec and check the sample models?

@lexaknyazev
Copy link
Member Author

Sample models are clean.

@lexaknyazev
Copy link
Member Author

See #681.

pjcozzi added a commit that referenced this issue Aug 15, 2016
lexaknyazev added a commit that referenced this issue Feb 2, 2017
lexaknyazev pushed a commit that referenced this issue Feb 2, 2017
@pjcozzi
Copy link
Member

pjcozzi commented Jun 15, 2017

Updated in #826

@pjcozzi pjcozzi closed this as completed Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants