Viewer: normal maps in a tangent frame built from the UV set they are sampled with #120
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/holdmysocks--SixNG!120
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/120/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@holdmysocks on GitHub · 2026-11-24 04:52 UTC · original
holdmysocks:claude/tangent-frame→master· +89 −3 · 5 files · 2 commits · merged 2026-11-24 05:01 UTCSupersedes #112. Reported in #112 by DarkBlade909.
Cause
The tangents stored in the models follow the second UV set, not the first one the viewer samples normal maps with. Measured per triangle (stored tangent against dP/du,
cross(n, t) * wagainst dP/dv, area weighted):rhino_hiplayer_story000_01_pantsjeans_mr1_002_regular_mw_long_fullSo on models whose two layouts differ the frame was unrelated to the normal map, and the
tn.y = -tn.yflip was right on some surfaces and wrong on others. That is why the jeans looked right without the flip and the rhino's bolts looked right with it.Change
glb.rs: the loader builds the frame from UV0 for every mesh with tangents: tangent along +u, sign so thatcross(n, t) * wruns along +v (down the image). Mirrored halves get the opposite sign from their UV winding. Vertices no triangle with UV area touches keep the stored frame.shader.wgsland the Metal shader: the green flip is removed; green is used as stored (DirectX style, green = +v).Verified
rhino_hiat--tod 12: side armour bolts lit from above on both sides of the tank (mirrored halves); on master they were lit from the side.Not verified