Graphics Pipeline 2D Geometric Transformations CS 4620 Lecture 8 1
Plane projection in drawing Albrecht Dürer 2
Plane projection in drawing source unknown 3
Rasterizing triangles Summary 1 evaluation of linear functions on pixel grid 2 functions defined by parameter values at vertices 3 using extra parameters to determine fragment set 4
Pixel-walk (Pineda) rasterization Conservatively visit a superset of the pixels you want Interpolate linear functions Use those functions to determine when to emit a fragment 5
The z buffer another example of a memory-intensive brute force approach that works and has become the standard [Foley et al.] 6
Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION FRAGMENTS blending, compositing, shading FRAGMENT PROCESSING FRAMEBUFFER IMAGE user sees this DISPLAY 7
8
Some demos http://mrdoob.github.io/three.js/examples/ http://carvisualizer.plus360degrees.com/threejs/ http://madebyevan.com/webgl-water/ http://akirodic.com/p/jellyfish/ 9
Pipeline of transformations Standard sequence of transforms object space camera space screen space modeling transformation camera transformation projection transformation viewport transformation world space canonical view volume 10
A little quick math background Notation for sets, functions, mappings Linear transformations Matrices Matrix-vector multiplication Matrix-matrix multiplication Geometry of curves in 2D Implicit representation Explicit representation 11
Implicit representations Equation to tell whether we are on the curve Example: line (orthogonal to u, distance k from 0) (u is a unit vector) Example: circle (center p, radius r) {v (v p) (v p) r 2 =0} Always define boundary of region (if f is continuous) 12
Explicit representations Also called parametric Equation to map domain into plane Example: line (containing p, parallel to u) Example: circle (center b, radius r) Like tracing out the path of a particle over time Variable t is the parameter 13
Transforming geometry Parametric representation: Implicit representation: 14
Translation Simplest transformation: Inverse: 15
Linear transformations One way to define a transformation is by matrix multiplication: Such transformations are linear, which is to say: (and in fact all linear transformations can be written this way) 16
Geometry of 2D linear trans. 2x2 matrices have simple geometric interpretations uniform scale non-uniform scale rotation shear reflection Reading off the matrix 17
Linear transformation gallery Uniform scale 18
Linear transformation gallery Nonuniform scale 19
Linear transformation gallery Reflection can consider it a special case of nonuniform scale 20
Linear transformation gallery Rotation apple 0.866 0.5 0.5 0.866 21
Linear transformation gallery Shear 22
Composing transformations Want to move an object, then move it some more We need to represent S o T ( S compose T ) and would like to use the same representation as for S and T Translation easy Translation by u T then by u S is translation by u T + u S commutative! 23
Composing transformations Linear transformations also straightforward Transforming first by M T then by M S is the same as transforming by M S M T only sometimes commutative e.g. rotations & uniform scales e.g. non-uniform scales w/o rotation Note M S M T, or S o T, is T first, then S 24
Combining linear with translation Need to use both in single framework Can represent arbitrary seq. as e. g. Transforming by M T and u T, then by M S and u S, is the same as transforming by M S M T and u S + M S u T This will work but is a little awkward 25
Homogeneous coordinates A trick for representing the foregoing more elegantly Extra component w for vectors, extra row/column for matrices for affine, can always keep w = 1 Represent linear transformations with dummy extra row and column 26
Homogeneous coordinates Represent translation using the extra column 27
Homogeneous coordinates Composition just works, by 3x3 matrix multiplication This is exactly the same as carrying around M and u but cleaner and generalizes in useful ways as we ll see later 28