OpenGL custom rendering pipeline: Perspective matrix
I am attempting to work in LWJGL to display a simple quad using my own
matrices. I've been looking around for awhile and have found a few
perspective matrix implementations, these two in particular:
[cot(fov/2)/a 0 0 0]
[0 cot(fov/2) 0 0]
[0 0 -f/(f-n) -1]
[0 0 -f*n/(f-n) 0]
and:
[cot(fov/2)/a 0 0 0]
[0 cot(fov/2) 0 0]
[0 0 -(f+n)/(f-n) -1]
[0 0 -(2*f*n)/(f-n) 0]
Both of these provide the same effect, as expected (got them from here and
here, respectively). The issue is in my understanding of how multiplying
this by the model matrix, then the view matrix, then a vertex, then
dividing each x, y, and z value by its w value gives a screen coordinate.
More specifically, if I multiply either of these by the modelview matrix
then by a vertex (10, 10, 0, 1), it gives a w=0. That in itself is a big
smack in the face. I conclude either the matrices are wrong, or I am
missing something completely. In my actual test program, the vertices
don't even end up on screen even though the camera position at (0,0,0) and
no rotation would make it so. I even have tried many different z values,
positive and negative, to see if it was just a clipping plane. Am I
missing something here?
No comments:
Post a Comment