970 likes | 988 Views
Projection And Bounding Box culling. Tong-Yee Lee. Readings. Computer Graphics Using OpenGL by F.S Hill, J.R. Chapter 7. Perspective ( 透視投影 ) v.s. Orthographic ( 正投影 ) projection. Projection in standard CG pipeline. Image plane is Z = 0. Zs is lost , so it can not be used for
E N D
Projection And Bounding Box culling Tong-Yee Lee
Readings • Computer Graphics Using OpenGL by F.S Hill, J.R. • Chapter 7
Perspective(透視投影)v.s. Orthographic (正投影)projection
Image plane is Z = 0 Zs is lost , so it can not be used for Visible Surface Removal!!!
d (dx, dy,dz,0) d=(0,0,1,0) Note that projection vector d (dx, dy,dz,0) is specified from -Z toward Z in the eye space coordinate
What OpenGL wants is: • After projection, the image • space (after division) • become ……. • Left hand system • -1<=xs, ys, zs <=1 Regardless of parallel projection or perspective projection!!!
Parallel Projection in OpenGL glortho(l,r,b,t,n,f) -Z -Z Translate and Scale d=(0,0,1,0) l (x’, 0) r -1 +1 +X +X
Parallel Projection Matrix in OpenGL Image space in right hand system negate Z Image space in left hand system (OpenGL)
This row will not affect the projection!!! Only affect the Zs value! And substitute the following to solve A and B
Final Parallel Projection Matrix in OpenGL glOrtho(l,r,b,t,n,f) In parallel projection, w term also is 1.We do not need division!! So, we want this model!! Zs is good for Hidden Surface Removal !!! Zs is not lost Zs is lost
Object is distorted in screen space but the projection result is still same!!
(針孔成像模型) Generally, graphics is pinhole camera-like model! Lens (鏡頭)
i.e. same正切 tangent (tan)
OR Zs is lost again!! Remember this!!
We will introduce bounding box or sphere to accelerate culling test!!
(after division) In the image (screen) space coordinate (left hand system) In the eye space coordinate (right-hand system)
Object is distorted in screen space but the projection result is still same!!
Resulting image on the near plane 3D NDC to 2D Image (Near) Plane Chapter 14
fovxand fovy are assumed to be equal Note (1) X, Y, Z axis are named u,v,w in the following discussions!
Note that the representation of point transform is different from the previous one in the following discussions: For example: Old New
Good when we choose a canonical screen space volume or clipping volume Clipping Space Coordinate
In clipping coordinate space, we perform clipping. We can therefore save division if points are outside the frustum of clipping coordinate space We will teach clipping soon!
Something Interesting …Clipping What does it imply? Remember if a point is behind eye, we can not see it!!. i.e., w > 0, means it is behind eye. So, we can check the fourth item(before division). If the fourth item is negative, this point is behind the eye point.
We neglect scales at X and Y first and we Will compute them latter
the near plane (w = - n ) goes to the face w= -1of the image space cube , and the face defined by the far plane (w = - f ) goes to the face w = 1 of the image space cube. That’s (0,0,-n)P = (0,0,-1) (0,0,-f)P = (0,0,1) Note that in image space (after division)
We should also note that (1) the above P has transformed any point to image space (left hand system (n=-1, f = 1)). So, as Zs is larger, it means it is far away from camera. (2) Point in image space will not lost its Zs component!! Zs is lost
But, we want this term to be 1. So, after division, we get :
Before we apply projection, we scale X, Y ………….. Scale can help ……….
Re-organize our Representation !!!! Clipping space division Eye space fovx and fovy can be different!! Image (screen) space
-X -r -Z Z = - n eye r Furthermore ……………… gluFrustum (l, r, b, t, n, f) when r = - l , b = -t , we will have a symmetric frustrum