-
-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lighting on models that use normal maps #6073
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
369310a
to
c301a04
Compare
Yep, makes sense. Done. |
c301a04
to
26ace92
Compare
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
26ace92
to
c7555c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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