# 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.

## 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.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.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.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 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 on other sites
Now i got it. Thank you very much.

##### 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.