How do you do this in GLSL?

Transform a point into World Coordinates = gl_ModelViewMatrix * gl_Vertex; (right)?

Transform a point into Light Coordinates = …..?

I think I need to create a transformation matrix which converts the vectors from the identity matrix into the vectors of the light coordinates…?

]]>vec3 normals = normalize(gl_NormalMatrix * gl_Normal);

vec 3 lightDir = normalize(vec3(gl_LightSource[0].position));

and then get their dot product:

dot(normal, lightDir);

is that what you need?

Also remember that the view it is just a type of modeling applied to the eye coordinates.

]]>The same way that gl_Vertex is passed in the application in Model Coordinates, and gl_ModelViewMatrix transforms this vertex into World Coordinates, then Lighting Coordinates, how do you obtain this transformation matrix?

This uberlight shader from the orange book needs to express the points in lighting space…

]]>I see. As far as I understand these are the only built-in uniforms that describe the transformation state of a matrix( with their inverse and transposition in the case of the first 4):

gl_ModelViewMatrix

gl_ModelViewProjectionMatrix

gl_ProjectionMatrix

gl_TextureMatrix[gl_MaxTextureCoords]

gl_NormalMatrix

check the struct that describes gl_LightSourceParameters, one of the members is the light position. Maybe on later implementations of glsl there is something to retrieve such coordinates, not sure about it.

For sure this seems to be a question for the openGL forum!

]]>http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=222573

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=298171

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=126782

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=26310&page=2

hope it helps! let me know how it goes!

]]>