Hi Michael,
Thanks J-S. Yea I finally got it working. I did it by taking over the cull step
of the shadow maps and getting rid of the fixed function tex gen and then
pushing the matrices for the shadow projection into my vertex shaders and doing
the math there.
I think you may have overcomplicated things for yourself a bit... You
dind't have to remove any fixed function state at all, since when you
use shaders it's implicitly replaced by your shader. Also, in the shader
you have everything you need to be able to calculate the texgen already
(care of the TexGen and some other calculations). This is all spelled
out in the shaders at the top of src/osgShadow/StandardShadowMap.cpp, as
I mentioned before.
You have a function called DynamicShadow:
void DynamicShadow( in vec4 ecPosition )
{
// generate coords for shadow mapping
gl_TexCoord[1].s = dot( ecPosition, gl_EyePlaneS[1] );
gl_TexCoord[1].t = dot( ecPosition, gl_EyePlaneT[1] );
gl_TexCoord[1].p = dot( ecPosition, gl_EyePlaneR[1] );
gl_TexCoord[1].q = dot( ecPosition, gl_EyePlaneQ[1] );
}
(the gl_EyePlane* are set up by the TexGen) and you call it like this:
vec4 ecPos = gl_ModelViewMatrix * gl_Vertex;
DynamicShadow( ecPos );
And as I said, you can put the first part in a file that you will add to
every osg::Program you have, in addition to your own shader that will
have the second set of lines in it. Same for the fragment shader,, where
you would do the shadowmap lookup using the texcoords that were
calculated above in the vertex shader. That way you're not duplicating
much code, you're reusing the same file in many places. And you're
working within the system instead of replacing big parts of it, which I
find preferable since it's less prone to break later on if OSG changes.
Anyways, good to know you have something that works, but I just wanted
to point out that there may be a better way.
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org