At the moment, your code is written to use world-space normal-maps. Is that intended?
You don't have vertex streams for normals/tangents/binormals, which means you're unable to properly decode a tangent-space normal map (the kind where flat areas a bluish).
Also, your calculation of eyevec seems suspect - this should be a vector between the pixel and the eye, but it seems as if you're getting a direction between the origin and the eye.
At the moment, your code is written to use world-space normal-maps. Is that intended?
You don't have vertex streams for normals/tangents/binormals, which means you're unable to properly decode a tangent-space normal map (the kind where flat areas a bluish).
Also, your calculation of eyevec seems suspect - this should be a vector between the pixel and the eye, but it seems as if you're getting a direction between the origin and the eye.
Thanks
How can I calculate the tangent/binormal? Can I do this inside the shader? And also what would be the "correct" way to calculate eyevec
you need to provide tangents
you can find binormal with cross(normal, tangent)
and eye vector is usually v_eye = normalize(-positon.xyz) * tbnMatrix; in the vertex shader
where position is the world-space position of vertices
youll have to do the same to v_light... v_light = normalize(lightposition.xyz) * tbn;
aka converting it to tangent / texture space
youll have to rotate normal, tangent and binormal, using gl_NormalMatrix
and normalize them, you can do that in the same line as you make the tbn matrix:
you need to provide tangents
you can find binormal with cross(normal, tangent)
and eye vector is usually v_eye = normalize(-positon.xyz) * tbnMatrix; in the vertex shader
where position is the world-space position of vertices
youll have to do the same to v_light... v_light = normalize(lightposition.xyz) * tbn;
aka converting it to tangent / texture space
youll have to rotate normal, tangent and binormal, using gl_NormalMatrix
and normalize them, you can do that in the same line as you make the tbn matrix:
probably not, you most likely will have to provide tangents along with normals... using attributes
its probably best if you move from standard vertex struct to a user defined one, using vertexattrib and VAOs
if theres anything you need help with on that part i can post some of my code and compare it
openGL is hillariously undocumented, and more often than not i seem to be reading the specifications for each and every thing i have to use =)
either way, make sure you have tangents to start with and go from there
im sure someone can explain why trying to make tangents is a bad idea, but i dont know why...