Hi. I've fixed the problem with the depth texture display, now it looks like this: http://youtu.be/XMOalXm0KdE I had to use [0; 1] scale for the quad to display DEPTH_BUFFER texture: http://goo.gl/xU9u3u The quad creation function: http://goo.gl/TbGaet However, I don't get why the display of all the rest COLOR_BUFFER textures is working fine with [0; 1024] scale: http://goo.gl/D1TWRK Can anyone explain why only use [0; 1] scale for the depth texture, please? Thanks.
2013/10/10 Marcel Pursche <[email protected]> > 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 > [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

