433 324 graphics and interaction surface rendering and
play

433-324 Graphics and Interaction Surface rendering and shading - PowerPoint PPT Presentation

Introduction Surface rendering and shading Gouraud shading Phong shading 433-324 Graphics and Interaction Surface rendering and shading Adrian Pearce Department of Computing and Information Systems University of Melbourne The University of


  1. Introduction Surface rendering and shading Gouraud shading Phong shading 433-324 Graphics and Interaction Surface rendering and shading Adrian Pearce Department of Computing and Information Systems University of Melbourne The University of Melbourne Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  2. Introduction Surface rendering and shading Gouraud shading Phong shading Lecture outline Introduction Surface rendering and shading Gouraud shading Phong shading Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  3. Introduction Surface rendering and shading Gouraud shading Phong shading How are polygonal surfaces rendered? Aim: understand how to use illumination models to create realistic shading through surface rendering. Reading: ◮ Foley Section 14.2 Shading models for polygons. ◮ Angel Section 5.5 Polygonal Shading ◮ Akenine-Möller Section 5.Polygonal Shading ◮ Akenine-Möeller 5.5.1 Imlementing the Shading Equation Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  4. Introduction Surface rendering and shading Gouraud shading Phong shading Shading techniques How do we put these formulas to use? For polyhedral objects, we can use flat shading or full shading. ◮ In flat shading, compute the shading at some representative point of each (visible) polygon face (may be a vertex, or the centroid of the face, assuming it lies within the face). Then use this computed value to fill the whole polygon. ◮ In full shading, do the complete shading calculation at each pixel as the polygon is displayed. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  5. Introduction Surface rendering and shading Gouraud shading Phong shading In flat shading, ◮ the same value is used to render the entire polygon, ◮ it misses out on shading variations. It is therefore realistic only for distant viewer and distant light source. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  6. Introduction Surface rendering and shading Gouraud shading Phong shading If our polyhedron is really intended as an approximation to a curved object, then either flat shading or full shading are inappropriate. The discontinuities in surface normal where the face meet will lead to artefactual discontinuities in the shading. There are two cures for this: Gouraud shading and Phong shading. In both, compute an “average” surface normal at each visible vertex, by averaging the normals of the faces that meet there. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  7. Introduction Surface rendering and shading Gouraud shading Phong shading ◮ Because of the contrast enhancing caused by lateral inhibition in our visual systems, these false edges are strongly perceived and are therefore even more objectionable. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  8. Introduction Surface rendering and shading Gouraud shading Phong shading Gouraud shading Normalised polygon surface normals averaged to obtain vertex normals in Gouraud shading (Foley Figure 14.18). N 1 N v N 3 N 2 N 4 Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  9. Introduction Surface rendering and shading Gouraud shading Phong shading Calculating surface normals Assuming all polygons store vertices in same walking order , the sign for surface normals should be correct and obtained simply calculating the cross products of the vectors ( p 2 − p 1 ) and ( p 3 − p 2 ) . N p 2 p 3 p 1 p 4 p 5 — N = ( p 2 − p 1 ) × ( p 3 − p 2 ) Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  10. Introduction Surface rendering and shading Gouraud shading Phong shading In Gouraud shading, compute the shading at each vertex. When filling a polygon in a scan-line fashion, interpolate the shading linearly along each edge, and then interpolate linearly along each scan-line segment (Foley Figure 14.19). y l 1 y 1 – y s y 1 l a = l 1 – ( l 1 – l 2 ) y 1 – y 2 l a l p l b Scan line y 1 – y s y s l b = l 1 – ( l 1 – l 3 ) y 1 – y 3 y 2 l 2 x b – x p l p = l b – ( l b – l a ) y 3 x b – x a l 3 Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  11. Introduction Surface rendering and shading Gouraud shading Phong shading ◮ Gouraud shading is also called intensity interpolated shading. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  12. Introduction Surface rendering and shading Gouraud shading Phong shading Orientation dependence The results of interpolated-shading is not independent of the projected polygons position (Foley Figure 14.22). A B P P D A C B D C (a) (b) Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  13. Introduction Surface rendering and shading Gouraud shading Phong shading Perspective distortion Imagine you have a polygon with vertex 1 more distant than vertex 2. In this case you get perspective distortion, since perspective foreshortening means that the difference from one scan line to another increases in the direction of the further coordinate. Under these conditions you can get polygonal silhouettes and edges can look weird. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  14. Introduction Surface rendering and shading Gouraud shading Phong shading Phong shading Phong shading is similar to Gouraud, except interpolate the surface normals, and do full shading calculation at every pixel using these interpolated normals (Foley Figure 14.20). N a N b N c N 0 N 1 P 0 P a P b P c P 1 Normal vector interpolation used in Phong shading. What is the computational cost of Phong versus Gouraud? Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  15. Introduction Surface rendering and shading Gouraud shading Phong shading Gouraud shading (left) Phong shading (right) with highlight falling at left vertex (Foley Figure 14.21). Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  16. Introduction Surface rendering and shading Gouraud shading Phong shading Highlight falling in centre of polygon face (Foley Figure 14.21). Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  17. Introduction Surface rendering and shading Gouraud shading Phong shading Gouraud shading with specular reflection Intensity interpolation (Gouraud shading) can be used with specular reflection but get less pronounced highlights (according to specular reflection coefficient). Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  18. Introduction Surface rendering and shading Gouraud shading Phong shading Unrepresentative vertex normals Averaged vertex normals may not represent surface geometry adequately (Foley Figure 14.24). Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  19. Introduction Surface rendering and shading Gouraud shading Phong shading If interpolation is used, this example should appear like corrugated iron! ◮ In this example, there will be little or no variation in the shade, if the light source is distant. ◮ This is because we interpolate between the normals, therefore the actual surface normal information inbetween is lost! ◮ Particularly true for objects represented by with lots of small polygons. Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

  20. Introduction Surface rendering and shading Gouraud shading Phong shading Summary ◮ Polygons can be rendered to produce curved surfaces by calculating surface normals at vertices and performing either ◮ interpolation over intensity (Gouraud shading), or ◮ interpolation over surfaces normals (Phong shading). ◮ Phong shading requires calculation of the illumination model at each pixel , whereas ◮ Gouraud shading only requires calculating the illumination model at each vertex . Adrian Pearce University of Melbourne 433-324 Graphics and InteractionSurface rendering and shading

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend