Jump to content
  • Advertisement
Sign in to follow this  
deadstar

Simple Cg question on depth buffer

This topic is 3649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!