[osg-users] How to render depth texture

Mihai Radu radu at cm-labs.com
Tue Oct 2 16:07:09 PDT 2007


Hi Marcus,

Looking again at the shader code you posted, it looks like you are
rendering the texture coordinates generated by _texGen, not the actual
contents of the shadow map, this may have something to do with the
ground artifact that appears. It closely tracks the depth values, that's
why you got results very close to what you were looking for.

I'm trying to get debugHUD() working for ShadowMap, and I would
appreciate any help.

Cheers
Mihai


Marcus Fritzen wrote:
> 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
>>
>>   
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   



More information about the osg-users mailing list