Visualisatie BMT Rendering Arjan Kok a.j.f.kok@tue.nl 1
Lecture overview Color Rendering Illumination 2
Visualization pipeline Raw Data Data Enrichment/Enhancement Derived Data Visualization Mapping Abstract Visualization Object Rendering Displayable Image 3
Color The electromagnetic spectrum visible to humans contains wavelengths ranging from about 400 to 700 nm Light we see consists of different intensities of these wavelengths 4
Color The human eye contains three receptors (cones): for red, green and blue Color we see is a combination of these Response curves 5
Color systems Color system A way to represent color on a computer Most used: RGB HSV 6
RGB-model 3 primary colors: Red, Green and Blue Color cube: Color = point in cube Additive: C = rr + gg + bb R B G 7
HSV-model More user oriented: based on intuitive perception Hue (0-1 or 0-360 ) Saturation (0-1) Value (0-1) Color is point in cone 8
Rendering How do I generate an image of a scene? Problems: World is complex (shape, light) World is 3 dimensional, screen is 2 dimensional 9
Subdivide problem Geometric modeling How do we define shape of objects? Projection and hidden surface removal How do we determine what is visible on screen and what is not. Shading How do we model color, texture and contribution of light? Rasterization Determine pixel values for visible objects 10
Graphics pipeline Geometric model Viewing Camera parameters Visible surface determination Light sources, materials Shading Rasterize Raster display 11
Raster graphics Currently standard for computer graphics Screen is subdivided in grid of squares : picture elements or pixels Per pixel: n bits information Resolution: size of grid and number of bits per pixel 12
Raster graphics hardware system bus display processor CPU system memory 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 1 0 frame buffer video controller monitor 13
Visualization pipeline Raw Data Data Enrichment/Enhancement Derived Data Visualization Mapping Abstract Visualization Object Rendering Displayable Image 14
Graphics pipeline Geometric model Viewing Camera parameters Visible surface determination Light sources, materials Shading Rasterize Raster display 15
Viewing Given a 3D model, how do we project this model on screen? Camera model Eye/view point: From which point do we look to the scene? Target point or viewing direction: Where do we look at? Viewing angles: What lens do we use? 16
The camera 17
Graphics pipeline Geometric model Viewing Camera parameters Visible surface determination Light sources, materials Shading Rasterize Raster display 18
Why illumination 19
Illumination Illumination model Illumination (and therefore color) of point on surface is determined by simulation of light in scene Illumination model is approximation of real light transport Shading method determines for which points illumination is computed determines how illumination for other points is computed 20
Illumination models Model(s) needed for Emission of light Scattering light at surfaces Reception on camera Desired model requirement Accurate Efficient to compute 21
Point light source Emits light equally in all directions Parameters Intensity I L Position P (p x,p y,p z ) Approximation for small light sources P 22
Direction light source Emits light in one direction Can be regarded as point light source at infinity E.g. sun Parameters Intensity I L Direction D (d x,d y,d z ) D 23
Surface illumination When light arrives at surface, it can be Absorbed Reflected Transmitted absorption reflection transmission 24
Reflection model Total intensity on point reflected in certain direction is determined by: Diffusely reflected light Specularly reflected light Reflection of ambient light 25
Diffuse reflection Incoming light is reflected equally in all directions Amount of reflected light depends only on angle of incident light viewer surface 26
Diffuse reflection Lambert law: Reflected energy from a surface is proportional to the cosine of the angle of direction of incoming light and normal of surface I d = k d I L cos(θ) = k d I L (N L) k d is diffuse reflection coefficient viewer N θ V L surface 27
Specular reflection Models reflections of shiny surfaces θ θ 28
Specular reflection Shininess depends on roughness surface Incident light is reflected unequally in all directions Reflection strongest near mirror angle very shiny less shiny 29
Specular reflection / Phong Light intensity observed by viewer depends on angle of incident light and angle to viewer Phong model: I s = k s I L cos n (α) = k s I L (V R) n k s is specular reflection coefficient n is specular reflection exponent θ N θ R L V α 30
Specular reflection / Phong increasing k s increasing n 31
Ambient light Even though parts of scene are not directly lit by light sources, they can still be visible Because of indirect illumination 32
Ambient light Ambient light I A is an approach to this indirect illumination Ambient light is independent of light sources and viewer position Contribution of ambient light I = k a I a k a is ambient reflection coefficient I a is ambient light intensity (constant over scene) 33
Total illumination model Total intensity I total at point P seen by viewer is n ( k cos( θ ) + k cos ( α ) I total = k ai a + I i d i s i ) i n ( k (N L ) + k (V R ) I total = k ai a + I i d i s i ) i θ 1 θ 0 α 0 α 1 34
Total illumination model In previous formula k a, k d dependent on wavelength (different values for R, G and B) Often division into color and reflection coefficient of surface I totaal = I e + k a C a I a + I where: 0 k a, k s, k s 1 (relative amounts) ( n k C cos( θ ) + k C cos ( α ) ) C a is ambient reflected color of surface C d is diffuse reflected color of surface C s is specular reflected color of surface i i d d i s s i 35
Only emission and ambient 36
Including diffuse reflection 37
Including specular reflection 38
Illumination model Given model: Simple Effective Not real world More advanced models possible 39
Shading Illumination model computes illumination for a point on surface But how do we compute the illumination for all points on all (visible) surfaces? Shading methods: Flat shading Gouraud shading Phong shading 40
Normal vectors For illumination model we need normal vectors for the cell center the cell nodes every pixel in the image 41
Normal vectors Cell normals Use the cross product of two cell edges n = v1 v2 v1 v2 Node normals Compute cell normals for neighbor cells Average cell normals n n1 + n2 + n3 + n4 = 4 42
Flat shading Determine illumination for one point on cell (e.g. center) Use this illumination for all points on cell Disadvantages: Does not account for changing direction to light source over polygon Does not account for changing direction to eye over polygon Discontinuity at polygon boundaries (when curved surface approximated by polygon mesh 43
Flat shading 44
Gouraud shading Based on interpolation of illumination values Compute illumination for nodes of cell Algorithm for all nodes of cell get node normal compute node illumination using this normal for all pixels in projection of polygon compute pixel illumination by interpolation of node illuminations 45
Gouraud shading I 2 I 1 y s I A I B I P I I A B = = ( 1 α) I1 + αi 2 y α = y 1 1 y y 2 ( 1 β) I1 + βi2 y β = y 1 1 y y s s 3 I 3 I P = (1 γ)i x γ = x A A A + γi x x P B B 46
Gouraud shading 47
Gouraud shading Advantages Interpolation is simple, hardware implementation Continuous shading Better results for curved surfaces Disadvantages Subtle illumination effects (e.g. highlights) require high subdivision of surface in very small polygons Mach banding 48
Phong shading Based on normal interpolation Compute illumination for each visible point of cell Algorithm for each node of cell get node normal for each pixel in projection of cell compute point normal by interpolation of node normals compute pixel illumination using interpolated normal 49
Phong shading 50
Phong shading Advantages Much better results for curved surfaces Nice highlights No Mach banding Disadvantages Computational expensive Normal interpolation and application of illumination model for each pixel 51
Shading summarized 52
Shading Flat shading 1x application of illumination model per cell 1 color per polygon Gouraud shading 1x application of illumination model per node Interpolated colors Phong shading 1x application of illumination model per pixel Nice highlights Increase computation time Increase quality 53
Graphics pipeline Geometric model Viewing Camera parameters Visible surface determination Light sources, materials Shading Rasterize Raster display 54