Hi,
I'm messing with some Cg in FX Composer, and I'd like to know how to set up and sample pixels from the depth buffer.
I'm setting up the depth texture and sampler like this:
texture DepthTexture : RENDERDEPTHSTENCILTARGET
<
float2 ViewPortRatio = {1.0, 1.0};
string Format = "D24S8";
>;
sampler2D DepthSampler = sampler_state
{
texture = <DepthTexture>;
WrapS = ClampToEdge;
WrapT = ClampToEdge;
MinFilter = Linear;
MagFilter = Linear;
};
and setting up the technique and pass like this:
technique Main
<
string Script =
"RenderColorTarget0=RTTTexture;"
"RenderDepthStencilTarget=DepthTexture;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"ScriptExternal=color;"
"Pass=MainPass;";
>
{
pass MainPass
<
string Script =
"RenderColorTarget0=;"
"RenderDepthStencilTarget=;"
"Draw=Buffer;";
>
{
DepthTestEnable = false;
DepthMask = false;
BlendEnable = false;
CullFaceEnable = false;
DepthFunc = LEqual;
VertexProgram = compile vp30 VShader();
FragmentProgram = compile fp30 PShader();
}
}
After a few battles with the colour target, I finally got my scene to render, but the small preview of the depth target in FX Composer is completely white.
Any ideas?