Hi,

In my quest for food (i.e. lunch), I failed to mention what I have tried. I create a 2D texture like:

 m_DepthTexture = new osg::Texture2D();
 m_DepthTexture->setInternalFormat(GL_DEPTH_COMPONENT);
 m_DepthTexture->setShadowComparison(true);
 m_DepthTexture->setShadowTextureMode(osg::Texture::LUMINANCE);
 m_DepthTexture->setFilter(osg::Texture2D::MIN_FILTER,
   osg::Texture2D::LINEAR);
 m_DepthTexture->setFilter(osg::Texture2D::MAG_FILTER,
   osg::Texture2D::LINEAR);
 m_DepthTexture->setTextureSize(width, height);

 m_CameraNode->attach(osg::CameraNode::DEPTH_BUFFER, m_DepthTexture);

Then I associate a texture environment with my geometry that I'll be applying the shader to:

 osg::ref_ptr<osg::TexEnv> texenv = new osg::TexEnv;
 texenv->setMode(osg::TexEnv::DECAL);
 m_Geometry->getOrCreateStateSet()->setTextureAttribute(1,texenv.get());

I set up my shader uniform as a osg::Uniform::SAMPLER_2D_SHADOW and assign it the appropriate texture unit.

I am also attaching a osg::CameraNode::COLOR_BUFFER to the same camera node with an appropriate texture.


Finally, I've got a simple shader program that I'm trying to use.

uniform sampler2DShadow texDepth;

void main()
{
 vec4 shadow = shadow2D(texDepth, gl_TexCoord[1]);
 gl_FragColor = shadow;
}


Regardless as to what my scene contains, the shader output is always pure white. However, if I remove the shader portion, the scene renders fine. There are no debug output errors that I have seen. The FBO is created fine.

If anyone has any insight into this problem, I'd really appreciate it.

Thanks,
Brian


----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, February 12, 2007 11:12 AM
Subject: [osg-users] Question about osgdepthshadow example.


Hi,

I'm trying to modify this example slightly so that only the depth buffer
portion is rendered. The shadow is cool, but is there a way to just render
the depth buffer?

Thanks,
Brian

_______________________________________________
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/

Reply via email to