PDA

View Full Version : emulation of built-in uniforms



Vexator
08-11-2006, 02:21 AM
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 :(

zed
08-11-2006, 11:22 PM
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 )

k_szczech
08-14-2006, 03:05 PM
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.