
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/(farClipnearClip) >>34: 1 >>43: ((screenWidth*2)/nearClip * (nearClip/(farClipnearClip))) >>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) Q=s/(1n/f) 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 depth1 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.
Harmless
