Hi,
To make phong shading using shaders(in GLSL), I have to pass the the light 
position to the vertex shader,  But the position of the vertex will be in 
eyespace (after multiplication with the ModelView matrix). So I need the light 
position in eye-space as well. Which is the best way of obtaining the correct 
light position? Either I need the vertex position to be in world space, I do in 
this way:

 
mat4 modelMatrix = osg_ViewMatrixInverse* gl_ModelViewMatrix ;
WorldPos=modelMatrix * gl_Vertex;
mat3 normalmatrix=mat3(modelMatrix);
WorldNrm=normalize(normalmatrix * gl_Normal);

though it works well to get the world space coordinate of each vertex, but to 
compute specular of object I have to know the eye position, since we are not in 
eye coordinates the eye postion is no longer (0,0,0), must the eye coordinate 
be passed by uniform?

Or I need the light position in eye space. I try to translate the light 
position into eye coordinate in this way:
 Pos_light0 =  osg_ViewMatrix *light0_pos  ; 
 or 
 Pos_light0 =  light0_pos * osg_ViewMatrix ; 

 but it seems not work.

What are the general strategy for this problem?


Thanks very much!


Julie
2008-09-09
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to