EDIT : I tried the geexlab method, it’s working, code snippets soon.
Hello, I’m re-trying to get linear depth buffer, this is driving me crazy
the left buffer is panda default non linear depth buffer,
the right buffer is my try for linear depth buffer.
//Cg
void vshader(in float4 vtx_position : POSITION,
in float4 vtx_texcoord0 : TEXCOORD0,
uniform float4x4 mat_modelproj,
uniform float4x4 trans_model_to_view,
uniform float4x4 trans_model_to_world,
uniform float4x4 trans_model_to_clip,
uniform float3 k_scale,
out float4 l_position : POSITION,
out float2 l_texcoord : TEXCOORD1,
out float4 l_position_VS : TEXCOORD2,
out float4 l_color : TEXCOORD4
)
{
l_position_VS = mul(trans_model_to_view, vtx_position* float4(k_scale,1));
l_texcoord = vtx_texcoord0;
l_position = mul(trans_model_to_clip, vtx_position * float4(k_scale,1));
}
void fshader(
in float2 l_texcoord : TEXCOORD1,
in float4 l_position_VS : TEXCOORD2,
in float4 l_color : TEXCOORD4,
out float4 o_color0 : COLOR0)
{
float depth =1/(l_position_VS.z);
o_color0 = depth;
}
My near clip plane is at 10, far at 500.
I tried the code found here : http://www.gamerendering.com/2008/09/28/linear-depth-texture/, I get full black color values.