Introduction Computer Graphics Instructor: Yung-Yu Chuang ( 莊 永 裕 ) E-mail: c@csie.ntu.edu.tw Office: CSIE 527 Grading: a MatchMove project Computer Science ce & Information o Technolog og Yung-Yu Chuang What is computer graphics? Definition the pictorial i snthesis of real or imaginar i objects from their computer-based models Computer graphics Create a 2D image/animation of a 3D world OUTPUT descriptions images I PUT descriptions Computer Graphics images Computer Vision Image Processing
Applications Movies Interactive entertainment Industrial design Architecture Culture heritage Computer graphics modeling rendering animation Modeling A simple example (0,0) (.5,0) # vertices 00 0.0, 00 0.0, 00 0.0.5, 0.0, 0.0 00 0.0, 5.5, 00 0.0.5,.5, 0.0 (0,.5) (.5,.5) z x # triangles 0, 2,, 2, 3
The power of triangles More complex examples Ever thing can be represented b triangles to a degree of precision. 20 triangles 80 triangles 320 triangles a real buddha 4K mesh rendered 2.4M mesh Modeling Triangle meshes The position of the model can be acquired b 3D scanner or made b artists using modeling tools. There are other was for representing geometric objects, but triangles have man advantages. Copright 998, Microsoft {f } : { v, v 2, v 3 } {f 2 } : { v 3, v 2, v 4 } {v } : (x,,z) {v 2 } : (x,,z) {f } : skin material {f 2 }: brown hair {v 2,f }:(n x,n,n z )(uv) (u,v) {v 2,f 2 } : (n x,n,n z ) (u,v) connectivit geometr face attributes corner attributes
Composition of a scene Graphics pipeline z x z x Representation Transformations
Representation 2D transformations Identit Scaling
Scaling Reflection Shearing Rotation
Limitations of a 2X2 matrix Homogeneous coordinate Scaling Rotation Reflection Shearing What do we miss? Translation 3D scaling
3D translation 3D rotation 3D shearing Graphics pipeline
Imaging with the snthetic camera Projections Specifing a viewer Projections
Parallel and perspective projections Orthographic transformation orthographic perspective Perspective projection Perspective transform
Triangle meshes Graphics pipeline review Copright 998, Microsoft {f } : { v, v 2, v 3 } {f 2 } : { v 3, v 2, v 4 } {v } : (x,,z) {v 2 } : (x,,z) {f } : skin material {f 2 }: brown hair {v 2,f }:(n x,n,n z )(uv) (u,v) {v 2,f 2 } : (n x,n,n z ) (u,v) connectivit geometr face attributes corner attributes Review of graphics pipeline Transformation Review of graphics pipeline Projection & clipping
Review of graphics pipeline Rasterization Visibilit ibili Visibilit (Hidden surface removal) Hidden surface removal Determining what to render at each pixel. A point is visible ibl if there exists a direct line-ofsight to it, unobstructed b another other objects (visible iibl surface determination). ti ) Moreover, some objects ma be invisible because there are behind the camera, outside of the field-of-view, too far awa (clipping) or back faced (backface culling). Hidden surfaces: wh care? Occlusion: Closer (opaque) objects along same viewing ra obscure more distant ones Reasons for removal Efficienc: i As with clipping, avoid wasting work on invisible objects Correctness: The image will look wrong if we don t model occlusion properl
Hidden surface removal algorithms Painter s algorithm Binar space partitioning Z-buffer Ra casting And man others Painter s algorithm Draw primitives from back to front to avoid need for depth comparisons from Shirle Painter s algorithm Idea: Sort primitives b minimum depth, then rasterize from furthest to nearest When there are depth overlaps, do more tests of bounding areas, etc. to see one actuall occludes the other Cclical overlaps are a problem Z-buffer algorithm Resolve depths at the pixel level Idea: add Z to frame buffer, when a pixel is drawn, check whether it is closer than what s alread in the framebuffer Proposed b Ed Catmull in 975, widel used toda, especiall in hardware. Z-buffer, texture, subdivsion surface, RenderMan Co-founder of Pixar 3 Oscars (993, 996, 200), SIGGRAPH Steven Coons Award (993)
Z-buffer algorithm Z-buffer algorithm The z-buffer Algorithm Z-buffer: example + = + = color buffer depth buffer
Z-Buffer Clipping (view frustum culling) Benefits Eas to implement Works for an geometric primitive Parallel l operation in hardware (independent d of order of polgon drawn) Limitationsit ti Memor required for depth buffer Quantization and aliasing artifacts Overfill Transparenc does not work well Review of graphics pipeline Rasterization Visibilit ibili Review of graphics pipeline Shading
Z-buffer algorithm Shading What is normal? ormal for a triangle n plane n (p - v 0 ) = 0 v 2 n = (v 2 - v 0 ) (v( - v 0 ) normalize n n/ n v 0 p v ote that tright-hand h rule determines outward dface
Using average normals Using average normals = true (geometric) normal 2 Using average normals 2 2 2 Using average normals 2 3 4 2 3 4 More generall, n i i 2 n 4 i i 3 It can also be area-weighted.
Triangle meshes Copright 998, Microsoft {f } : { v, v 2, v 3 } {f 2 } : { v 3, v 2, v 4 } {v } : (x,,z) {v 2 } : (x,,z) {f } : skin material {f 2 }: brown hair {v 2,f }:(n x,n,n z )(uv) (u,v) {v 2,f 2 } : (n x,n,n z ) (u,v) connectivit geometr face attributes corner attributes Illumination (shading) models Interaction between light sources and objects in scene that results in perception of intensit and color at ee Local vs. global models Local: perception of a particular primitive onl depends on light sources directl affecting that one primitive Geometr Material properties Shadows cast (global?) Global: also take into account indirect effects on light of other objects in the scene Light reflected/refracted Indirect lighting Local vs. global models Setup vl ve Direct lighting Indirect lighting Point P on a surface through a pixel p ormal at P Lighting direction vll Viewing direction ve Compute color L for pixel p
Surface tpes The smoother a surface, the more reflected light is concentrated in the direction a perfect mirror would reflected the light A ver rough surface scatters light in all directions Basics of local shading Diffuse reflection light goes everwhere; colored b object color Specular reflection happens onl near mirror configuration; usuall white Ambient reflection constant accounted for other source of illumination smooth surface rough surface Ambient shading add constant color to account for disregarded illumination and fill in black shadows; a cheap hack. ambient light Diffuse shading Assume light reflects equall in all directions Therefore surface looks same color from all views; view independent
Diffuse shading Illumination on an oblique surface is less than on a normal one (Lambertian cosine law) Diffuse shading (Gouraud 97) Applies to diffuse, Lambertian or matte surfaces Generall, illumination falls off as cosθ (albedo) Diffuse shading Diffuse shading For color objects, appl the formula for each color channel separatel 0.4 0.55 0.7 0.85.0 diffuse-reflection model with different k d 0.0 0.5 0.3 0.45 0.6 ambient and diffuse-reflection model with different and Ia Ip.0, kd 0. 4 k a
Specular shading Some surfaces have highlights, mirror like reflection; view direction dependent; especiall for smooth shinn surfaces Specular shading (Phong 975) Also known as gloss, rough specular and directional diffuse reflection Specular shading Fall off graduall from the perfect reflection direction Specular shading Increasing n narrows the lobe n cos 90 n=0 n=3 n= n=2 0 90
Specular shading Specular shading k s 0. 0.25 0.5 n 3.0 n 5. 0 n 0. 0 n 27. 0 n 200. 0 diffuse diffuse + specular Put it all together Choosing the parameters Include ambient, diffuse and specular Sum over man lights
Computing lighting at each pixel Most accurate approach: Compute component illumination at each pixel with individual positions, light directions, and viewing directions But this could be expensive... s I p Scan line Shading models for polgons Flat Shading Faceted Shading Constant Shading Gouraud Shading Intensit Interpolation Shading Color Interpolation Shading Phong Shading ormal-vector Interpolation Shading 2 3 Flat Shading Intensit Interpolation (Gouraud) Compute constant shading function, over each polgon Same normal and light vector across whole polgon Constant shading for polgon I p I I s I I a b I I s 2 2 I I 2 s s 3 s 3 3 3 2 I a I I b s I 2 I p I 3 I p x x x b p p a Ia Ib 2 xb xa xb xa x I I p I 3
ormal Interpolation (Phong) 2 s s 2 2 2 2 s s a a b s 3 3 3 3 s s b 2 s 3 3 2 3 p ormal Interpolation (Phong) a p b p b x x x x ~ a b a p b b a b p b a a p x x x x ~ p p ~ ormalizing makes thi it t p this a unit vector Gouraud v.s. Phong Shading Gouraud Phong Gouraud Phong Flat shading
Gouraud shading Phong shading Triangle meshes Graphics Pipeline Copright 998, Microsoft {f } : { v, v 2, v 3 } {f 2 } : { v 3, v 2, v 4 } {v } : (x,,z) {v 2 } : (x,,z) {f } : skin material {f 2 }: brown hair {v 2,f }:(n x,n,n z )(uv) (u,v) {v 2,f 2 } : (n x,n,n z ) (u,v) connectivit geometr face attributes corner attributes
Review of graphics pipeline Transformation Review of graphics pipeline Projection & clipping Review of graphics pipeline Rasterization Visibilit ibili Review of graphics pipeline Shading
Hierarchical modeling: a robot arm Animation Hierarchical modeling Animator demos
Videos TigerWang Racing Advanced topics Global illumination Complex materials
Realistic motion Graphics hardware vidia GT200 GPU 200 cores Animation production pipeline Animation production stor text t treatmentt t storboard voice storreal look and feel
Animation production pipeline modeling/articulation l laout animation What s next? shading/lighting rendering final touch Related courses Related courses