PDA

View Full Version : PolygonOffset state and the depth test



DmitryM
04-17-2012, 08:02 AM
Is PolygonOffset applied when the depth test is off?

It is not obvious to figure out the answer by reading the spec (ES 2.0 section 3.5.2). On one hand, the spec doesn't mention the need for a depth test, and the polygon offset is described separately from the fragment processing stages. On the other hand, it says:

... units scales an implementation-dependent constant that relates to the usable resolution of the depth buffer.
And later on:

It is the smallest difference in window coordinate z values that is guaranteed to remain distinct throughout polygon rasterization and in the depth buffer.
Hence, the question rises: what if we don't have a depth buffer attached? Or, in particular, we just disabled it by setting the depth test to OFF? It's not only the issue of how the offset is computed in this case, but also - it's difficult to imagine a use-case for it.

ZbuffeR
04-17-2012, 09:42 AM
Depth test being off does not mean the depth *buffer* does not exists, so I would guess it should work.

If no depth buffer is attached, however... no clue.

dukey
04-17-2012, 09:59 AM
if you need polygon offset you are probably .. doing it wrong. It works but you'll never get consistent results across different hardware. That's my experience anyway.

DmitryM
04-17-2012, 10:15 AM
Thanks for your answers.

If no depth buffer is attached, however... no clue.
Does it look like a bug in a spec for you? The question wouldn't exist if they put a line like "The unit offset is zero if no depth buffer is attached."


if you need polygon offset you are probably .. doing it wrong.
It's not that I need polygon offset for something, it's that I need to provide the functionality to use it. Hence, my internal dillema was: whether I need the user to pass polygon offset parameters in a context of the depth test settings, or regardless of that.