Simple Cg question on depth buffer

Started by
1 comment, last by deadstar 15 years, 4 months ago
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?

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

Advertisement
I'm having the same problem with my depth textures in FX Composer. Anyone know what's causing this?
Quote:Original post by hatboyzero_zen
I'm having the same problem with my depth textures in FX Composer. Anyone know what's causing this?


Several weeks on and it's still giving me a headache. Shame the documentation for FX Composer and Cg in general is either non-existent or absolutely diabolical.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

This topic is closed to new replies.

Advertisement