3D graphics rendering pipeline (1) Geometr Rasteriation 3D Coordinates & Transformations Prof. Aaron Lanterman (Based on slides b Prof. Hsien-Hsin Sean Lee) School of Electrical and Computer Engineering Georgia Institute of Technolog Geometr Pipeline Vertices Mainl floating-point operations Rasteriation Pipeline Piels Mainl dealing with Integer operations 3D graphics rendering pipeline () 3D graphics rendering pipeline (3) Geometr MMX ISA Rasteriation SSE/SSE ISA Geometr MMX ISA Rasteriation Geometr Pipeline Vertices Mainl floating-point operations Rasteriation Pipeline Piels Mainl dealing with Integer operations MMX was originall designed to accelerate this tpe of functionalit Geometr Pipeline Vertices Mainl floating-point operations SSE/SSE were designed for this part Rasteriation Pipeline Piels Mainl dealing with Integer operations MMX was originall designed to accelerate this tpe of functionalit 1
Fied-function 3D graphics pipeline 3D Coord: Math tetbooks use -up Geometr Performed b GPU Geometr Pipeline Vertices Mainl floating-point operations SSE/SSE were designed for this part Rasteriation Pipeline Piels Mainl dealing with Integer operations MMX was originall designed to accelerate this tpe of functionalit Rasteriation Z-up, Right-Handed Sstem 3D Coord: Real games tend to use -up X-Y natural for screen coordinates (awa from the viewer) (toward the viewer) Left-Handed Sstem Direct3D Unit3D Right-Handed Sstem OpenGL XNA Left-Handed Sstem Direct3D Unit3D Right-Handed Sstem OpenGL XNA
Some use Z-up for world coordinates Another view Left-Handed Sstem Right-Handed Sstem Z-up, LHS: Unreal Z-up, RHS: Quake/Radiant, Source/Hammer, C4 Engine Nearl everthing still uses Y-up for screen coordinates! Left-Handed Sstem Unreal Right-Handed Sstem Quake/Radiant Source/Hammer C4 Engine 3D object modeling software Geometr format verte coordinates +Y (X, Y, Z) +Z Right-Handed Sstem 3D Studio Ma, Blender Right-Handed Sstem Maa, Milkshape Y1 Z1 (X1, Y1, Z1) X1 (X3, Y3, Z3) +X 3
Geometr format verte normals +Y Geometr format verte colors +Y (NX, NY, NZ) (R, G, B, A) +Z +Z (NX3, NY3, NZ3) (R3, B3, B3, G3) (NX1, NY1, NZ1) (R1, G1, B1, A1) +X +X Triangle-based geometr representation Specifing a 3D object (1) V4 V7 V1 V5 V3 V6 V9 V V V4 V3 V5 V3 V4 V1 V5 V1 V7 V5 V6 Triangle list {v1, v3, v}, {v1, v5, v3}, {v5, v6, v3}, {v4, v3, v6}, {v1, v7, v6}, {v1, v6, v5} V8 Triangle List (note the verte order) V1 Triangle Strip V Triangle Fan V V3 V4 Triangle strip {v5, v3, v1, v}, {v5, v6, v3, v4}, {v7, v6, v1, v5} Verte ordering is critical when culling mode enabled We will discuss normal computation later 4
Specifing a 3D object () 3D rendering pipeline V1 V7 V8 V6 V4 Triangle list {v1, v, v7}, {v, v8, v7}, {v, v3, v4}, {v, v4, v8}, {v4, v7, v8}, {v4, v6, v7} Triangle strip {v1, v, v7, v8}, {v3, v4, v, v8}, {v6, v7, v4, v8} World Transform View Transform Lighting Projection Transform Backface Culling Clipping Perspective Divide Viewport Transform Rasteriation V V3 Verte ordering is critical when culling mode enabled We will discuss normal computation later Transformation pipeline World Transformation Model coordinates à World coordinates View Transformation World coordinates à Camera space Projection Transformation Camera space à View plane World transformation World Coordinates Local model coordinates Translation Rotation Scaling These are a series of matri multiplications World origin Local model coordinates 5
View transformation Projection transformation World Coordinates Set up camera internals Camera position Look vector Set up Field of View (FOV) View frustum View planes World origin Will discuss in the net lecture Homogeneous coordinates Transformation 1: translation (Offset) Enable all transformations to be done b multiplication Primaril for translation (see net few slides) ( t, t, t ) Add one coordinate (w) to a 3D vector Each verte has [,,, w] w will be useful for perspective projection (,, ) w should be 1 in a Cartesian coordinate sstem 6
Translation matri 1 [ t, t, t,1] = [,,,1] T 1 1 T T Transformation : scaling Eample of a row-coordinate convention Direct3D & XNA use row coordinates OpenGL uses column coordinates Scaling matri Transformation 3: rotation S [ s, s, s,1] = [,,,1] S S 7
D rotation (, ) (, ) θ ϕ (, ) cosθ sin θ [ ', ',1] = [,,1] sin θ cosθ Rotate along which ais? θ 3D rotation matri (LHS) Rotation along Z ais Rotation along Y ais Rotation along X ais cosθ sin θ [', ',',1] = [,,,1] cosθ = 1 [', ',',1] [,,,1] sinθ 1 [', ',',1] = [,,,1] cosθ sin θ sin θ cosθ 1 sinθ cosθ sin θ cosθ Non-commutative propert (1) 1. Counter-clockwise 9 o along. Clockwise 9 o along 1. Clockwise 9 o along. Counter-clockwise 9 o along Non-commutative propert () π cos( ) π sin( ) 1 π cos( ) π sin( ) π 1 sin( ) π cos( ) 1 π π cos( ) sin( ) (,, ) = (-, -, ) π sin( ) π cos( ) π cos( ) π sin( ) (,, ) = (-, -, ) π 1 sin( ) = π cos( ) 1 π sin( ) 1 1 π = cos( ) 1 1 1 8
Non-commutative propert (3) 1. Translation b (,, ). Scale b times 1. Scale b times. Translation b (,, ) Non-commutative propert (4) 1 T S 1 S 1 T T S = S ST S ST S ST (,, ) = (*S+S*T, *S+S*T, *S+S*T) Offsets were scaled as well S S 1 S T S 1 = S 1 T T T T S T (,, ) = (*S+T, *S+T, *S+T) Non-commutative propert (5) View transformation revisited Ordering matters! World Coordinates Be careful when performing matri multiplication World origin Camera position Look vector 9
Specifing the view transformation Most commonl parameteried b: Position of camera Position of point to look at Vector indicating up direction of camera In Direct3D: D3DXMatriLookAtLH! D3D uses a LHS, but also have D3DXMatriLookAtRH In XNA: Matri.CreateLookAt (RHS) In OpenGL: glulookat (RHS) Can also build a rotation+translation matri as if the camera was an object in scene, then take the inverse of that matri msdn.microsoft.com/en-us/librar/bb534(vs.85).asp msdn.microsoft.com/en-us/librar/bb5343(vs.85).asp 1