• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# How does depth bias work in DX10 ?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1jerrycao_1985  Members

Posted 25 August 2013 - 09:36 PM

Hi all

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.

### #2nonoptimalrobot  Members

Posted 26 August 2013 - 02:12 PM

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, 26 August 2013 - 02:46 PM.

### #3jerrycao_1985  Members

Posted 27 August 2013 - 12:07 AM

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 ?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.