Ah, that makes perfect sense, why didn’t I think of that?
*Edit: I still have some clipping issues, but I suspect this is due floating point inaccuracies as I move the skybox in the world to the eye position, instead of moving the eye position to the origin.
Are there alternatives that guarantee the fragment will pass when z==1.0 (per fragment rather than vertex level)?
I think it would even be possible to set glDepthRange(1, 1), so the resulting fragment depth will always be 1 but you propably still would get the problems due to clipping as clipping is applied before the depth range. So depth range is practically useless.
If you set z = w you basically put the point directly on the far clipping plane. Theroretically this should be ok but as you say you still get errors. You could make z a tiny bit smaller though.
An alternative would be to use a perspective transform which sets the far clipping plane to infinity and this would avoid the whole problem altogether.
Yes, glDepthRange(1,1) doesn’t work for me, the entire skybox is clipped. According to an old ATI paper this should work, but I heard it no longer behaves reliably on the latest drivers.
An alternative would be to use a perspective transform which sets the far clipping plane to infinity and this would avoid the whole problem altogether.
Does that work? Don’t things get clamped or clipped one way or another?
[quote]An alternative would be to use a perspective transform which sets the far clipping plane to infinity and this would avoid the whole problem altogether.
Does that work? Don’t things get clamped or clipped one way or another?[/QUOTE]Yes, this should work as it is also needed for correct stencil shadows. Take a look at The Mechanics of Robust Stencil Shadows or Projection Matrix Tricks .