This is the excerpt we are using and it works for lighting calculations
(also need to calculate clip planes) on our volume rendering framework:
"void main() \n"
"{ \n"
"gl_Position=ftransform(); \n"
"gl_ClipVertex = gl_ModelViewMatrix*gl_Vertex;\n"
" \n"
"eyePos = gl_ClipVertex;\n"
"gl_TexCoord[0].s=dot(eyePos,gl_EyePlaneS[0]); \n"
"gl_TexCoord[0].t=dot(eyePos,gl_EyePlaneT[0]); \n"
"gl_TexCoord[0].p=dot(eyePos,gl_EyePlaneR[0]); \n"
"gl_TexCoord[0].q=dot(eyePos,gl_EyePlaneQ[0]); \n"
"gl_TexCoord[0] *= gl_TextureMatrix[0];\n"
biv
On 1/24/07, Brede Johansen <[EMAIL PROTECTED]> wrote:
On 1/24/07, Wojciech Lewandowski <[EMAIL PROTECTED]> wrote:
> I could recommend
> chapter 9 "Emulating OpenGL Fixed Functionality" of Addison Wesley
"OpenGL
> Shading Language" book.
ShaderGen from 3Dlabs is another alternative.
http://developer.3dlabs.com/downloads/shadergen/
Regards,
Brede
On 1/24/07, Wojciech Lewandowski <[EMAIL PROTECTED]> wrote:
> Vertex Shaders overrides TexGen functionality (like other transform and
> lighting functionality). You need to add Tex Coord generation code to
> shader. I briefly looked at your code and suppose that following change
in
> shader would do it (sorry had no time to check it). I could recommend
> chapter 9 "Emulating OpenGL Fixed Functionality" of Addison Wesley
"OpenGL
> Shading Language" book.
>
> uniform int transformModeX;
>
> void main()
> {
> #if 1 // Emulate TexGen Object mode at texture stage 0
> gl_TexCoord[0].s = dot(gl_Vertex, gl_ObjectPlaneS[0]);
> gl_TexCoord[0].t = dot(gl_Vertex, gl_ObjectPlaneT[0]);
> gl_TexCoord[0].p = dot(gl_Vertex, gl_ObjectPlaneR[0]);
> gl_TexCoord[0].q = dot(gl_Vertex, gl_ObjectPlaneQ[0]);
> #else
> gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
> #endif
> gl_FrontColor = gl_Color;
> gl_BackColor = gl_Color;
> vec4 v = vec4(gl_Vertex);
> // Change the test to transformModeX == 0 to enable.
> // This is here to help verify that this shader is actually being
used.
> // Change the C code's gluOrtho2D call so the camera gets
> // a better picture. (Switch the one that is commented out.)
> if(transformModeX == 1)
> {
> // The multiply factor makes this log10()
> v.x = log2(v.x) * 0.301029995664;
> }
> gl_ClipVertex = gl_ModelViewMatrix * v;
> gl_Position = gl_ModelViewProjectionMatrix * v;
> }
>
> Cheers,
> Wojtek Lewandowski
>
> ----- Original Message -----
> From: "E. Wing" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Wednesday, January 24, 2007 6:32 AM
> Subject: [osg-users] Problem using a Vertex Shader with TexGen
>
>
> >I am trying to produce a simple cheesy effect. I am trying to make a
> > moving dotted line (think similar to a barber shop pole).
> >
> > - I start with a GL_LINE_STRIP.
> >
> > - Then I add a 1D texture to it so I can control how it looks and how
> > it moves. (Currently it is an alternating off-on texture so it looks
> > like a dotted line.)
> >
> > - I use osg::TexGen to generate texture coordinates for me. (In my
> > general case, I may add or subtract points to my line so I didn't want
> > to have to manually set TexCoords myself.)
> >
> > - I then use osg::TexMat to generate movement
> >
> > This all seems to work well enough.
> >
> > But my final step is where things seem to break. I then add a Vertex
> > Shader to the mix. When I do this, my line does not render correctly.
> > Often I seem to get a line that completely flashes off or on, rather
> > than seeing the animated dots.
> >
> > To start with, I'm just trying to write a simple vertex shader that is
> > effectively a pass-through program so it should look identical to the
> > fixed pipeline program. I have been able to reproduce the problem on
> > both Mac and Windows (with different video cards). So I'm guess I'm
> > missing something important.
> >
> > If I remove the glTexGen stuff and set the glTexCoord manually, things
> > seem to work, but I would like to know how to get it to work with
> > glTexGen as well. (It makes my general case easier.) I assume I'm
> > doing something wrong with either my shader or the way I set up
> > TexGen.
> >
> > Attached is a tar-ball containing the source to two programs plus my
> > vertex shader. One uses TexGen, the other does not. In the program
> > that uses TexGen, there is a single line of code that will make or
> > break the program. Search for "KEY LINE". If the line is enabled, the
> > shader is used and I get the flashing. If disabled, the program works
> > as expected. (Also, I think I might have found a bug in OSG. As noted
> > in the comment, if I set the stateset's setAttributeAndModes to
> > osg::StateAttribute::OFF, the shader still gets loaded and run.)
> >
> >
> > Can somebody tell me how to fix my program so it works with TexGen?
> >
> > This is the build line I use for Mac:
> > g++ -D__USE_OSX_AGL_IMPLEMENTATION__ shader_<no>texgen.cpp -framework
> > osg -framework osgUtil -framework osgDB -framework osgGA -framework
> > osgProducer -framework Producer -framework OpenThreads -framework
> > osgText -framework OpenGL
> > (Adapt as necessary for your platform.)
> >
> >
> > Thanks,
> > Eric
> >
>
>
>
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://openscenegraph.net/mailman/listinfo/osg-users
> > http://www.openscenegraph.org/
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/