Hello,
I have a problem trying to implement depth-peeling using a CG shader. The issue is that i get only 8-bit precission for the texture containing the depths of the previous layer. I load it with the standard
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, data );
And the image i load has more than 8-bit precission (i’ve obtained it by reading the depth buffer from a previous render), i check it by making an histogram.
OpenGL returns ok to the previous command, but in the shader that follows :
void main(
in float4 in_color0 : COLOR0,
in float4 in_position : WPOS,
in float4 in_normal : TEXCOORD0,
uniform float window_width
uniform float window_height,
uniform sampler2D front_depth_map,
uniform float3 world_eye_direction,
out float4 out_color : COLOR
)
{
// Epsilon for 8-bit precission
float epsilon = 0.004;
float2 tex_coords = float2(
(in_position.x)/(window_width),
(in_position.y)/(window_height) );
float front_depth = tex2D( front_depth_map, tex_coords ).x;
if ( front_depth+epsilon >= in_position.z/in_position.w ) discard;
out_color = in_color0;
// Code normal orientation
if ( dot(world_eye_direction,in_normal)>0.0 )
out_color.r = out_color.r + 0.5;
}
i get only 8-bit precission for the texture lookup result.
What am i doing wrong? My card is an NV 5650FXGo, supporting nv30 shaders.
Thanks in advance for any hint you could provide, i’ve been trying to find out what’s happening for a long time and a deadline is approaching…
(bandoler)
P.S. Only in case you are wandering… i’m trying to make global illumination.