Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / projection matrix Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Jaap Suter

March 12, 1999, 02:19 PM

Exactly what points in the projectionMatrix need to have what values? I thought i had it but
something is wrong:

I thought:

11: screenHeight*2/nearClip
22: screenWidth*2/nearClip
33: nearClip/(farClip-nearClip)
34: 1
43: -((screenWidth*2)/nearClip * (nearClip/(farClip-nearClip)))
and the rest zero?

My projection is so damn weird?

What are usual values for near and far clipping plane:
Currently i use: 10 for near and 1000 for far?


Jaap Suter


April 06, 1999, 01:38 AM

Jaap Suter wrote:
>>Exactly what points in the projectionMatrix need to have what values? I thought i had it but
>>something is wrong:
>>11: screenHeight*2/nearClip
>>22: screenWidth*2/nearClip
>>33: nearClip/(farClip-nearClip)
>>34: 1
>>43: -((screenWidth*2)/nearClip * (nearClip/(farClip-nearClip)))
>>and the rest zero?

My preferred perspective matrix is taken directly from Jim Blinn's Corner: A Trip down the Graphics Pipeline (which is a reprinting of an earlier article)

c 0 0 0
0 c 0 0
0 0 Q s
0 0 -Qn 0

s = sin(fov/2)
c = cos(fov/2)
n = distance to near plane
f = distance to far plane

then the projection from perspective space to a fullscreen window requires you to simply rescale
which would be something like:

11: width/2
22: height/2
33: depth or depth-1
41: -width/2
42: -height/2
43: 0 or -1

the two options on 33 and 43 are for the two cases where your hardware or zbuffer algorithm allows you 0 or not.

The above assumes you have a visual volume of:

x=-w < x < w
y=-w < y < w
z= 0 < z < w

are using a premultiplication based matrix set and a left handed coordinate system, if not shuffle signs and transpose things until it works.

>>What are usual values for near and far clipping plane:

The values vary from application to application, but in general you want to push your near clipping plane as far away from you as possible for the scene to improve the effectiveness of the zbuffer. The above mentioned perspective matrix would allow you a near plane of 0 of you HAD to have it, but it costs you too much resolution in your zbuffer and zbuffer artifacts start to crop up if you move your near plane too close to the camera.


This thread contains 2 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.