Hey man thanks for the help! What I ended up doing was isolating the camera matrix from the model view matrix and only multiplying it in during the gl_Position call to translate the vertex in the shader. I rewrote my light model code.
Right now I need to work on my object class a bit more so that I'm actually using the correct tangent and binormal vectors for my faces instead of my current tangent space vector hack. I've been reading more about coordinate system transforms and basis vectors which has helped a lot. I'll throw up some new videos once I make more progress with this. By the way, where did you get all of those textures and normal maps at for your demos? I need some more artwork for my demos! :D
probably you're setting the light position at each frame after the camera modelview transformation, I've had a look at your code, when u calculate the transformed light position components try to use this formula v.x = dot(gl_LightSource[0].position, tangent);
instead of the ones u used multiplying for the modelview matrix(since you're using gl_LightSource.position u're gettin the light pos already in world coords).
Dude you gotta transform the tangent and binormal the same way you usually transform the normal in the vertex shader. Otherwise, the transformation matrix of the object is not considered. I had the same problem.
sorry for the double post, did a mess :p
MGBoney 4 years ago
Hey man thanks for the help! What I ended up doing was isolating the camera matrix from the model view matrix and only multiplying it in during the gl_Position call to translate the vertex in the shader. I rewrote my light model code.
Webking271 4 years ago
Right now I need to work on my object class a bit more so that I'm actually using the correct tangent and binormal vectors for my faces instead of my current tangent space vector hack. I've been reading more about coordinate system transforms and basis vectors which has helped a lot. I'll throw up some new videos once I make more progress with this. By the way, where did you get all of those textures and normal maps at for your demos? I need some more artwork for my demos! :D
Webking271 4 years ago
Actually I just spent a lot of time on google searching for the color maps :p
for the normal and displacement maps generation I've used Crazy Bump and ATI normal map generator, they're for free, check them out :)
MGBoney 4 years ago
I had a look at your code, try to calculate the light direction in this way:
v.x = dot(gl_LightSource[0].position, tangent); v.y = dot(gl_LightSource[0].position, binormal); v.z = dot(gl_LightSource[0].position, normal);
since u're using gl_LightSource.pos u don't need to multiply for the modelview matrix since u are already gettin the light position in world coords
hope it helps
MGBoney 4 years ago
probably you're setting the light position at each frame after the camera modelview transformation, I've had a look at your code, when u calculate the transformed light position components try to use this formula v.x = dot(gl_LightSource[0].position, tangent);
instead of the ones u used multiplying for the modelview matrix(since you're using gl_LightSource.position u're gettin the light pos already in world coords).
Do the same for v.y and v.z of course.
hope it helps
MGBoney 4 years ago
Dude you gotta transform the tangent and binormal the same way you usually transform the normal in the vertex shader. Otherwise, the transformation matrix of the object is not considered. I had the same problem.
programmertom2 4 years ago
By the way that's a super cool usage of normal maps haha.
programmertom2 4 years ago