Three-Dimensional Viewing PPT6 - Intro to Computer Graphics Mehrad Eslami mehrad@mail.usf.edu EEL-5771-001
3D Viewing Concepts It is the field of computer graphics that deals with generating and displaying three dimensional objects in a two-dimensional space(eg: display screen) In addition to color and brightness, a 3-D pixels adds a depth property that indicates where the point lies on the imaginary z- axis. When many 3-D pixels are combined, each with its own depth value, the result is a 3-D surface called a texture. Objects are created on a 3-D stage where the current view is derived from the camera and light sources, similar to the real world.
3D Viewing Concepts
Three-Dimensional Display Methods Parallel projection Project points on the object surface along parallel lines onto the display plane. Parallel lines are still parallel after projection. Used in engineering and architectural drawings. Perspective projection Project points to the display plane along converging paths. This is the way that our eyes and a camera lens form images and so the displays are more realistic.
Three-Dimensional Display Methods Visible line and surface identification Highlight the visible lines or display them in different color Display nonvisible lines as dashed lines Remove the nonvisible lines Depth Cueing To easily identify the front and back of display objects. Depth information can be included using various methods. A simple method to vary the intensity of objects according to their distance from the viewing position. Eg: lines closest to the viewing position are displayed with the highest intensities and lines farther away are displayed with decreasing intensities.
Parallel projection By selecting different viewing positions, we can project visible points on the object onto the display plane to obtain different two-dimensional views of the object.
Perspective projection It has two major characteristics Smaller as their distance from the observer increases. Foreshortened: the size of an object’s dimension along the line of sight are relatively shorter than dimensions across the line of sight.
Visible Line and Surface
Depth Cueing Application is modeling the effect of the atmosphere on the pixel intensity of objects. More distant objects appear dimmer to us than nearer objects due to light scattering by dust particles, smoke etc.
Wire frame The wireframe model is perhaps the oldest way of representing solids. A wireframe model consists of two tables, the vertex table and the edge table. Each entry of the vertex table records a vertex and its coordinate values, while each entry of the edge table has two components giving the two incident vertices of that edge. A wireframe model does not have face information. For example, to represent a cube defined by eight vertices and 12 edges. Because of wireframe models are ambiguous, their uses are limited. However, wireframe models are popular, because they are efficient (i.e., only vertices and edges are displayed and processed) when they work. For example, wireframe models can be used for preview purpose. Rendering a complex model or an animation sequence could be very time consuming if all objects are to be rendered. If wireframe models (usually including its face information) are available, one can easily obtain a general feeling of the final result without waiting for minutes or even hours before spotting a design flaw.
Wire frame 16 vertices and 32 edges on the right 8 vertices and 12 edges on the left
Projection Coordinates 3D Viewing Pipeline Process Construct World-Coordinate Scene From Modeling-Coordinate Transformations World Coordinates Modeling Coordinates Convert World- Coordinates to Viewing- Coordinates Coordinates Viewing Projection Transformation Projection Coordinates Transform Projection-Coordinates to Normalized-Coordinates Normalized Coordinates Map Normalized- Coordinates to Device-Coordinates Device Coordinates
3D Viewing pipeline Pipeline has +/ same structure as in 2D Similar to making a photo Position and point virtuele camera, press button; Projection plane aka Viewing plane Pipeline has +/ same structure as in 2D
3D viewing coordinates P0, Pref , V: define viewing coordinate system zvp Specification of projection: P0 : View or eye point Pref : Center or look-at point V: View-up vector (projection along vertical axis) zvp : positie view plane yw P0 N V Pref xw zw P0, Pref , V: define viewing coordinate system Several variants possible
3D viewing coordinates P0, Pref , V: define viewing coordinate system xview yview zview yw P0 N V Pref xw zw P0, Pref , V: define viewing coordinate system Several variants possible
3D view coordinates n xview yview u v yw zview P0 N V Pref xw zw
3D view coordinates xview yview u v zview yw n P0 N V Pref xw zw
Octagonal projections Orthogonal projection is a means of representing a three- dimensional object in two dimensions. It is a form of parallel projection, where all the projection lines are orthogonal to the projection plane, resulting in every plane of the scene appearing in affine transformation on the viewing surface. It is further divided into multiview orthographic projections and axonometric projections. In computer graphics, one of the most common matrices used for orthographic projection can be defined by a 6-tuple, which defines the clipping planes. We’ll see in next slides how a orthogonal works in term of projecting 3D to 2D.
Orthogonal projections The box is translated so that its center is at the origin, then it is scaled to the unit cube which is defined by having a minimum corner at (-1,-1,-1) and a maximum corner at (1,1,1). The orthographic transform can be given by the following matrix:
Orthogonal projections Which can be given as a scaling followed by a translation of the form The inversion of the Projection Matrix, which can be used as the Unprojection Matrix is defined:
Orthogonal projections Parallell projection: Projection lines are parallel Orthogonal projection: Projection lines are parallel and perpendicular to projection plane Isometric projection: Projection lines are parallel, perpendicular to projection plane, and have the same angle with axes. P’2 P1 P’1 P2 P1 P’2 P’1 z x y
Orthogonal projections
Orthogonal projections View volume Clipping window yview Near plane Far plane xview zview
Orthogonal projections (xwmax, ywmax, zfar) View volume yview xview zview (xwmin, ywmin, znear)
Orthogonal projections (xwmax, ywmax, zfar) znorm xnorm ynorm Normalized View volume (1,1,1) (-1,-1,-1) yview xview zview (xwmin, ywmin, znear) View volume Translation Scaling From right- to left handed
Parallel Projection Point (x,y,z) is projected to position (xp,yp) on the view plane. Projector (oblique) from (x,y,z) to (xp,yp) makes an angle with the line (L) on the projection plane that joins (xp,yp) and (x,y). Line L is at an angle with the horizontal direction in the projection plane.
Parallel Projection
Parallel Projection Orthographic Projection:
Transformation When the human eye views a scene, objects in the distance appear smaller than objects close by - this is known as perspective. While orthographic projection ignores this effect to allow accurate measurements, perspective projection shows distant objects as smaller to provide additional realism. The standard way to represent 2D/3D transformations nowadays is by using homogeneous coordinates. [x,y,w] for 2D, and [x,y,z,w] for 3D. Since we have three axes in 3D as well as translation, that information fits perfectly in a 4x4 transformation matrix.
Transformation Transform your 3D points with the inverse camera matrix, followed with whatever transformations they need. If you have surface normal, transform them as well but with w set to zero, as you don't want to translate normal. The matrix you transform normal with must be isotropic; scaling and shearing makes the normal malformed. Transform the point with a clip space matrix. This matrix scales x and y with the field-of-view and aspect ratio, scales z by the near and far clipping planes, and plugs the 'old' z into w. After the transformation, you should divide x, y and z by w. This is called the perspective divide.
Transformation Now your vertices are in clip space, and you want to perform clipping so you don't render any pixels outside the viewport bounds. Sutherland-Hodgeman clipping is the most widespread clipping algorithm in use. Transform x and y with respect to w and the half-width and half-height. Your x and y coordinates are now in viewport coordinates. w is discarded, but 1/w and z is usually saved because 1/w is required to do perspective-correct interpolation across the polygon surface, and z is stored in the z-buffer and used for depth testing.
Perspective projection View plane: z = zvp P2 P’2 P1 Projection reference point P’1 yview xview zview View plane: orthogonal to zview axis.
Perspective projection View plane: z = zvp P = (x, y, z) R: Projection reference point (xp, yp, zp) (xr, yr, zr) yview To simplify, Assume R in origin xview zview Question: What is the projection of P on the view plane?
Perspective projection View plane: z = zvp P = (x, y, z) yview (xp, yp, zp) xview zview R= (0,0, 0)
Perspective projection P = (x, y, z) View plane yview y zvp yp R zview z Viewed from the side
Perspective projection Clipping window in View plane Ratio between W=wmaxwmin and zvp determines strenght perspective P = (x, y, z) wmax yview R zview W zvp wmin Viewed from the side
Perspective projection Clipping window in View plane Ratio between W=wmaxwmin and zvp determines strenght perspective. This ratio is 2tan(/2), with the view angle. yview R zview Viewed from the side
Perspective projection yview R zview
Perspective projection yview R zview
Perspective projection
Perspective projection Option 1: Specify view angle . yview R zview W zvp How to specify the ratio between W en zvp? How to specify ‘how much’ perspective I want to see?
Perspective projection yview f (mm) 24 mm R zview W zvp Use camera as metaphor. User specifies focal length f . (20 mm – wide angle, 50 mm – normal, 100 mm – tele). Application adjusts W and/or zvp, such that W/zvp = 24/f. For x: W/zvp = 36/f.
Perspective projection ynorm yview Side view Front view znorm R zview Perspective transformation: Distort space, such that perpendicular projection gives an image in perspective.
Perspective projection ynorm yview znorm 2r R zview zn zf Simplest case: Square window, clipping plane coincides with view plane: zn=zvp
Perspective projection (-r, -r, zn) ((zf /zn)r, (zf /zn)r, zf ) ynorm (-1,-1,-1) (1,1,1) yview znorm 2r R zview zn zf
Perspective projection (r, r, zn) (rzf /zn, rzf /zn, zf ) ynorm (1, 1, 1) (1,1,1) yview znorm R zview Earlier: How to put this transformation in the pipeline? How to process division by z?
Perspective projection (r, r, zn) (rzf /zn, rzf /zn, zf ) (1, 1, 1) (1,1,1) ynorm yview znorm R zview
Perspective projection (r, r, zn) (rzf /zn, rzf /zn, zf ) (1, 1, 1) (1,1,1) ynorm yview znorm R zview
Perspective projection
View volume perspective Clipping window yview xview Far clipping plane zview R Near clipping plane
Normalizing view volume (1,1,1) zview xview yview R ynorm znorm xnorm (1, 1, 1) Normalized View volume Rectangular frustum View Volume
Normalized view volume Normalize Matrix Normalizing formula Dx= Dy= Dz= Kx= Ky= Kz=
References Chen, Jim X. "Foundations of 3D Graphics Programming - Using JOGL and Java3D | Jim X. Chen | Springer.” Foundations of 3D Graphics Programming - Using JOGL and Java3D | Jim X. Chen | Springer. Springer, n.d. Web. 06 Oct. 2015. Wijk, Jack Van. "2IV60 Computer Graphics 2014/2015.” 2IV60 Computer Graphics. N.p., n.d. Web. 06 Oct. 2015. Younesi, and Malaek, Dr. "Three Diminutionals Viewing." N.p., n.d. Web. Luebke, David. "UVA Computer Graphics: Courses.”UVA Computer Graphics: Courses. N.p., n.d. Web. 06 Oct. 2006. Wimer, Shmuel. "Computer Graphics Viewing." N.p., May 2010. Web. "3D Computer Graphics.” Wikipedia. Wikimedia Foundation, n.d. Web. 06 Oct. 2015. "Computer Graphics.” Wikipedia. Wikimedia Foundation, n.d. Web. 06 Oct. 2015. Sung, K., P. Shirley, and S. Baer. "Essentials of Interactive Computer Graphics Concepts and Implementation." N.p., n.d. Web. 06 Oct. 2015. *some pictures and formulas have copied from the references
Thank You