Jump to content
  • Advertisement
Sign in to follow this  
furqantariq

Understanding Depth Testing

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

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



[background=rgb(192, 192, 192)]depthStencilDesc.DepthEnable = false;[/background]


[background=rgb(192, 192, 192)]depthStencilDesc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;[/background]


[background=rgb(192, 192, 192)]depthStencilDesc.DepthFunc = D3D10_COMPARISON_LESS;[/background]



Next, draw a box behind the wall with these depth settings:



[background=rgb(192, 192, 192)]depthStencilDesc.DepthEnable = true;[/background]


[background=rgb(192, 192, 192)]depthStencilDesc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;[/background]


[background=rgb(192, 192, 192)]depthStencilDesc.DepthFunc = D3D10_COMPARISON_LESS;[/background]



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



[indent=1]

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



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




I have modified correctly as mentioned but i am not getting expected result.



what i had expected was that In first case since Wall depthTest is false and it will not update depthBuffer, box will shown and


in second case box will be hide by wall because wall is closer to camera.


but in actual the in both cases wall is occluding the box. why is that?



(Please excuse my poor english)

Edited by furqantariq

Share this post


Link to post
Share on other sites
Advertisement

what i had expected was that In first case since Wall depthTest is false and it will not update depthBuffer



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
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!