Jump to content
  • Advertisement
Sign in to follow this  
mgoss

DX11 DX11 Depth RT issue

This topic is 2175 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

I'm having issues writing a depth RT correctly.

float4x4 ViewProjection;
struct VertexShaderOutput
{
float4 Position : SV_POSITION0;
float2 Depth : TEXCOORD0;
};
VertexShaderOutput VertexShaderFunction(float4 Position: POSITION)
{
VertexShaderOutput output;
float4 position = mul(Position, ViewProjection);
output.Position = position;
output.Depth = position.zw;
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : SV_TARGET0
{
float depth = input.Depth.x / input.Depth.y;
return float4(depth, depth * depth, 0, 0);
}
technique11 Depth
{
pass p0
{
SetVertexShader(CompileShader(vs_4_0, VertexShaderFunction()));
SetPixelShader(CompileShader(ps_4_0, PixelShaderFunction()));
}
}



o0Uqk.jpg

Share this post


Link to post
Share on other sites
Advertisement
You have a depth stencil view, why would you want to write it into a render target view? Just define a shader resource view for your depth stencil views resource.

Share this post


Link to post
Share on other sites
I can for a stand Depth map. However, when I want a custom depth like float4(depth, depth * depth, 1, 1)(variance shadows); I can't use that.

EDIT: Never mind, got it working. Edited by mgoss

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!