bevy/crates/bevy_gltf
robtfm 28060f3180
invert face culling for negatively scaled gltf nodes (#8859)
# Objective

according to
[khronos](https://github.com/KhronosGroup/glTF/issues/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 <mockersf@gmail.com>
2023-09-18 15:55:24 +00:00
..
src invert face culling for negatively scaled gltf nodes (#8859) 2023-09-18 15:55:24 +00:00
Cargo.toml Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00