Jump to content
  • Advertisement
Sign in to follow this  
jerrycao_1985

How does depth bias work in DX10 ?

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

Hi all

 

I'm kind of confused by this article.

http://msdn.microsoft.com/en-us/library/windows/desktop/cc308048(v=vs.85).aspx

 

There is a formula in it :

Bias = (float)DepthBias * 2**(exponent(max z in primitive) - r) + SlopeScaledDepthBias * MaxDepthSlope;

 

First , what's ** after the number "2" ? Is it a typo ?

Second , about this part , exponent(max z in primitive) - r , could someone give me a more clear explanation ? It doesn't make any sense to me.

 

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

This funny looking quantity:

2**(exponent(max z in primitive) - r

doesn't contain a typo.  As far as I know the double star should be interpreted like so:

pow(2, (exponent(max z in primitive) - r)

The 'exponent' can also be rewritten more explicitly:

pow(2, (pow(e, max z in primitive) - r)

Where 'e' is the natural number 2.71828...

Personally, I think that formula should have been written like this:

2^(e^(MaxDepthInPrim) - r)

MaxDepthInPrim is the maximum depth value (in projection space so values on [0, 1]) of the current primitive being rendered.  If you are drawing a triangle with three vertices that have a depth value of 0.5, 0.75 and 0.25 the MaxDepthInPrim will be equal to 0.75. 

 

The constant 'r' is the number of mantissa bits used by the floating point representation of your depth buffer.  If you are using a float32 format then r = 23, if you are using a float16 format then r = 10 and if you are using a float64 format then r = 52.

 

I'm not entirely clear on the utility behind this formula.  If you play around with it a bit you can tell it's related (but not equal to) the distance between adjacent floating point values in your depth buffer.  The e^(MaxDepthInPrim) is just a way of doing a non linear interpolation across the deltas between adjacent values at different points in the depth buffer.

 

[EDIT] typed clip-space when I should have typed projection-space.

Edited by nonoptimalrobot

Share this post


Link to post
Share on other sites

It's weird.

 

1. The vertex with the maximum depth value in a primitive may be far away from the pixel to be shaded. It may be even outside the render target.

2. r is a integer , 23 , 10 or 52 , whatever. How does it relate to the maximum depth value in a primitive ?

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!