Doh!

Thanks Robert, I had a niggling feeling it was something terribly
obvious...For the benefit of anyone following in my footsteps, you might
want to start off with a vertex shader looking more like this:

uniform sampler2D baseTexture;
uniform int baseTextureUnit;
uniform sampler2DShadow shadowTexture;
uniform int shadowTextureUnit;

        void main(void) {
            gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex ;
    gl_TexCoord[0] = gl_MultiTexCoord0; // base texture
    gl_TexCoord[1] = gl_MultiTexCoord1; // shadow tex if it is actually
bound to 1
            vec4 ecPosition = gl_ModelViewMatrix*gl_Vertex;
    gl_TexCoord[1] =
ecPosition*mat4(gl_EyePlaneS[1],gl_EyePlaneT[1],gl_EyePlaneR[1],gl_EyePlaneQ[1]);
}



best

Mike


On 14 November 2011 14:01, Robert Osfield <[email protected]> wrote:

> Hi Mike,
>
> You can't just throw in a very simple vertex shader to replace the
> built in vertex shader and expect it to work.  The vertex shader has
> to use texgen to create the texture coordinates for the shadow map.
>
> Robert.
>
> On 14 November 2011 12:06, Mike Connell <[email protected]> wrote:
> > Hi
> >
> > I've recently been testing out the new VDSM shadow implementation in
> trunk,
> > it's looking really nice.
> >
> > I have a problem with the default fragment shader - it stops working as
> soon
> > as I attach a vertex shader, even a quite innocuous one like this:
> >
> > void main(void) {
> >     gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex ;
> >
> >     gl_TexCoord[0] = gl_MultiTexCoord0;
> >     gl_TexCoord[1] = gl_MultiTexCoord1;
> > }
> >
> >
> > I am working with the osgshadow demo program, modified to attach the
> above
> > shader alongside the fragment shader, and before the VDSM is constructed
> I
> > edit the settings so that the shaders are constructed and used like this:
> >
> >
> >
> settings->setShaderHint(osgShadow::ShadowSettings::PROVIDE_VERTEX_AND_FRAGMENT_SHADER);
> >
> > The strange result is that both the vertex and fragment shaders appear to
> > run and there are no warnings about errors compiling or linking the
> > them.However the call to shadow2DProj() will always return (1,1,1,1) iff
> a
> > vertex shader is attached, but work fine without a vertex shader present
> -
> > ie every fragment is treated as shadowed.
> >
> > It feels like there is something vital missing from the vertex shader
> that
> > shadow2DProj relies upon, and which is provided by the fixed function
> > pipeline?
> >
> > I've also stripped the fragment shader down to simply perform a texture
> > lookup on the base texture and modulate by the value returned from
> > shadow2DProj, but this doesn't appear to make any difference.
> >
> > Has anyone seen anything like this before? Ideas?
> >
> > TIA
> >
> > Mike
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to