technomage
07-03-2007, 11:57 PM
Yet another question for anyone who has working with shaders.
I am implementing normal mapping in my engine, currently I am passing in my Light Position in world coordiantes, most of the shaders i have seen use eye coordinates for calculating the light direction.
mostly this is done via
GLSL
lightDir = (lightPosition - ecPosition).xyz
where ecPosition is the gl_Vertex transformed into eye space.
now, I have tried to transform my lightPosition into eye space by
ecLightPos = lightPosition * gl_ModelViewMatrix;
but this does not produce the result I am expecting, in fact it produces some weird results, the lights seem rotate as well.
I would rather not have to define my lights in eye coordinates in my app, but as an actual location in the world.
I hope this makes sense. Anyone got any tips or examples on this.
Oh as a side note, most of the example shaders don't deal with moving objects, they all seem to assume that an object is at 0,0,0
I am implementing normal mapping in my engine, currently I am passing in my Light Position in world coordiantes, most of the shaders i have seen use eye coordinates for calculating the light direction.
mostly this is done via
GLSL
lightDir = (lightPosition - ecPosition).xyz
where ecPosition is the gl_Vertex transformed into eye space.
now, I have tried to transform my lightPosition into eye space by
ecLightPos = lightPosition * gl_ModelViewMatrix;
but this does not produce the result I am expecting, in fact it produces some weird results, the lights seem rotate as well.
I would rather not have to define my lights in eye coordinates in my app, but as an actual location in the world.
I hope this makes sense. Anyone got any tips or examples on this.
Oh as a side note, most of the example shaders don't deal with moving objects, they all seem to assume that an object is at 0,0,0