Presentation is loading. Please wait.

Presentation is loading. Please wait.

Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.

Similar presentations


Presentation on theme: "Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action."— Presentation transcript:

1 Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura tkomura@inf.ed.ac.uk Institute for Perception, Action & Behaviour

2 Taku KomuraComputer Graphics Last Lecture… Hidden Surface Removal  Back face culling  Painter’s algorithm  BSP Tree  Z-buffer

3 Taku KomuraComputer Graphics Back Face Culling Light(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 Taku KomuraComputer Graphics Turning on and off Z-buffer in OpenGL ON OFF

5 Taku KomuraComputer Graphics Today is about calculating the color of objects The incident light Position of light source Direction Color The object Reflectance Viewer Position

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

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

8 Taku KomuraComputer Graphics 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 — I a = light intensity — k a = reflectance Object Uniform Light source IN camera Example: sphere

9 Taku KomuraComputer Graphics 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 Object Infinite point light source N LnLn I  No dependence on camera angle! Example: sphere (lit from left)‏

10 Taku KomuraComputer Graphics Specular Lighting Direct reflections of light source off shiny object –specular intensity n = shiny reflectance of object –Result: specular highlight on object Object N I = output color R n = camera position α : angle between R n and S R (Reflection)‏  Infinite point light source LnLn No dependence on object colour. α 

11 Taku KomuraComputer Graphics Specular Light

12 Taku KomuraComputer Graphics Combined Lighting Models Summing it altogether : Phong Illumination Model ++ = Ambient (colour)‏ Diffuse (directional)‏ Specular (highlights)‏ RcRc

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

14 Taku KomuraComputer Graphics Color You do the above computation for Red, Green and Blue color Finally color the pixel by the RGB color

15 Taku KomuraComputer Graphics Demo applets http://www.cs.unc.edu/%7Eclark/courses/comp14- spr04/code/SphereLightApplet.html 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 Taku KomuraComputer Graphics Overview Illumination (how to calculate the color) Shading (how to color the whole surface)?

17 Taku KomuraComputer Graphics 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 Taku KomuraComputer Graphics Compute the color at the middle of the polygon All points in the same polygon are colored by the same color Flat Shading

19 Taku KomuraComputer Graphics Compute the color at each vertex first Compute the color inside the polygon by interpolating the colors of the vertices composing the polygon Gouraud Shading (Smooth Shading)

20 Taku KomuraComputer Graphics interpolating the normal vectors at the vertices Do the computation of illumination at each point in the polygon Phong Shading

21 Taku KomuraComputer Graphics

22 Taku KomuraComputer Graphics Gouraud Shaded Floor Phong Shaded Floor Gouraud shading is not good when the polygon count is low

23 Taku KomuraComputer Graphics interpolating the normal vectors at the vertices Do the computation of illumination at each point in the polygon Phong Shading

24 Taku KomuraComputer Graphics 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 : ? A B C

25 Taku KomuraComputer Graphics Problems with interpolation shading. Problems with computing vertex normals. Face surface normals and averaged vertex normals shown. Solution:?

26 Taku KomuraComputer Graphics 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

27 Taku KomuraComputer Graphics Overview Illumination (how to calculate the color) Shading (how to color the whole surface)? BRDF (how to simulate the reflection of real objects)

28 Taku KomuraComputer Graphics 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

29 Taku KomuraComputer Graphics Reflectance of objects The way the light reflects depends on the physical characteristics of the surface Its not uniform

30 Taku KomuraComputer Graphics 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 irradiance and L is the reflected radiance

31 Taku KomuraComputer Graphics 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

32 Taku KomuraComputer Graphics Isotropic and Anisotropic BRDFs Isotropic:  Can model by diffuse + specular reflection Anisotripic  Brushed metal  Cannot model by diffuse + specular reflection

33 Taku KomuraComputer Graphics How to get the BRDF? Measure Data Use Analytical models  Empirical models  Microfacet

34 Taku KomuraComputer Graphics Measuring the BRDF Measured using a device called gonioreflectometer  Casting light from various directions to the object, and capturing the light reflected back

35 Taku KomuraComputer Graphics 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

36 Taku KomuraComputer Graphics 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

37 Taku KomuraComputer Graphics 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]

38 Taku KomuraComputer Graphics Examples : Satin

39 Taku KomuraComputer Graphics Examples : velvet

40 Taku KomuraComputer Graphics Summary Illumination model  Phong model Shading  Flat,  Gouraud,  Phong Shading BRDF  Measuring  Analytical models — Phong — Microfacet


Download ppt "Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action."

Similar presentations


Ads by Google