Repository navigation
Match Cycles' Normal Map node tangent frame (codepawl/crucible#1111) - #57
Merged
Merged
Conversation
Cycles builds the tilted normal of a tangent-space normal map in object space (unnormalised vertex normal, UV tangent and handedness) and moves the result to world space as a normal. On an instance with a non-uniform scale the tilt shrinks along the stretched axes. Cook moved the tangent as a vector and rebuilt the bitangent from the world normal, so such a mesh was lit with the full tilt. The shading point now carries normal_map_tangent and normal_map_bitangent: the object-space tangent and cross(normal, tangent) * sign, moved with the inverse transpose and divided by the length of the moved normal, so tangent * x + bitangent * y + normal * z is the node's result. The base normal map and the coat normal map read it; bump and anisotropy keep the old frame. Measured against Cycles 5.3 at 480x270, 256 spp: a normal-mapped plane scaled 1.8 x 1.8 x 1 went from mean ratio 0.956, relMSE 0.0032 and 15 of 64 tiles over 5 percent to mean 1.0015, relMSE 4e-6 and 0 tiles over. Only instanced scenes reach this path; a flattened scene has the matrix baked into the vertices.
This was referenced Nov 16, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of codepawl/crucible#1111.
What was wrong
Cycles builds the tilted normal of a tangent-space normal map in object space and moves it to world space as a normal (inverse transpose). On an instance with a non-uniform scale the tilt shrinks along the stretched axes. Cook moved the tangent as a vector and rebuilt the bitangent from the world normal, so the same map tilted the normal more than in Cycles.
The fix
The shading point carries
normal_map_tangentandnormal_map_bitangent: the object-space tangent andcross(normal, tangent) * sign, moved with the inverse transpose and divided by the length of the moved normal.tangent * x + bitangent * y + normal * zthen equals the Normal Map node. The base and coat normal maps read it; bump and anisotropy keep the old frame.How I checked it
node tools/run-cargo-tests.mjs: 140 + 23 passed, including a new test of the kernel text.The Crucible side (parity scenes, Normal Map node in
render-cycles.py, evidence) is in the Crucible pull request.