1 / 29

Chapter 8: Rendering for Realism

Chapter 8: Rendering for Realism. Render: to compute the “look” of each pixel Hidden surface removal Flat shading : scattered light from each face computed at single point Smooth shading : Gourard shading Specular light : highlights for shiny objects Shadows Textures

chick
Download Presentation

Chapter 8: Rendering for Realism

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8: Rendering for Realism • Render: to compute the “look” of each pixel • Hidden surface removal • Flat shading : scattered light from each face computed at single point • Smooth shading : Gourard shading • Specular light : highlights for shiny objects • Shadows • Textures • Ray tracing (ch 14) : proper shadows, mirrorlike reflections, light through transparent objects: computationally expensive CS Hons RW778 Graphics

  2. Chapter 8: Rendering for Realism • 8.2 Shading Models • Describes how light is scattered or reflected from surface • Simple models of achromatic light (only brightness); extend to colour. • Two types of light sources: point, ambient • some light absorbed by surface • some light reflected from surface • some light transmitted into interior (e.g. glass) CS Hons RW778 Graphics

  3. Chapter 8: Rendering for Realism • Two types of reflection • Diffuse scattering: light penetrates surface slightly and is re-radiated uniformly in all directions; color affected by type of material of surface • Specular reflection: light does not penetrate surface, and is reflected directionally; causes highlights and surface appears shiny. • Total light is sum of diffuse and specular • For each point on surface, compute size of reflection that reaches eye. CS Hons RW778 Graphics

  4. Chapter 8: Rendering for Realism • 8.2.1 Geometric Ingredients • To find light that reacheseye from point P: • normal m to surface at P • v from P to eye • s from P to light source • NB! Angles calculated in world coordinates, as transformations change angles. • Model developed only for one side of face. If both visible (open box lid) must do explicitly. CS Hons RW778 Graphics

  5. Chapter 8: Rendering for Realism • 8.2.2 Computing Diffuse Component • Suppose light from point source onto face S; fraction re-radiated diffusely; some fraction reaches eye with intensity Id. • Id independent of angle betweenm and v. • Id dependent on angle betweenm and s (Lambert’s law) • Id = Isd(s.m)/|s||m| • Is : intensity of light source • d diffuse reflection coefficient • Effect of distance from light ignored CS Hons RW778 Graphics

  6. Chapter 8: Rendering for Realism • 8.2.3 Specular Reflection • Phong model • Works well for plastic-like appearance; not for metallic appearance. • r = -s + 2(s.m)m/(|m|2) • Amount of light reflected decreases as  increases. CS Hons RW778 Graphics

  7. Chapter 8: Rendering for Realism • In Phong model, decrease modeled as cosf() • Isp = Is s • s is specular reflection coefficient • Efficiency: h = s + v • Isp = Is smax(0, ) CS Hons RW778 Graphics

  8. Chapter 8: Rendering for Realism • 8.2.4 Role of Ambient Light • Diffuse and specular : shadows unrealistic • Add uniform background glow, with no particular position for ambient light source. • Source assigned intensity Ia • Each face in model assigned ambient reflection coefficient a (in practice, a = d). • Ia a added to diffuse and specular components. CS Hons RW778 Graphics

  9. Chapter 8: Rendering for Realism • 8.2.5 Combining Light Contributions • total light = diffuse + specular + ambient • 8.2.6 Adding Colour • Calculate diffuse, specular, ambient for RGB • Need 9 reflection coefficients • Colour of specular light: colour of source, not surface • Objects made of different materials: reflection coefficients can simulate different materials CS Hons RW778 Graphics

  10. Chapter 8: Rendering for Realism • 8.2.7 Shading and the Graphics Pipeline • Modelview transformation  attach colour to each vertex  clipping: new colour found by linear interpolation CS Hons RW778 Graphics

  11. Chapter 8: Rendering for Realism • 8.2.8 Using Light Sources in OpenGL: Selfstudy • 8.2.9 Material Properties in OpenGL: Selfstudy • 8.2.10 Shading of Scenes in SDL: Selfstudy. CS Hons RW778 Graphics

  12. Chapter 8: Rendering for Realism • 8.3 Flat Shading and Smooth Shading • Flat shading: Accentuates individual polygons • Smooth shading: Blends faces to de-emphasize edges • Normal vector attach to each vertex of face • Flat shading: Attach same normal vector to all vertices of face – direction normal to plane of face • Smooth shading: Attach to each vertex normal to the underlying surface at that point CS Hons RW778 Graphics

  13. Chapter 8: Rendering for Realism • For both kinds of shading, face is painted pixel by pixel with assigned colours. • Painting a face: Polygon-fill (tiler) • Move over polygon pixel by pixel, and colour • Pixels visited in regular order - scan line, bottom to top, left to right. • Assume polygons convex • Algorithm: • For each scan line • Find xleft, xright • For each pixel across scan line • Find color, fill pixel CS Hons RW778 Graphics

  14. Chapter 8: Rendering for Realism • 8.3.1 Flat Shading • For flat face (barn roof) and distant light source, diffuse light component nearly the same for every point on face. • OpenGL : entire face drawn with same colour (colour of first vertex) • Fast • Edges very pronounced due to lateral inhibition • Discontinuity in intensity across object, eye manufactures Mach band  vivid edge. CS Hons RW778 Graphics

  15. Chapter 8: Rendering for Realism • Specular highlights  poor with flat shading • 8.3.2 Smooth shading • De-emphasize edges by computing colours at more points • Gourard (OpenGL) and Phong CS Hons RW778 Graphics

  16. Chapter 8: Rendering for Realism • Gourard shading • colourleft= lerp(colour1,colour4,f)f = (ys-ybott)/(y4-ybott) • Across scan line:c(x) = lerp(colourleft, colourright, (x-xleft)/(xright-xleft)) • Efficiency: c(x+1) = c(x) + ((colourright – colourleft)/(xright-xleft)) • Doesn’t work well for highlights (why?) • Specular component usually not included. CS Hons RW778 Graphics

  17. Chapter 8: Rendering for Realism • Phong Shading • Find normal vector at each point on face by interpolating normal vectors at vertices • mleft = lerp (m4,m3, (ys-y4)/(y3-y4)) • Interpolate mleft, mright at each x on scan line • Drawback: slow • Not OpenGL (approximate bytexturing) CS Hons RW778 Graphics

  18. Chapter 8: Rendering for Realism • 8.4 Removing Hidden Surfaces • Given enough memory, use depth buffer (z-buffer) • Disadv: memory, can render object that is later “unrendered”. • Depth buffer b bits deep; for every bit p[i][j] on display, depth buffer stores d[i][j] • Render: • d[i][j] contains pseudodepth of closest object encountered so far. • Scan line: If pseudodepth of current face less than that in d[i][j] at that point; if so, replace d[i][j] with new pseudodepth. CS Hons RW778 Graphics

  19. Chapter 8: Rendering for Realism • d[][] initialized to 1.0; frame buffer initialized with background colour. • Finding Pseudodepth at each Pixel • At great distances, rounding may cause problems • Using the depth buffer in OpenGL CS Hons RW778 Graphics

  20. Chapter 8: Rendering for Realism • 8.5 Adding Texture to Faces • Texture function (s,t) produces colour/intensity value for 0 <= s,t <= 1 • Sources: bitmaps, functions • Bitmaps: array txtr[c][r] of colour values (texels) • Given texture, must map to world coordinates on object’s surface (Ttw), then view with camera (Tws). CS Hons RW778 Graphics

  21. Chapter 8: Rendering for Realism • 8.5.1 Pasting Texture onto Flat Surface • Texture flat, face flat  associate points on texture with points on face • If same shape, then affine transformation • Adding texture coordinates to mesh objects: • Add texture list to mesh object • Mesh consists of number of flat faces, and different texture to each. • Mesh respresents smooth underlying object, and single texture “wrapped around” it. CS Hons RW778 Graphics

  22. Chapter 8: Rendering for Realism • Selfstudy: OpenGL in 8.5.1, as well as detail of adding texture coordinates to mesh objects (p.444). • 8.5.2 Rendering the Texture • Similar to Gourard shading • For each pixel, determine texture coordinates (s,t), access texture, set pixel to proper texture colour. CS Hons RW778 Graphics

  23. Chapter 8: Rendering for Realism • Careful : cannot linearly interpolate moving across scan line, as equal steps across projected face do not correspond to equal steps across 3D face (see fig. 8.42) CS Hons RW778 Graphics

  24. Chapter 8: Rendering for Realism • Works also for moving animation • Selfstudy: Deriving how f and g are related • Selfstudy: Rendering images incrementalle • Selfstudy: Implications for graphics pipeline • 8.5.3 What does Texture Modulate? • Different renderings for different visual effects • Creating a Glowing Object: • Set visible intensity equal to texture value at each spot CS Hons RW778 Graphics

  25. Chapter 8: Rendering for Realism • Painting Texture by Modulating the Reflection Coefficient • Vary diffuse reflection and ambient refleciton. • Simulating Roughness by Bump Mapping • Technique to give surface wrinkled or dimpled appearance without having to model each individual dimple. • Use texture function to perturb surface normal vector  causes perturbations in amount of diffuse and specular light. CS Hons RW778 Graphics

  26. Chapter 8: Rendering for Realism • m’(u*,v*) = m(u*,v*) + (m×Pv)textureu –(m×Pu)texturevwhere textureu, texturev are partial derivates of texture function wrt u, v. • 8.5.4 Texturing using OpenGL: Selfstudy CS Hons RW778 Graphics

  27. Chapter 8: Rendering for Realism • 8.5.5 Wrapping Texture on Curved Surfaces • Selfstudy: Examples 8.5.1-8.5.4. • 8.5.6 Reflection Mapping • See world surrounding object reflected in object • Chrome mapping – rough, blurry image reflected • Environment mapping – recognizable image reflected • Surrounding cube less distortion than surrounding sphere • Movement: reflection “flows” over surface • How? Ray traces direction of reflection CS Hons RW778 Graphics

  28. Chapter 8: Rendering for Realism • 8.6 Adding Shadows of Object : Selfstudy. CS Hons RW778 Graphics

  29. Chapter 8: Rendering for Realism • Programming Task : None, due toe exam next week. • However, you may earn bonus marks (equal to one task) by implementing Case Study 8.1 (Shading), p. 469, in Hill. CS Hons RW778 Graphics

More Related