Jump to content
  • Advertisement
Sign in to follow this  
michaelruecker

Difference between DepthStencilView and DepthStencilState?

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

Advertisement
View is for binding a fitting texture as a depth buffer to the device,
Depth stencil state is for setting the depth states (enable, write, ...) encapsualted in an immutable state object.

Share this post


Link to post
Share on other sites

So if one would not specify the state at all and just setting the view, depth testing would still work right?

 

Does it load some default settings then?

Edited by me_12

Share this post


Link to post
Share on other sites

Yes, setting the depth stencil state to NULL will enable the default settings. It disables stencil and has depth comparison set to less: Clear your depth stencil view to 1.0f and you're probably fine.

Edited by unbird

Share this post


Link to post
Share on other sites

Alright, so lets say the engine I am working with, is not using a depth stencil state yet. But I need to set that state now for my stuff. Afterwards I would like to set it to what it was before I changed it.

 

To do this I would just use OMSetDepthStencilState(NULL, 0) and set the state to NULL again? Or do I actually have to create another state that with default parameters and set that active?

 

Also what do you exactly mean with:

 

Clear your depth stencil view to 1.0f and you're probably fine.

 

Edited by me_12

Share this post


Link to post
Share on other sites
If said engine doesn't come up with some state saving of its own (or some reset functionality), you can grab any state with the corresponding Get function (in this case OMGetDepthStencilState (read the remarks: getter function usually AddRef() the object in question so don't forget to Release() when you reset it).

For your second question: When using a depth comparison of less (or less equal) it makes sense to start with a depth value at 1.0f (third parameter of ID3D11DeviceContext::ClearDepthStencilView). Depth buffer values go from 0 to 1 (inclusive) so 1 is the maximum. If your depth buffer is cleared to 0, and you use a less comparison, nothing gets drawn, since no value can be less than 0 wink.png.

But of course other stuff has to be setup properly, too, e.g. a sensible projection.

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!