Pass only if current depth is 1.0

Started by
16 comments, last by Kryzon 13 years, 9 months ago
Hmm, I'm confused. Using .xyww causes horrible flickering in the sky. Using .xyzz just shows black. Using .z = .w = 1.0f, -1.0f, or any other constant value also seems to just show black (at least, the ones I've tried, though since z = w flickers, there are probably some values that produce this). Any ideas as to why this is?
Advertisement
Hm, sounds like FP imprecision in the perspective division causing far clipping. Set z to 0.999*w instead of exactly w.
Hmm, that seems to do the trick (the 0.999f makes me cringe, but oh well).

It seems strange though, that explicitly setting the same value for w and z would cause problems. If all vertices are set such that z = w and a/a == 1 for any a, then all values for z/w should be 1, and so interpolating z/w should just be 1 + (1 - 1)*d. So either a/a != 1 (where both occurrences of a have the same bits) or 1 - 1 != 0.

It's probably more complicated than this, it just surprises me that floating point imprecision would occur when you explicitly set values to be exactly equal.
Hmm, Remember, these are GPUs we're talking about, and are NOT necessarily compliant with IEEE 754. They prioritize speed over accuracy, and concentrate on the much more common case (in the graphics realm) of inequalities.

EDIT: Hmm

[Edited by - Sneftel on July 18, 2010 8:50:31 PM]
Hmm... I've used the vertPos = vertPos.xyzz trick quite a few times (on different platforms) and haven't had any problems.

What value are you clearing the depth buffer to, and what depth-test settings are you using?
Ah hah! OpenGL was defaulting to GL_LESS for its depth test function. I changed it to GL_LEQUAL and it works perfectly. Thanks everyone! (I still find it strange that it would flicker on GL_LESS rather than just be completely gone though. I guess that is because of what Sneftel said about GPUs though.)
May be at some point z = 0
If you return pos.xyzz; z / z != 1 because 0/0 != 1

And as said, GPUs may not be IEEE 754 compliant so who knows what happens when 0/0 is calculated. That could explain the flicker.

Anyway, good to know your problem is solved :)
Quote:- Or just make the sky shpere/box/drome very very large.
Does the size of objects have an impact on performance at all?
I know it does for the precision at least.

This topic is closed to new replies.

Advertisement