Repository navigation
Normal mapping without tangents: negate the derivative bitangent for glTF - #200
Conversation
…glTF The screen-space tangent frame returns the direction of increasing v, but glTF's v runs down the image while its normal maps keep +Y up, so the frame inverted the normal map's green channel on every mesh without a TANGENT attribute. On low-poly meshes whose normal map carries the smoothing, each triangle showed as a facet. The vertex-tangent branch was already correct.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What
compute_tbn, the screen-space tangent frame used when a mesh has noTANGENTattribute, returned the bitangent along increasingv. glTF'svruns down the image while its normal maps keep +Y up, so the glTF bitangent (cross(normal, tangent) * w, what the vertex-tangent branch builds) points along decreasingv. The fallback therefore inverted the normal map's green channel on every tangent-less mesh.Why it matters
On a low-poly mesh whose normal map carries the smoothing (every generated character and prop in The Deep), the inverted channel doubles the faceting instead of cancelling it: each triangle shows as a facet under a directional light. Found by rendering the same GLB in three.js and in Bloom at the same camera: three.js is smooth, Bloom was faceted, and with this change Bloom matches.
Checks
cargo test --releaseinnative/shared: 501 unit tests and all 86 golden renders pass with no golden changes.visibility_shading_matches_forward_referencefails, as it does onmain.Summary by CodeRabbit