1 / 40

Local Illumination and Shading

Local Illumination and Shading. Computer Graphics – Lecture 3 Taku Komura tkomura@ed.ac.uk Institute for Perception, Action & Behaviour. Today is about calculating the color of objects. The incident light Position of light source Direction Color The object Reflectance Viewer

mcdonalde
Download Presentation

Local Illumination and Shading

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. Local Illumination and Shading Computer Graphics – Lecture 3 Taku Komura tkomura@ed.ac.uk Institute for Perception, Action & Behaviour

  2. Today is about calculating the color of objects • The incident light • Position of light source • Direction • Color The object • Reflectance Viewer • Position

  3. Overview • Illumination (how to calculate the colour)‏ • Shading (how to colour the whole surface)? • BRDF (how to simulate the reflection of real objects)‏

  4. Illumination • Simple 3 parameter model • The sum of 3 illumination terms: • Ambient : 'background' illumination • Specular : bright, shiny reflections • Diffuse : non-shiny illumination and shadows 'Virtual' camera = + + Rc Specular (highlights)‏ Ambient (colour)‏ Diffuse (directional)‏

  5. Ambient Lighting • Light from the environment • light reflected or scattered from other objects • Coming uniformly from all directions • and then reflected equally to all directions • simple approximation to complex 'real-world' process • Result: globally uniform colour for object • I = resulting intensity • Ia= light intensity • ka = reflectance Example: sphere Object

  6. Object Diffuse Lighting • Light reflected to all directions • considers the angle of incidence of light on surface • (angle between light and surface normal)‏ • Also known as Lambertian reflection • Result: lighting varies over surface with orientation to light Ln Infinite point light source Example: sphere (lit from left)‏ N  I No dependence on camera angle!

  7. Object Specular Lighting • Direct reflections of light source off shiny object • specular intensity n = shiny reflectance of object • Result: specular highlight on object Ln N Infinite point light source R (Reflection)‏   α Ip: light intensity I : output color R: reflection vector S: direction towards the camera α : angle between R and S No dependence on object colour.

  8. Specular Light

  9. Combined Lighting Models • Summing it altogether : Phong Illumination Model = + + Rc Specular (highlights)‏ Ambient (colour)‏ Diffuse (directional)‏

  10. Object When you implement it… Use dot product of the vectors instead of calculating the angles N R L   α V : Vector from the surface to the viewer : Normal vector at the colored point : Normalized reflection vector : Normalized vector from the coloured point towards the light source

  11. Demo applets • http://www.cs.auckland.ac.nz/~richard/research-topics/PhongApplet/PhongDemoApplet.html

  12. Local Illumination Model • Considers light sources and surface properties only. • Not considering the light reflected back onto other surfaces • Fast real-time interactive rendering. • Most real-time graphics (games, virtual environments) are based on local illumination models • Implementation - OpenGL, Direct3D

  13. Attenuation • Haven’t considered light attenuation – the light gets weaker when the object is far away • Use 1/(s+k) where s relates to eye-object distance and k is some constant for scene. • Note: must apply 3 times – for each primary colour

  14. Color • Finally color the pixel by the RGB color

  15. Overview • Illumination (how to calculate the color)‏ • Shading (how to color the whole surface)?

  16. How often do we do the computation of illumination? • At all the points on the surface? • But usually we have normals only at the vertices Depends on the shading model – Flat Shading (once per polygon)‏ (less computation needed) – Gouraud shading (once per vertex)‏ – Phong Shading (once per pixel)‏ (heavy computation needed)‏

  17. Flat Shading • Compute the colour at the middle of the polygon • All points in the same polygon are coloured bythe same colour

  18. Shading Polyhedra • Flat (facet) shading: • Works well for objects really made of flat faces. • Appearance depends on number of polygons for curved surface objects. • If polyhedral model is an approximation then need to smooth.

  19. Mach banding. • Physiological effect exaggerates difference between closely coloured polygons. • Mach banding. • Exaggerates intensity change at an edge with a discontinuity in magnitude. • Our eyes are well adapted to seeing edges ! • Using a finer mesh is surprisingly ineffective.

  20. Gouraud Shading (Smooth Shading) • Compute the color at each vertex first • Compute the color inside the polygon by interpolating thecolors of the vertices composing the polygon

  21. Gouraud shading

  22. Gouraud Shading. Find vertex normals by averaging face normals • - Use vertex normals with desired shading model, • Interpolate vertex intensities along edges. • Interpolate edge values across a scanline. B A Ibc Iac Iac interpolated A to C, Ibc interpolated B to C. C

  23. Phong Shading • interpolating the normal vectors at the vertices • Do the computation of illumination at each point in thepolygon

  24. Direction of maximum highlight Phong shading. • For specular reflection, highlight falls off with cosn • Gouraud shading linear interpolates – makes highlight too big. • Gouraud shading may well miss a highlight that occurs in the middle of the face.

  25. Direction of maximum highlight Highlight on surface. Phong shading. • In Phong model of specular reflection, highlight falls off with cosn • Gouraud shading linear interpolates – makes highlight too big. • Gouraud shading may well miss a highlight that occurs in the middle of the face.

  26. Phong example

  27. Gouraud Shaded Floor Phong Shaded Floor • Gouraud shading is not good when the polygon count is low

  28. A C B Problems with interpolation shading. • Problems with computing vertex normals. • A,B are shared by all polygons, but C is not shared by the polygon on the left. • Shading information calculated to the right of C will be different from that to the left. • Shading discontinuity. Solution 1: subdivide into triangles that that share all the vertices Solution 2 : introduce a ‘ghost’ vertex that shares C’s values

  29. Problems with interpolation shading. • Problems with computing vertex normals. Face surface normals and averaged vertex normals shown. Unrepresentative so add small polygon strips along edges or test angle and threshold to defeat averaging.

  30. A B A D B D C Problems with interpolation shading. • Rotational invariance? • When interpolating the colour inside a polygon, the edge colours are determined first, and then they are interpolated to compute the internal colour • If the number of edges is >= 4, the results of interpolation shading can change with orientation of the polygon. Point on left is interpolated between AD & AB , Point on right is interpolated between AB & BC C

  31. Problems with interpolation shading. • Solution. • Decompose polygon into triangles before Gouraud shading.

  32. Overview • Illumination (how to calculate the color)‏ • Shading (how to color the whole surface)? • BRDF (how to simulate the reflection of real objects)‏

  33. What about real objects? • Phong Illumination model is popular but actually it is not accurate • True photorealism, requires more sophisticated and elaborate models of surface properties

  34. Reflectance of objects • The way the light reflects depends on the physical characteristics of the surface • Its not uniform

  35. Bidirectional Reflectance Distribution Function (BRDF)‏ • The reflectance of an object can be represented by a function of the incident and reflected angles • This function is called the Bidirectional Reflectance Distribution Function (BRDF)‏ • where E is the incoming irradianceand L is the reflected radiance

  36. What affects the BRDF? • The way light reflecting over the surface • The smoothness/roughness of the surface • Single reflection : if smooth, specular • Multiple reflections : diffusive • The shadowing effect

  37. Isotropic and Anisotropic BRDFs • Isotropic: • Can model by diffuse + specular reflection • Anisotripic • Brushed metal • Cannot model by diffuse + specular reflection • Reflectance changing systematically with respect to direction

  38. Measuring the BRDF • Measured using a device called gonioreflectometer • Casting light from various directions to the object, and capturing the light reflected back

  39. Summary • Illumination model • Phong model • Shading • Flat, • Gouraud, • Phong Shading • BRDF • Measuring

  40. Recommended Reading • Foley et al. Chapter 16, sections 16.1.6 up to and including section 16.3.4. • Introductory text Chapter 14, sections 14.1.6 up to and including section 14.2.6.

More Related