[osg-users] How to render depth texture

Marcus Fritzen mfritzen at uni-koblenz.de
Thu Sep 13 02:04:17 PDT 2007


Hi Mihai,

i thought more or less about the same. After trying a little bit I ended 
up with the following shader, which does what I want.

uniform sampler2D shadowMap;

void main(void)
{
    vec4 texCoord = gl_TexCoord[1].xyzw;
    float value = texCoord.z / texCoord.w;
    gl_FragColor = vec4( value, value, value, 1.0 );
}

But there is a little artifact which I get on my ground and at the 
moment I am not sure why. When I have solved this problem I will tell 
you. Attached is an image of my scene.

--marcus

Mihai Radu wrote:
> Hi Marcus,
>
> If you use shaders, you can render the depth texture to a quad using
> texture access function in place of shadow2D().
>
> The trouble is that the values are not suitable for rendering, if you
> looks through the archives, someone posted how to map the values to some
> useful gray scale ( all I remember of it is subtracting 128 from the
> color value from the texture op. ).
>
> I hope this will set you on the right path, and if you manage to do it,
> please post the solution.
>
> Cheers
> Mihai
>
> Marcus Fritzen wrote:
>   
>> Hello,
>>
>> is there an easy and fast way how I can render the depth values from the 
>> depth texture to screen so that the scene is in grayscale? If i do a 
>> shadow2D(...) in the shader, it is directly compared with the actual 
>> depth value or am I wrong? So I am unsure how I can reach the actual 
>> depth value stored in the depth texture.
>>
>> Thx.
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>   
>>     
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: st2.jpg
Type: image/jpeg
Size: 26440 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070913/20ea054f/attachment-0006.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: st1.jpg
Type: image/jpeg
Size: 28346 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070913/20ea054f/attachment-0007.jpg>


More information about the osg-users mailing list