Near clipping distance = 0

As we all know, perspective projection is undefined when n=0. However, one day I spent too much time tuning a near clipping distance, and I decided to work out what it would take to actually set n=0 without the whole system exploding. It can be done with a little GLSL. I’ve written an article on the result. How to Set the Near Clipping Distance to Zero

Some of you are gonna hate this, I know. :slight_smile: But there it is.

Interesting. Not sure why anyone would hate it, however, it would be interesting to compare such a solution to a regular solution where you just use depth clamping.

Well, I’m as committed to teaching good GL style as anyone. I find that beginning programmers often don’t understand the impact that moving the near and far planes has on depth buffer precision. They want to make n as small as possible and not worry about tuning n and f based on scene content.

So this code provides a way to get the effect of n=0, which is desirable to the lazy programmer, but it does so in a fashion that cannot be considered good GL style. That’s hateable to someone who deals with GL learners (as do these forums).

Also, the difference between this and depth clamping is that clamped values don’t sort.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.