Sign in to follow this  

Understanding Depth Testing

This topic is 2012 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 reading 'introduction to D3D10' by Frank Luna. I have problem in solving first exercise of ninth chapter 'stenciling', which is following

[left]Modify the Mirror demo in the following way. First draw a wall with the following depth settings:[/left]

[left][background=rgb(192, 192, 192)]depthStencilDesc.DepthEnable = false;[/background][/left]
[left][background=rgb(192, 192, 192)]depthStencilDesc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;[/background][/left]
[left][background=rgb(192, 192, 192)]depthStencilDesc.DepthFunc = D3D10_COMPARISON_LESS;[/background][/left]

[left]Next, draw a box behind the wall with these depth settings:[/left]

[left][background=rgb(192, 192, 192)]depthStencilDesc.DepthEnable = true;[/background][/left]
[left][background=rgb(192, 192, 192)]depthStencilDesc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;[/background][/left]
[left][background=rgb(192, 192, 192)]depthStencilDesc.DepthFunc = D3D10_COMPARISON_LESS;[/background][/left]

[left]Does the wall occlude the box? Explain. What happens if you use the following to draw the wall instead?[/left]

[indent=1][size=4][background=rgb(192, 192, 192)][color=#000000]depthStencilDesc.DepthEnable = true;
depthStencilDesc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;
depthStencilDesc.DepthFunc = D3D10_COMPARISON_LESS;[/color][/background][/size][/indent]

[left]Note that this exercise does not use the stencil buffer, so that should be disabled.[/left]


[left]I have modified correctly as mentioned but i am not getting expected result.[/left]

[left]what i had expected was that In first case since Wall depthTest is false and it will not update depthBuffer, box will shown and[/left]
[left]in second case box will be hide by wall because wall is closer to camera.[/left]
[left]but in actual the in both cases wall is occluding the box. why is that?[/left]

[left](Please excuse my poor english)[/left] Edited by furqantariq

Share this post


Link to post
Share on other sites
[quote name='furqantariq' timestamp='1342198691' post='4958842']
[left]what i had expected was that In first case since Wall depthTest is false and it will not update depthBuffer[/quote][/left]

This is incorrect. DepthEnable only controls whether depth testing is enabled, it doesn't affect depth writes. If you want to disable depth writes, you need to specify D3D10_DEPTH_WRITE_MASK_ZERO for DepthWriteMask.

Share this post


Link to post
Share on other sites

This topic is 2012 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this