Render to Far Plane (gl_Position.z = 1)


this is a basic question but requires some in depth knowledge that I am missing.

I want to render a texture on the far plane, that is gl_Position.z = 1 & gl_Position.w = 1. Hard Coded and without Matrices.

It appears that GL clips including the far plane.

Can I modify the clipping comparison?
Is there a standard way to place geometry on the far plane?

The largest possible depth value appears to be: 0.99999991059303297

Interestingly, the largest value provided by <math.h> and nextafter(1.0f, 0.0f) is 0.99999994039535522

I would have thought that the precision would be the same by now, can anyone elaborate on this? Or point to some documentation.

Best Regards.

Are you rendering said texture first?

If you are, you can clear the depth buffer, disable depth test & write, render it at an arbitrary distance (e.g. 0), and re-enable depth test & write. That’ll give you an image on the far plane.

I think you can also use glDepthFunc() to change comparison function; however, its a bit slower than DarkUranium’s method.