1 / 40

Local Illumination and Shading

Local Illumination and Shading. Computer Graphics – Lecture 10 Taku Komura tkomura@inf.ed.ac.uk Institute for Perception, Action & Behaviour. Last Lecture… . Hidden Surface Removal Back face culling Painter’s algorithm BSP Tree Z-buffer.

avital
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 10 Taku Komura tkomura@inf.ed.ac.uk Institute for Perception, Action & Behaviour

  2. Last Lecture… • Hidden Surface Removal • Back face culling • Painter’s algorithm • BSP Tree • Z-buffer

  3. Back Face CullingLight(L), view (V), and normal(N) Cull faces according to L.N and V.N Cull if V.N < 0 Cull if L.N > 0 (if only one light, and no ambient light)

  4. Turning on and off Z-buffer in OpenGL ON OFF

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

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

  7. Object Illumination • Simple 3 parameter model • The sum of 3 illumination terms: • Ambient : 'background' illumination • Specular : bright, shiny reflections • Diffuse : non-shiny illumination and shadows surface normal (specifies surface orientation)‏ Light source (here point light source)‏ 'Virtual' camera

  8. Ambient Lighting • Light from the environment • light reflected or scattered from other objects • simple approximation to complex 'real-world' process • Result: globally uniform colour for object • I = resulting intensity • Ia= light intensity • ka = reflectance Example: sphere N I Uniform Light source Object camera

  9. Object Diffuse Lighting • Also known as Lambertian reflection • considers the angle of incidence of light on surface (angle between light and surface normal)‏ • 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!

  10. 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)‏   α I= output color Rn= camera position α : angle between Rn and S No dependence on object colour.

  11. Specular Light

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

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

  14. Color • You do the above computation for Red, Green and Blue color • Finally color the pixel by the RGB color

  15. Demo applets • http://www.cs.unc.edu/%7Eclark/courses/comp14-spr04/code/SphereLightApplet.html • http://www.cs.auckland.ac.nz/~richard/research-topics/PhongApplet/PhongDemoApplet.html

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

  17. 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 (for all the vertices of the polygon) – Phong Shading (all the points) (heavy computation needed)

  18. Flat Shading • Compute the color at the middle of the polygon • All points in the same polygon are colored bythe same color

  19. 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

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

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

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

  23. 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 : ?

  24. Problems with interpolation shading. • Problems with computing vertex normals. Face surface normals and averaged vertex normals shown. Solution:?

  25. Exercise • Draw a picture by Phong Shading by enhancing the demo program I put up on the web. • When doing the rasterization, you do the computation of the illumination

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

  27. 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

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

  29. 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

  30. 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

  31. Isotropic and Anisotropic BRDFs • Isotropic: • Can model by diffuse + specular reflection • Anisotripic • Brushed metal • Cannot model by diffuse + specular reflection

  32. How to get the BRDF? • Measure Data • Use Analytical models • Empirical models • Microfacet

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

  34. Problems with Measured BRDF • Includes a lot of error • Huge amount of time to capture • The data size is enormous • 18 hours acquisition time, 30GB raw data • Ngan et al. EGSR ’05 -> Fitting the acquired data into analytical models

  35. Analytical models • Empirical models • Gouraud, Phong models or more complex models • Microfacet models • Assuming the surface is composed of a large number of micro mirrors • Each reflect light back to the specular direction

  36. Microfacet Theory • [Torrance & Sparrow 1967] • Surface modeled by tiny mirrors • Value of BRDF at • # of mirrors oriented halfway between and where is the incoming direction, is the out going direction • Modulated by Fresnel, shadowing/masking [Shirley 97]

  37. Examples : Satin

  38. Examples : velvet

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

More Related