illumination and shading[vinayak garg]

15
Netaji Subhas Institute of Technology [ 2011 ] Computer Graphics Illumination and Shading Prepared By Vinayak Garg 326 / CO / 09 COE – II

Upload: vinayak-garg

Post on 12-Apr-2017

278 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Illumination and shading[vinayak garg]

Netaji Subhas Institute of Technology

[ 2011 ]

Computer Graphics

Illumination and Shading

Prepared By

Vinayak Garg326 / CO / 09COE – II

NOTE: All the figures in the document, including cover image are self made. (Modelled and rendered in Blender Software) .

Page 2: Illumination and shading[vinayak garg]

1

Contents1. Introduction2. Illumination

a. Illumination Modelsb. Ambient Lightc. Light Sourcesd. Diffuse Reflectione. Specular Reflection

3. Shadinga. Flat shadingb. Gouraud shadingc. Phong shading

Page 3: Illumination and shading[vinayak garg]

1

IntroductionA scene usually comprises of several 3D objects. Some of them are simple shapes like cuboids, cylinders, spheres or some complex shapes modelled with curves. To view this scene, modelled using a computer or some similar device, we need to perform all of the following steps -

And for displaying a realistic scene two steps, Illumination and Shading are very important.

Illumination involves determining intensity of different types of lights, present in a scene at a given point. It takes into account laws of physics (approximated). By illuminating a scene we add reality as without light it is impossible to see anything and different light sources add effects like reflection, transparency, shadows etc.

Shading is the process of assigning colour to the pixels. It invokes an Illumination model to compute colour at each Pixel positions or at same point and then shading the rest by interpolation.

Page 4: Illumination and shading[vinayak garg]

1

Illumination Illumination is the transport of energy (luminous flux of visible light) from light sources to surfaces, indirect and direct. Here we basically refer to illumination as the process of computing the luminous intensity (outgoing light) at a particular 3D point.

Fundamentally we model the interaction of electromagnetic energy within the objects of a scene. What we see, is the light (electromagnetic energy in the spectrum of visual light) that hits the eyes.

This involves a number of things:

Material properties

Object position relative to light sources and other objects

Feature of light sources

Illumination models Direct or Local Illumination – Takes into account only Surface and direct light (from

light sources) interaction. It ignores inter object reflections. Thus it is fast but incomplete.

Global Illumination – It considers not only the light which comes directly from a light source (direct illumination), but also subsequent cases in which light rays from the same source are reflected by other surfaces in the scene, whether reflective or not (indirect illumination). Theoretically reflections, refractions, and shadows are all examples of global illumination, because when simulating them, one object affects the rendering of another object (as opposed to an object being affected only by a direct light). Images rendered using global illumination algorithms often appear more photorealistic than images rendered using only direct illumination algorithms. However, such images are computationally more expensive and consequently much slower to generate.

Page 5: Illumination and shading[vinayak garg]

1

Ambient LightDue to reflections onto other objects, even object that are not directly lit by a light source are visible. Thus to model indirect illumination Ambient light source is used.

Properties of ambient Light

It has no position and no direction.

Its constant for all surfaces in the scene

It has colour

It is independent of objects orientation and position.

Surface properties are used to determine how much ambient light is reflected.

Figure 1: A sphere with only Ambient Light

Light SourcesThere are various light sources, but mainly we consider following two

Point Light Source - Rays diverge radially from the point in all directions. It is approximation for sources that are small compared to objects in the scene.

Distributed light sources – Light sources which are comparable to objects cannot be approximated as point light source. Thus light sources like tube light are treated as distributed light source. This light has a direction and varies with angle (not just distance as in point light source)

Page 6: Illumination and shading[vinayak garg]

1

Diffuse ReflectionRough surfaces scatter reflected light many directions. This is due to microscopic variations in the surface. The visibility of objects is primarily caused by diffuse reflection of light: it is diffusely-scattered light that forms the image of the object in the observer's eye. We can model the amount of incident light on a surface with a source with intensity I l as:

Il,diff = Kd Il Cos Ω

Where Kd is coefficient of diffuse reflection, Il is light intensity and Ω is the angle of incidence between the incoming light direction and surface normal. This is according to Lambert’s cosine law.

Figure 2: A sphere with only diffuse reflection

Specular ReflectionSpecular reflection is the mirror-like reflection of light (or of other kinds of wave) from a surface, in which light from a single incoming direction (a ray) is reflected into a single outgoing direction.

Specular reflection is distinct from diffuse reflection, where incoming light is reflected in a broad range of directions. An example of the distinction between specular and diffuse reflection would be glossy and matte paints. Matte paints have almost exclusively diffuse reflection, while glossy paints have both specular and diffuse reflection. A surface built from a non-absorbing powder, such as plaster, can be a nearly perfect diffuser. On the opposite side, polished metallic objects can specularly reflect light very efficiently. The reflecting material of mirrors is usually aluminum or silver.

Specular reflection intensity can be obtained using Phong model:

Ispec = Ks Il(N · H)ns

Where Ks is specular reflection coefficient, N is surface normal, H is halfway vector

(between incident light direction L and V viewing direction). The ns is specular reflection

parameter. This depends on the surface. Shiny surface like silver have high value of ns and

dull surface have small value (like 1) for ns.

Page 7: Illumination and shading[vinayak garg]

1

Figure 3: A sphere with 0.7 specular intensity and 0.9 diffuse intensity

Figure 4: Three same spheres (same surface colour and properties). Starting from left, Specular intensities are 0.25, 0.5 and 1.0

Combining diffuse and specular reflections, we get

I = Idiff + Ispec

I = Ka Ia + ∑ Ili [Kd (N · Li) + Ks (N · Hi)ns]

Here Ka is ambient reflection coefficient and Ia is ambient light intensity.

Page 8: Illumination and shading[vinayak garg]

1

ShadingShading is a sampling and reconstruction problem. Simplest shading approach is to perform independent lighting calculation for every pixel. Shading is essential because human vision uses shading as a cue to form, position, and depth. Following are few of the approximate (not physically accurate) methods of shading.

Flat ShadingThe simplest shading method applies only one illumination calculation for each primitive. This technique is called constant or flat shading. It is often used on polygonal primitives. It is very simple and fast to implement.

Figure 5: A sphere with flat shading

Drawbacks:

The direction to the light source varies over the facet

The direction to the eye varies over the facet

Nonetheless, often illumination is computed for only a single point on the face, which is usually the centroid.

Gouraud ShadingThe Gouraud shading method applies the illumination model on a subset of surface points and interpolates the intensity of the remaining points on the surface. In the case of a polygonal mesh the illumination model is usually applied at each vertex and the colours in the triangles interior are linearly interpolated from these vertex values.

The linear interpolation can be accomplished using the plane equation method.

Drawbacks:

Page 9: Illumination and shading[vinayak garg]

1

Appearance of the shading differences between adjacent polygons

It is more CPU intensive and can become a problem when rendering real time environments with many polygons.

Phong ShadingIn Phong shading (not to be confused with the Phong illumination model), the surface normal is linearly interpolated across polygonal facets, and the Illumination model is applied at every point.

In Phong shading the input is same as in Gouraud shading, which means that it expects a normal for every vertex. The illumination model is applied at every point on the surface being rendered, where the normal at each point is the result of linearly interpolating the vertex normals defined at each vertex of the triangle.

Phong shading will usually result in a very smooth appearance; however, evidence of the polygonal model can usually be seen along silhouettes. Also Phong shading is more computationally expensive than Gouraud shading since the reflection model must be computed at each pixel instead of at each vertex.

Figure 6: A sphere with Phong Shading (smooth shading)