COMP250: Computer Graphics Jérôme Waldispühl School of Computer Science McGill University Slides assembled from M. BlancheGe (McGill), T. Thorne (U. of Edinburgh)
Slide by M. BlancheGe (McGill) Computer Graphics Rendering World is represented by a set of 3D objects, with colors, reflectvity, transparence, etc. Primite objects: Polygons, spheres, cones Complex objects: Mesh of triangles Goal: Produce a realistc 2D picture of the world
( films ) Computer Graphics is about animaton Major driving force now
Games are very important in Computer Graphics
Medical Imaging is another driving force
Computer Aided Design too
ScienTfic VisualisaTon To view below and above our visual range
Graphics / Rendering Pipeline There are three stages ApplicaTon Stage Geometry Stage RasterizaTon Stage
Batch Computer Graphics Today, stll use non-interactve batch mode for final producton-quality video and film (special effects FX). Rendering a single frame of Monsters University (a 24 fps movie) averaged 29 hours on a 24,000-core render farm! Still from Monsters University Render farm Slide by A. van Dam (Brown U.)
ApplicaTon stage (for interactve computer graphics) EnTrely done in sofware by the CPU Read Data the world geometry database, User s input by mice, trackballs, trackers, or sensing gloves In response to the user s input, the applicaton stage change the view or scene 15-12-01 Lecture 1 10
Geometry Pipeline Loaded 3D Models Model Transformation Transformation: viewing Hidden Surface Elimination Shading: reflection and lighting Imaging Pipeline
Preparing Shape Models Designed by polygons, parametric curves/surfaces, implicit surfaces and etc. Defined in its own coordinate system
Model TransformaTon Objects put into the scene by applying translaton, scaling and rotaton Linear transformaton called homogeneous transformaton is used The locaton of all the vertces are updated by this transformaton 15-12-01 Lecture 1 13
The input Slide by M. BlancheGe (McGill)
Ray-tracing Slide by M. BlancheGe (McGill)
Ray-tracing algorithm Input: - world: set of 3D objects - (x,y,z) positon of the eye - PosiTon of the 2D screen Output: Image: array of colors of size npixels by mpixels For i = 1 npixels For j = 1 mpixels r = ray( eye -> pixel(i,j) ) object = getclosestintersecton(r, world) if (object!=null) then image[i,j] = object.getcolor(); Slide by M. BlancheGe (McGill)
Recursive Ray-tracing Slide by M. BlancheGe (McGill)
Finding intersectons Suppose your world consists of Millions of objects How can you calculate closest intersecton quickly? CompuTng intersecton between ray and each object is much too slow Idea: Store your objects in a data structure that allows you to quickly discard objects that can t have intersecton Slide by M. BlancheGe (McGill)
Quad trees For a 2D-world, Subdivide the world into four quadrants. Keep subdividing as long there is more than one object per square For 3D-world, Subdivide world into eight octants Slide by M. BlancheGe (McGill)
Quad trees Subdivision is represented as a tree: Root = complete world Children = four quadrants Slide by M. BlancheGe (McGill)
Fast ray intersecton problem To quickly find intersecton between ray and world: Find which main quadrant is intersected Find which of its subquadrant is intersected Keep going down the tree untl a leaf is found If leaf contains an object, then test intersecton ConTnue untl intersecton is found Eye ray Slide by M. BlancheGe (McGill)
Hidden Surface Removal l Objects occluded by other objects must not be drawn
Shading Now we need to decide the colour of each pixels taking into account the object s colour, lightng conditon and the camera positon point light source Object
Shading : Constant Shading - Ambient l Objects colours by its own colour
Shading Flat Shading l Objects coloured based on its own colour and the lightng conditon l One colour for one face
Gouraud shading, no specular highlights l LighTng calculaton per vertex
Specular highlights added l Light perfectly reflected in a mirror-like way
Phong shading
Next, the Imaging Pipeline Geometry Pipeline Rasterization and Sampling Texture Mapping Image Composition Intensity and Colour Quantization Framebuffer/Display
RasterizaTon Converts the vertex informaton output by the geometry pipeline into pixel informaton needed by the video display Aliasing: distorton artfacts produced when representng a high-resoluton signal at a lower resoluton. AnT-aliasing : technique to remove aliasing
AnT-aliasing Aliased polygons ( edges (jagged AnT-aliased polygons
ü How is anti-aliasing done? Each pixel is subdivided (sub-sampled) in n regions, and each sub-pixel has a color; ü Compute the average color value
Texture mapping
Other topics: ReflecTons, shadows & Bump mapping