# Infinite projection matrix (Pinf) -> Trouble!

Hello.
I am trying implent stencil shadows in my program and I need the Pinf-matrix badly.
The problem though, is that I can’t get it working in any reasonable way. (That means that I cannot see anything)
I hope you can find some error in my code thanks a lot!

float Near = 2.0;
double tangent = tan(Config.ScreenFOV / 2.0);
float y = tangent * Near;
float x = (3 / 4) * y;

float right = x;
float left = -x;
float bottom = -y;
float top = y;

float Pinf;
const float NUDGE = 0.9999f;

// zero out the matrix
Pinf = Pinf = Pinf = Pinf = 0.f;
Pinf = Pinf = Pinf = Pinf = 0.f;
Pinf = Pinf = Pinf = Pinf = 0.f;
Pinf = Pinf = Pinf = Pinf = 0.f;

// create view matrix with infinite far plane
Pinf = 2.0 * Near / (right - left);
Pinf = 2.0 * Near / (top - bottom);
Pinf = -2.f * Near;
Pinf = NUDGE * -1.f;
Pinf = -1.f;
Pinf = Near * NUDGE * -2.f;
Pinf = (right + left) / (right - left);
Pinf = (top + bottom) / (top - bottom);

glMatrixMode(GL_MODELVIEW);
gluLookAt(ViewMat,ViewMat, ViewMat,
ViewMat + ViewMat,
ViewMat + ViewMat,
ViewMat + ViewMat,
ViewMat, ViewMat, ViewMat);

Thanks for the help!

Well, I managed to put the code in a place where it actually seems to do some good.

I do get correct shadows in more cases now, but it still isn’t quite right.
There is a chance that an other part of my shadow-code is wrong. But please have a look on the above code (Pinf related only) and see if you can find any thing.

BTW it is: float x = ((float)4 / 3) * y;

EDIT:
Yeah! I just found another stupid error!
When dealing with shadow-volumes I calculated the backfaces relative to the camera instead of the light. It works so (!) much better now.
Ah, that’s a good feeling [This message has been edited by B_old (edited 04-07-2003).]

Always good to read the last response in a thread like this first. 