Fix lighting on models that use normal maps#6073
Fix lighting on models that use normal maps#6073fluffyfreak merged 1 commit intomasterfrom unknown repository
Conversation
sturnclaw
left a comment
There was a problem hiding this comment.
Thank you for catching this issue!
Because the meaning of ATTRIB_TANGENT is intended to be the numeric value 5, I'd prefer you change VertexBufferGL.cpp line 23 to return the proper attribute index instead. It's slightly simpler that way and shares the same value across both shaders and C++ source.
|
Yep, makes sense. Done. |
|
As a general git-etiquette thing, we prefer to avoid mentioning issue numbers and @-usernames in commit messages; every time the commit in question is pushed (including to other users' forks, etc.) Github triggers a notification of the mentioned issue/user. Otherwise the code looks quite simple now! 😉 |
- lighting on models that use a normal map were incorrect and normal map had no effect on lighting - a_tangent was always (0, 0, 0) but a_uv1 had tangent data - attribs.glsl and Program.cpp have tangent at location 5 but the vertex buffer layout has tangent at index 4. - ATTRIB_TANGENT changed to index 5 in gett_attrib_index() in VertexBufferGL.cpp
fluffyfreak
left a comment
There was a problem hiding this comment.
Approved 👍 one character bug fixes are the best 😁
|
I gave it a few days in case anyone wanted to merge or comment, merging now |



The lighting on the models that use a normal map were not looking correct and the normal map had no effect on lighting.
I setup a test shader that did a dump of a_tangent and it was always (0, 0, 0) which explained why the normal calc in the fragment shader was incorrect. I then did a dump of a_uv1 and it had the tangent data. I swapped the locations of a_tangent and a_uv1 in attributes.glsl and the lighting on normal mapped models now looks correct , to me :).
After some digging I found that attributes.glsl and Program.cpp have tangent at location 5 but the vertex buffer layout in VertexBufferGL.cpp (line 23) has tangent at index 4.
So by putting a_tangent in location 4 the lighting is now correct for models using a normal map