GLSL lighting. Bad normals? Bad shader? Something else entirely?

This is a discussion on GLSL lighting. Bad normals? Bad shader? Something else entirely? within the Game Programming forums, part of the General Programming Boards category; In my engine, I'm ~trying~ to do per-pixel/normal mapped lighting with GLSL shaders. I'm using a modified shader from RenderMonkey. ...

GLSL lighting. Bad normals? Bad shader? Something else entirely?

In my engine, I'm ~trying~ to do per-pixel/normal mapped lighting with GLSL shaders. I'm using a modified shader from RenderMonkey. Everything compiles properly, but everything is illuminated at full-bright (as if there was no lighting).

Hmm. Have no idea sand_man. In fact I've been looking for information on tangent vectors and what to use them for and how to compute them. Your code has helped a bit.

Explain more of what your approach is in general terms and perhaps I can help or at least point you in the right direction. I'm trying to do per-pixel lighting as well, but I'm not doing all the calculations that you are.

The shader is for normal mapping, however iv'e edited it, so that there is no bump texture, it's just flat per-pixel lighting. Iv'e done this, so I can switch easily between bumped and flat.

My approach:
1. I calculate the tangent and bitangent vectors, during the loading of the model.
2. I pass the vectors to the shader as attribute variables. In GLSL, attribute variables can only be used in the vertex shader, and are used (as the name might suggest) on a per-vertex basis. One of the problems I found though, Is I can't pass the whole array of vectors to the shader, as the shader does things one vertex at a time (one a cycle? i don't really know the terminology). So, I decided to update the vectors in the shader once at the end of the models draw cycle. I'm thinking this may be a bad approach, but I havn't found anything that tells me to do otherwise.

The math for the tangent calculation, is (loosely) based on this code, from a tutorial I found on emboss bump mapping (I believe it's from codesampler.com):