So, I’ve been playing around with trying to get a lighting shader to work. I basically just want it to do the exact same thing as the fixed functionality OpenGL lighting, except per fragment instead of per vertex.
I’ve tried several of the ones I’ve found on online, but none of them seem to match the fixed functionality of OpenGL. I am working under the assumption that the OpenGL lighting is “correct” and it’s just the per-vertex approximation that makes it look less than optimal. If this is not the case, please let me know. Stemming from this assumption, I assumed that when the camera is stationary, but rotating back and forth, that the specular patches should move around. This happens in the fixed functionality version, but in half of the Phong lighting model shaders I find online, the specular patches are strictly stationary. These are based off the modelview matrix, so maybe I am segregating the modelview and projection matrix operations incorrectly; I will specify how I do that later.
There are shaders I have found online that move, but they are seem to move more drastically than the fixed functionality, and the patches are in a different spot on the object (just using a sphere for now). I even tried generating a shader using 3D Labs ShaderGen to mimic fixed functionality, but it does the same thing (moves more dramatically, and is in the wrong spot).
As mentioned above, I figure this could stem from my segregating my modelview and projection matrix operations in some non-standard way, but even if I do, I would have thought this would have broken fixed functionality in the same way as the shaders (hence they would both be wrong, but wrong in the same way).
My projection matrix is Identity * my gluPerspective() call, and my modelview matrix is then Identity * my gluLookAt() call * whatever the objects own display matrix is. If this is non-standard, and you think it could be what is breaking the shaders, please let me know how they would anticipate them being.
I wouldn’t have thought it would be that hard to make a shader that matched the fixed functionality of OpenGL (assuming that is a desirable lighting model), hence I assume I’m just doing something else wrong.