Presentation is loading. Please wait.

Presentation is loading. Please wait.

Local Illumination and Shading

Similar presentations


Presentation on theme: "Local Illumination and Shading"— Presentation transcript:

1 Local Illumination and Shading
Computer Graphics – Lecture 3 Taku Komura 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 + + = Ambient (colour)‏ Diffuse
The sum of 3 illumination terms: Ambient : 'background' illumination Specular : bright, shiny reflections Diffuse : non-shiny illumination and shadows 'Virtual' camera + + = Ambient (colour)‏ Diffuse (directional)‏ Specular (highlights)‏ Rc

5 Ambient Lighting Object 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 Diffuse Lighting Light reflected to all directions Ln N  I Object
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 Object No dependence on camera angle!

7 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)‏ α Object 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 + + = Ambient (colour)‏ Diffuse (directional)‏ Specular (highlights)‏ Rc

10 When you implement it… Use dot product of the vectors instead of calculating the angles N L R α Object 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 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 by the same colour

18 Shading Polyhedra Flat (facet) shading: really made of flat faces.
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 the colors of the vertices composing the polygon

21 Gouraud shading

22 Gouraud Shading. Find vertex normals by averaging face normals B A
- 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 the polygon

24 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. Direction of maximum highlight

25 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. Direction of maximum highlight Highlight on surface.

26 Phong example

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

28 Problems with interpolation shading.
Problems with computing vertex normals. A B C 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 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. A B C D 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 irradiance and 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
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 Shading BRDF Phong model Flat, Gouraud,
Phong Shading BRDF Measuring

40 Recommended Reading Foley et al. Chapter 16, sections up to and including section Introductory text Chapter 14, sections up to and including section


Download ppt "Local Illumination and Shading"

Similar presentations


Ads by Google