Emulation of built-in uniforms

so far i’m still using opengl’s built-in uniforms for most of my lighting calculations, but i’d like to replace them by my own uniforms. this works well in most cases, but i still have some problems…

i realized that if i want to emulate gl_LightSource[n].position e.g., that i have to multiply my original vector by the inverse of the current modelview matrix and then pass this to the shader.
but what do i have to do to emulate gl_LightSource[n].spotDirection? i tried to do it the same way, but it results in no spotlight cone at all. in addition, gl_LightSource[n].spotCosCutoff does not seem to be equal to cos(gl_LightSource[n].spotCutoff)…

is there a document that decribes how these built-in uniforms are computed? it’s not in the glsl specs :frowning:

check the gl spec (the lighting section) i believe they have the various lighting equations written down.

with the spot direction u dont wanna take into consideration the position ie uonly the direction, the 3x3 part of the 4x4 matrix.

for the cos cutoff i think GL u specify it in degrees but cos takes radians as input so use cos( X * DEG2RAD )

realized that if i want to emulate gl_LightSource[n].position e.g., that i have to multiply my original vector by the inverse of the current modelview matrix and then pass this to the shader.
Remember one thing - light position is transformed by matrix when glLight is called to setup it’s position. When you render polygons your matrices can be completely different.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.