Hi Sebastian,

> But in case one is writing to the attached depth target (e.g. a linear 
> depth value) the hierachical culling should be gone AFAIK.


Well my idea was to write to the regular color buffer target. The depth target 
is unaffected. It will still use the logarithmic depth value and all hardware 
optimizations. Here is a bit of pseude code that should explain my idea.


Code:

osg::ref_ptr<osgTexture2D> depthTexture = new osg::Texture2D;
depthTexture->setSourceFormat(GL_RED);
depthTexture->setInternalFormat(GL_R32F);
depthTexture->setSourceType(GL_FLOAT);
... //setup height here

osg::ref_ptr<osg::Camera> camera = new osg::Camera;
... // setup code for camera with matrix, reference system, framebuffer etc.
depthCamera->attach(osg::Camera::COLOR_BUFFER, depthTexture);
depthCamera->setClearColor(osg::Vec4(farPlane, 0.0f, 0.0f, 0.0f);




and the shaders for the shadow pass:

Code:

// vertex shader
smooth out float depth;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 viewPosition = gl_ModelViewMatrix * gl_Vertex;
depth = -viewPostion.z;
}

// fragment shader
smooth in float depth;
void main()
{
gl_FragColor = vec4(depth, 0.0, 0.0, 1.0); // or use linearized depth, whatever 
you like
}




If I find some time, I will write a small application to compare the 
performance of the regular approach and the usage of a color texture.

Thank you!

Cheers,
Marcel

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56697#56697





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to