Hi All,

Today I've trying to get a GLSL program to generate tex coords in the
same way as non shader texgen works.  I've read up the orange book on
the topic, and also searched the web for inspriation, and what I've
written look like should work, but it doesn't :-|

The vertex program I've kept simple so far and looks like

void main (void)
{
   gl_Position = ftransform();
   gl_FrontColor = vec4(1.0,1.0,1.0,1.0);
   gl_TexCoord[0] = gl_MultiTexCoord0;

   vec4 ecPosition = gl_ModelViewMatrix*gl_Vertex;

#if 1
   gl_TexCoord[1] = ecPosition * mat4(gl_EyePlaneS[1],
                                      gl_EyePlaneT[1],
                                      gl_EyePlaneR[1],
                                      gl_EyePlaneQ[1]);

   gl_TexCoord[1].p = 0.0;
   gl_TexCoord[1].q = 1.0;
#else

   gl_TexCoord[1].s = dot(ecPosition, gl_EyePlaneS[1]);
   gl_TexCoord[1].t = dot(ecPosition, gl_EyePlaneT[1]);
   gl_TexCoord[1].p = 0.0; // dot(ecPosition, gl_EyePlaneR[1]);
   gl_TexCoord[1].q = 1.0; //dot(ecPosition, gl_EyePlaneQ[1]);

#endif
//    gl_TexCoord[1] = gl_MultiTexCoord0;
}


The two parts of the #if #else #endif work identically, if I comment
out the resetting og the p and q values I have what I think is correct
code, but the generated tex coords are clearly wrong as I don't any
valid texture being accessed.  By adding the p and q setting in I do
at least get half sensible values, but there still are not correct as
distortion occurs as I change the eye point.

glxinfo gives me:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 7800 GT/PCI/SSE2
OpenGL version string: 2.0.2 NVIDIA 87.62


I am not setting the fragment program yet, so it should be the
standard OpenGL fixed function pipeline for the shader.

Any ideas?
Robert.
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to