Review of Tuesday We have learnt how to rasterize lines and fill polygons Colors (and other attributes) are specified at vertices Interpolation required to fill polygon with attributes 26
Review of Tuesday Mathematical formulation: Given (x i,f i ) ( positions and values ) Find function f defined on [x 0,x n ] such that f(x i )=f i We required our solutions to be linear functions 27
Interpolation: Linear Linear interpolation Parametric function takes the form f(u) =(1 u)f 0 + uf 1 Values between u 0 and u 1 are mixtures of f 0 and f 1 u =0.2 80%f 0 + 20%f 1 Control points are weighted/blended together 28
Interpolation: Linear Basis functions/blending functions/weights f(u) =(1 u)f 0 + uf 1 (1 u)+u =1 partition of unity weights sum up to one f(u) =b 0 (u) f 0 + b 1 (u) f 1 f(u) = i b i (u) f i control point contributions are blended together 29
What about colors? Linear interpolation (component-wise) f RGB (t) =(f R (t),f G (t),f B (t)) 30
What about colors? Linear interpolation across triangle Can we construct function as mixture of corner vertices? f(α 0,α 1,α 2 )=α 0 f 0 + α 1 f 1 + α 2 f 2 31
What about colors? Barycentric interpolation across triangle p = α 0 p 0 + α 1 p 1 + α 2 p 2 f(p) =α 0 f 0 + α 1 f 1 + α 2 f 2 Compute weights (barycentric coordinates) Interpolate values α 0 + α 1 + α 2 =1 0 α 0,α 1,α 2 1 convex combination 32
What about colors? 33
What about colors? Polygon interpolation is dependent on triangulation 34
How about patterns? Define color on more positions than just vertices? Map an image onto a mesh add details 35
Texture Mapping 2D texture coordinates (s,t) specified per vertex Interpolation of coordinates takes care of the rest 36
Texture Mapping and Rasterization How do we map texels to pixels? Aliasing Look up texel at pixel center (point sampling; nearest neighbor) Linear filtering (average texels around pixel center location) 37
Texture Mapping and Rasterization Magnification: texel maps to multiple pixels Minification: pixel maps to multiple texels CC-SA Wojciech Mula OpenGL demo in class 38
Texture Mapping and Rasterization Mip-Mapping: Create low resolution texture images for minification Similar to low-pass filtering before sampling Faster rendering Reduced aliasing 39
Texture Mapping Textures on curved 3D objects are distorted CC-SA Beuc 40
Triangles and Rasterization - Summary Summary: Vertices, lines, triangles are easily mapped to fragments Rasterization produces fragments from continuous primitives Fragments have interpolated attributes Color Texture coordinates Alpha Strong aliasing effects can be caused by sampling 41
General Object Representations So far we have described objects as (triangle) meshes Triangle meshes are piecewise linear object representations Easy to rasterize/ put on the screen Maps nicely to graphics pipeline What about other representation techniques? Disconnect rendering from object representation? Editing? Vector graphics? 42
General Object Representations Three ways to represent curves and surfaces Explicit y = f(x) Implicit f(x, y) =0 Parametric f(u) =(x(u),y(u),z(u)) 43
General Object Representations Explicit representation y = f(x) Independent variable defines value of dependent variable 44
General Object Representations Implicit representation f(x, y) =0 Points in space can be tested for membership In 2D these functions define curves, in 3D they define surfaces. 45
General Object Representations Parametric representation f(u) =(x(u),y(u),z(u)) Coordinates expressed in terms of one independent variable, the parameter. 46
Parametric Representation Set of control points Piecewise linear representation vs. higher-order parametric curves Linear representation Linear interpolation Bézier curve (cubic) Approximation 47
Bézier Curves Relaxing the interpolation condition allows for more stable curve construction (approximation) Goals: Easy construction Suitable for rendering and basic geometric operations Control over smoothness Stability Easy computation of derivatives 48
Bézier Curves Geometric construction of a cubic Bézier curve Four control points are weighted to construct a cubic Bézier curve. 49
Bézier Curves Bézier curve constructed by repeated linear interpolation f(u) = n b in (u)p i i=0 curve blends together control points cubic Bernstein basis polynomials b in (u) = n u i (1 u) n i i 50
Bézier Curves Convex hull property n b in (u) = u i (1 u) n i i n b in (u) =1 partition of unity 0 b in (u) 1 i=0 Bézier polynomial is convex combination of control points; stays Within convex hull of control polygon. 51
Bézier Curves Subdivision example: cubic Bézier curve p k i (u) =(1 u) p k 1 i 1 + u pk 1 i f(u) =p 3 3(u) cubic Bézier curve (p 0 0,p 1 1,p 2 2,p 3 3) (p 3 3,p 3 2,p 3 1,p 3 0) Cubic curve 1 Cubic curve 2 52
Bézier Curves Derivatives f(u) = n b in (u) p i i=0 Derivatives are tangents. Lighting computations require derivatives. Example: Utah Teapot consists of bicubic Bézier patches 53
Bézier Curves Derivatives f(u) = n b in (u) p i i=0 df (u) du = d du n b in (u) p i = i=0 n i=0 db in (u) du p i db in (u) du = n(b i 1,n 1 (u) b i,n 1 (u)) df (u) n du = n(b i 1,n 1 (u) b i,n 1 (u)) p i i=0 54
Bézier Curves Derivatives df (u) du = n i=0 n(b i 1,n 1 (u) b i,n 1 (u)) p i df (u) du n 1 = i=0 b i,n 1 (u) n(p i+1 p i ) Derivative is a Bézier curve of order (n-1) with combined control points 55
Bézier Curves Joining Bézier curves Discontinuous C 0 f continuous f discontinuous C 1 f continuous f continuous 56