Hi,
I have been working for a while on compatibility issues with nVidia and ATI
in our OpenSceneGraph application. Aside from a fair number of GLSL shader
source issues, one of the last remaining problems was that textured objects
were not casting shadows (please see first attached screenshot).
After a little detective work, it seems that the empty osg Program attached
to the StateSet belonging to the _camera in StandardShadowMap::ViewData::init()
is causing the problem:
>
> // optimization attributes
> osg::Program* program = new osg::Program;
> stateset->setAttribute( program, osg::StateAttribute::OVERRIDE |
> osg::StateAttribute::ON );
> stateset->setMode
> ( GL_LIGHTING, osg::StateAttribute::OVERRIDE |
> osg::StateAttribute::OFF );
> stateset->setMode
> ( GL_BLEND, osg::StateAttribute::OVERRIDE |
> osg::StateAttribute::OFF );
>
> #if 0 // fixed pipeline seems faster (at least on my 7800)
> program->addShader( new osg::Shader( osg::Shader::FRAGMENT,
> "uniform sampler2D texture;
> \n"
> "void main(void)
> \n"
> "{
> \n"
> " gl_FragColor = texture2D( texture, gl_TexCoord[0].xy );
> \n"
> "}
> \n"
> ) ); // program->addShader Fragment
>
> program->addShader( new osg::Shader( osg::Shader::VERTEX,
> "void main(void)
> \n"
> "{
> \n"
> " gl_Position = ftransform();
> \n"
> " gl_TexCoord[0] = gl_MultiTexCoord0;
> \n"
> "}
> \n"
> ) ); // program->addShader Vertex
> #endif
>
The setting of the fragment and vertex shaders to the stateset are #if 0'd
out, but the osg Program setting is not.
Anyway, if I skip adding the empty program, things seem fine. Oddly, if I
keep the empty program and skip the AlphaFunc above it that allows texture
alpha to affect the depth buffer render, it casts shadows properly (well,
without the alpha penetration of course).
Everything works fine with nVidia drivers, even with the empty program.
My scene has a mixture of shader programs depending on how the objects are
setup, but they all include the shadow shader source (except the flat shaded
objects like the force arrows shown below).
So it seems to be an easy fix, but I was curious if anyone else had run into
this problem? I did many searches on the forum and came up empty.
And if anyone has deeper illumination into how the empty program could affect
the statesets (seems like a bug to me since nVidia works fine), or if there is
a more appropriate fix I'm not thinking of, I'd appreciate the feedback.
Thanks-
Baker Searles
Hardware Versions:
nVidia GTS 250
ATI Radeon HD4670
Software Versions:
OSG @ 2.8.3
ATI Display Drivers @ 10.7
nVidia Display Drivers @ 258.96
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30329#30329
Attachments:
http://forum.openscenegraph.org//files/ati_emptyglslprogram_noalphafunc_163.jpg
http://forum.openscenegraph.org//files/ati_noemptyglslprogram_192.jpg
http://forum.openscenegraph.org//files/ati_emptyglslprogram_debughud_103.jpg
http://forum.openscenegraph.org//files/ati_emptyglslprogram_167.jpg
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org