Based on what I’ve read and the simple experiments I’ve been carrying out these last few days, it seems to me that the viewable range in Normalized Device Coordinates (NDC), this is, after perspective division is [-1,1] in all three dimensions. With left, bottom and front being -1, and 1 the rest.
This is easy to prove by drawing elements in GL without using any transformations. The only visible geometry is the one that is contained within these ranges, everything else won’t show up.
So going back to my question.
if we take some point in eye space, lets say conveniently:
P = (w/2, h/2, -n, 1.0)
We know by definition that this point should end up, after projection and perspective divide (NDC) as (1,1,-1)
Now, lets call the first matrix M1 (which doesn’t work) and the second M2 (which does work), and lets multiply them by the point P manually and see what happens:
M1P = [-n, -n, -n(f+n)/(f-n) + 2fn/(f-n), -n]
M2P = [n, n, -n(f+n)/(n-f) + 2fn/(n-f), n]
Now we do perspective divide and we have:
M1P/-n = [1,1,-1]
M2P/n = [1,1,-1]
The results are the same. And this will happen for any vector.
So my question again is why M2 works but M1 doesn’t?
I read that clipping is carried out in Clip coordinates, this is, before perspective division. Something is happening in that stage that is clipping the results of M1P but not M2P.
What is it? What is the exact logic behind the clipping in Clip space?
According to a computer graphics book I have (Watt)
The clipping operations must be performed on the homogeneous coordinates before the perspective divide, and translating the definition of the viewing frustum into homogeneous coordinates gives us the clipping limits
-w <= x <= w
-w <= y <= w
0 <= z <= w
I guess in GL context the range for z would be also:
-w <= z <= w
and I assume that that w would be the w coordinate of each individual vertex(?)
Anyone know what is the exact clipping algorithm?