-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Negative transformation scale #1697
Comments
I think I get it. At some point someone was asked "what happens if the scale inverts the faces" and this was the answer. It is true that you could save some VRAM if you had a separate mesh object that included the triangle order and a "mesh data" object that was shared between meshes that contains the vertex arrays, and thus instance the mesh with two different winding orders, but it seems like a really obscure optimization. I think this decision is covering one mistake with another one. |
I think this implementation note should be removed. Negative scales will invert single-sided faces, and that's OK. |
This implementation note is there to support mirrored geometry. Both Unity and Unreal do this. For the history, see #971 (comment) and the corresponding PR #985. |
Well, at least the correct behavior is explicitly stated. Thanks for the info. |
Now that it's in use, this is actually critical to follow. I have encountered GLTF files that use a negative scale on one axis and if you don't follow this rule the faces will be inverted from what you would expect. |
See https://github.com/KhronosGroup/glTF-Asset-Generator/blob/master/Output/Positive/Node_NegativeScale/README.md for a set of test cases if you are implementing a loader. |
I see, thanks – looks like this was added to three.js as well, in r89, and I'd missed it. mrdoob/three.js#12787. @JoshKlint to your original question...
...the same mesh can be can be reused, uploaded to the GPU once, and rendered with different states of |
# Objective according to [khronos](KhronosGroup/glTF#1697), gltf nodes with inverted scales should invert the winding order of the mesh data. this is to allow negative scale to be used for mirrored geometry. ## Solution in the gltf loader, create a separate material with `cull_mode` set to `Face::Front` when the node scale is negative. note/alternatives: this applies for nodes where the scale is negative at gltf import time. that seems like enough for the mentioned use case of mirrored geometry. it doesn't help when scales dynamically go negative at runtime, but you can always set double sided in that case. i don't think there's any practical difference between using front-face culling and setting a clockwise winding order explicitly, but winding order is supported by wgpu so we could add the field to StandardMaterial/StandardMaterialKey and set it directly on the pipeline descriptor if there's a reason to. it wouldn't help with dynamic scale adjustments anyway, and would still require a separate material. fixes #4738, probably fixes #7901. --------- Co-authored-by: François <[email protected]>
# Objective according to [khronos](KhronosGroup/glTF#1697), gltf nodes with inverted scales should invert the winding order of the mesh data. this is to allow negative scale to be used for mirrored geometry. ## Solution in the gltf loader, create a separate material with `cull_mode` set to `Face::Front` when the node scale is negative. note/alternatives: this applies for nodes where the scale is negative at gltf import time. that seems like enough for the mentioned use case of mirrored geometry. it doesn't help when scales dynamically go negative at runtime, but you can always set double sided in that case. i don't think there's any practical difference between using front-face culling and setting a clockwise winding order explicitly, but winding order is supported by wgpu so we could add the field to StandardMaterial/StandardMaterialKey and set it directly on the pipeline descriptor if there's a reason to. it wouldn't help with dynamic scale adjustments anyway, and would still require a separate material. fixes bevyengine#4738, probably fixes bevyengine#7901. --------- Co-authored-by: François <[email protected]>
# Objective according to [khronos](KhronosGroup/glTF#1697), gltf nodes with inverted scales should invert the winding order of the mesh data. this is to allow negative scale to be used for mirrored geometry. ## Solution in the gltf loader, create a separate material with `cull_mode` set to `Face::Front` when the node scale is negative. note/alternatives: this applies for nodes where the scale is negative at gltf import time. that seems like enough for the mentioned use case of mirrored geometry. it doesn't help when scales dynamically go negative at runtime, but you can always set double sided in that case. i don't think there's any practical difference between using front-face culling and setting a clockwise winding order explicitly, but winding order is supported by wgpu so we could add the field to StandardMaterial/StandardMaterialKey and set it directly on the pipeline descriptor if there's a reason to. it wouldn't help with dynamic scale adjustments anyway, and would still require a separate material. fixes #4738, probably fixes #7901. --------- Co-authored-by: François <[email protected]>
https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#transformations
According to what I am reading, the indice order should be reversed if a node has a negative scale in its transformation. This makes little sense, as meshes can potentially be shared across different nodes, some of which may be reversed and some not. Face direction should be a per-mesh property, not a per-node property. Am I misunderstanding this?
The text was updated successfully, but these errors were encountered: