# oblique near plane in projection matrix

Hello.
How could I adjust the projection matrix to project NDC point to the oblique near plane? Tom Tong

Well, you’re starting with what appears to be an on-axis frustum, and you’re going to flip to an off-axis frustum. So you’ll be calling glFrustum (or something like it) to explicitly specify L,R,B,T,N,F.

Ok, the point at which your L/R/B/T planes meet (if you extend them) is the eyepoint. The eyepoint doesn’t change in your picture as you want the same LRBT sides.

Given a near plane, draw a vector from the eyepoint normal to the near plane (as you have done). That vector is your eye-space -Z axis, and the distance is your near distance

Your far plane is parallel to the near plane, so chose similarly.

With your eyepoint/near/far planes oriented in EYE-SPACE (such that eyepoint is (0,0,0), near plane is Z=-near, far plane = Z=-far, +X=right, and +Y= up), The Left and Right glFrustum values are identified by the coordinates on the near plane at which you hit the left and right planes, respectively. Similarly for Top and Bottom.

I would like to do some thing like 3D pavement art on the computer screen.
The image will be shown in correct way only if I view the screen from specific angle.
What should I adjust on the projection matrix?

Tom Tong

[QUOTE=Tom Tong;1252064]I would like to do some thing like 3D pavement art on the computer screen.
The image will be shown in correct way only if I view the screen from specific angle.[/QUOTE]
You should set up the texture matrix as if for a camera located at the correct viewpoint, then use the vertex coordinates as texture coordinates. E.g.

``````
glMatrixMode(GL_TEXTURE);
glScalef(0.5, 0.5, 1);
glTranslatef(1, 1, 0);
gluPerspective(...);
gluLookAt(...);
glMatrixMode(GL_MODELVIEW);
glBegin(...);
glTexCoord3f(x0,y0,z0);
glVertex3f(x0,y0,z0);
glTexCoord3f(x1,y1,z1);
glVertex3f(x1,y1,z1);
...
glEnd();

``````

The behaviour of texture matrix is effectively the inverse of the projection and model-view matrices, so when the combination of model-view and texture matrices match the texture matrix, the two cancel out.

The glTranslate() and glScale() calls correct for the fact that normalised coordinates are -1 to +1 whereas texture coordinates are 0 to 1.