Skip to main content
GameDev.net gamedev.net
🔒 Locked

Depth bias clamping in opengl

Started by obhi Mar 2, 2011 at 12:30 PM 12 replies 11.3k views
Original Post
obhi
obhi
Anybody knows of any extension supporting depth bias clamping?
Since its already available in DX11 there should be an already existing extension in opengl 4.1 supporting this?

Thanks for any info.
-obhi
What if everyone had a restart button behind their head ;P
obhi
obhi

I don't know anything about direct X but can it be that u'R looking for polygon offset, it's an extension from OpenGL 1.0

http://www.opengl.or...lygonOffset.xml


I know polygon offset. But is there any way to clamp the depth bias it adds for sharp angles.

EDIT: I mean clamp/clip it to a max value? There is DepthBiasClamp setting in DX11 that can do that.

Thanks,
-obhi
What if everyone had a restart button behind their head ;P
V-man
V-man
DepthBiasClamp is a DX10 and 11 feature. It seems to be related to biasing the depth which is sort of what glPolygonOffset does. There is nothing about a "bias clamp" in glPolygonOffset.

There is the GL 1.0 function, glDepthRange, it does a remapping of normalized depth to window depth.
For example, if you want to kill fragments from 0.5 to 1.0, then you call
glDepthRange(0.0, 2.0)

and so 0.5 to 1.0 get mapped to 1.0 to 2.0 and thus get killed by the depth test.
karwosts
karwosts
Isn't this something that you could put in your pixel shader? glPolygonOffset is deprecated now anyway, unless I'm misunderstanding what this "depth bias" function in directx does. Sounds like you could implement whatever you want in the pixel shader.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Danny02
Danny02
sure, you can do what ever you want with the depth value in a shader, but then u loose early Z out.

On the other hand I heard that these depth manipulating functions are also not that fast.
V-man
V-man

Isn't this something that you could put in your pixel shader? glPolygonOffset is deprecated now anyway, unless I'm misunderstanding what this "depth bias" function in directx does. Sounds like you could implement whatever you want in the pixel shader.


Where does it say that glPolygonOffset is deprecated?
In a pixel shader? Nope, you can't duplicate what glPolygonOffset. Read the description at http://www.opengl.org/sdk/docs/man3/
karwosts
karwosts
Hm thats odd, I could have sworn I looked this up a month or two ago and found it deprecated, but now when I look it seems to not be deprecated. Must be going crazy
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
obhi
obhi

Hm thats odd, I could have sworn I looked this up a month or two ago and found it deprecated, but now when I look it seems to not be deprecated. Must be going crazy



DX11 and 10 are supporting depthbias clamping...as well as depth bias. So no point deprecating something as useful. But yes i found articles on shadow mapping which uses projection matrix tricks and avoids depth bias altogether. That is something nicer.

And here is what it does:

Bias = (float)DepthBias * r + SlopeScaledDepthBias * MaxDepthSlope;

if(DepthBiasClamp > 0)
Bias = min(DepthBiasClamp, Bias)
else if(DepthBiasClamp < 0)
Bias = max(DepthBiasClamp, Bias)

Further reference: http://msdn.microsoft.com/en-us/library/cc308048(v=vs.85).aspx
What if everyone had a restart button behind their head ;P
V-man
V-man
Shadow mapping? You probably are thinking of stencil shadows or planar stencil shadows.
obhi
obhi

Shadow mapping? You probably are thinking of stencil shadows or planar stencil shadows.



Ya..i meant stencil shadows! On the flip side.. i m not really concerned about shadows.. I was building a rendering pipeline (supporting DX and Opengl).. so I was deciding what to put in that so that both api can be fed data seamlessly. Right now i was looking into the stencil buffer settings so it came up.

Thanks for all replies.
obhi
What if everyone had a restart button behind their head ;P

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.