0% found this document useful (0 votes)
38 views44 pages

Module-V - Illumination Shading Model

Uploaded by

ralac55582
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views44 pages

Module-V - Illumination Shading Model

Uploaded by

ralac55582
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Illumination and Shading

Deepika Sahu
Asst. Professor
CSE
Illumination Model/ Light Model/ Shading
Model
• It is used to calculate the intensity of light that we should
see at a given point on the surface of an object.

• A surface-rendering algorithm uses the intensity calculations


from an illumination model to determine the light intensity
for all projected pixel positions for the various surfaces in a
scene.

• Illumination is a technique to intensify(brightness will be


added) an object or point by applying certain model in order
to get a realistic image.
Light Sources
• Light source is the source that emits light.

• Total reflected light = Light directly from light


source/light emitting sources + Light directly
from reflecting surfaces/light reflecting sources

• A surface that is not directly


exposed to light may still be
visible if nearby objects are
illuminated.
Light Sources
Point Source:
• Rays from the surface follow radially diverging
paths from the source.

• Dimension is small in comparison to the size of


objects in the scene. Eg: Sun
Light Sources
Distributed Light source:
• The area of the source is not small compared to
the surfaces in the scene.

• Eg: A long fluorescent light


Light Sources
Diffuse Reflection:
• Surfaces that are rough or grainy, tend to scatter
the reflected light in all directions. This scattered
light is called diffuse reflection.
• Color of an object is the color of the diffuse
reflection of the incident light.
• Eg:
– A blue object illuminated by a white light
source reflects the blue component of the white
light and absorbs all other components.
– The same blue object illuminated by red light
appears black since all incident light is
absorbed.
Light Sources
Specular Reflection:

• Light sources create highlights or bright spots


called specular reflection.

• Mostly found on shiny surfaces.


Basic Illumination models
• Light calculations are based on:

– The optical properties of surfaces : opaque or


transparent, shiny or dull and surface-texture

– The relative position of the surface in a scene.

– The light source specification: color, position

– The background lighting conditions


Ambient light (Background light)
• The light that is the result from the light reflecting
off other sources in the environment.
• Has no direction.
• Each light source has an ambient light
contribution Ia.
• For a given surface, we can specify how much
ambient light the surface can reflect using an
ambient reflection coefficient, Ka(0 < Ka < 1).
• So, the amount of light that the surface reflect is
Iamb = Ka * Ia
Diffuse Light
• The illumination that a surface receives from a
light source and reflects equally in all directions.

• This type of reflection is called Lambertian


reflection(Lambertian surfaces).

• The brightness of the surface is independent of


the observer position since the light is reflected in
all directions equally.
Lambert’s Law
• How much light the surface receives from a light
source depends on the angle between its Normal
and the vector from the surface point to the light

• Lambert’s law: the radiant energy ’Id’ from a


small surface da for a given light source is:
Id = IL * cosθ

IL : the intensity of the light source


 is the angle between the surface
normal (N) and light vector (L)
The Diffuse Component
• Surface’s material property: Assuming that the
surface can reflect Kd (0< Kd<1, diffuse reflection
coefficient), the amount of diffuse light:
Idiff = Kd * IL * cosθ
• If N and L are normalized cosθ = N*L
⇒ Idiff = Kd * IL * (N * L)
• The total diffuse reflection = ambient + diffuse
Idiff = Ka * Ia + Kd * IL * (N * L)
Specular Light
• These are bright spots on objects such as polished
metal, apple etc.
• Light reflected from the surface unequally to all
directions.
Specular Light
• The result of near total reflection of the incident light in a
concentrated region around the specular reflection angle.

• The specular reflection angle equals the angle of the


incident light, with the two angles measured on opposite
sides of the unit normal surface vector N.
Here, R : unit vector in the direction of ideal specular
reflection.
L : unit vector directed toward the point light source.
V : unit vector pointing to the viewer
Φ : Viewing angle relative to the specular reflection
direction R
Specular Light
• As per Phong specular-reflection model, the
intensity of specular reflection is described as:
• I spec = W(θ) . Il. cosnsΦ
Specular Light
• I spec = W(θ) . Il. cosnsΦ
where ns : specular-reflection parameter (for a shiny
surface ns = 100 or more , for a dull surface ns = 1
for a perfect reflector ns = ∞ )
W(θ) : specular-reflection coefficient
At θ = 90ᵒ, W(θ) = 1 and all of the incident light is
reflected.
Il : Intensity of light source
Φ : viewing angle relative to the specular reflection
direction R.
Illumination models

• It calculate the intensity projected from a


particular surface point in a specified viewing
direction.
• Types of illumination model :
– Global illumination
– Local illumination
Global Illumination

• Global Illumination models: take into account the


interaction of light from all the surfaces in the
scene.
Local illumination

• Only consider the light, the observer position, and


the object material properties
Illumination Vs. Shading

 Illumination (lighting) model: determine the color of a


surface point by simulating some light attributes.

 Shading model: applies the illumination models at a set of


points and colors the whole image.
Shading Models for Polygons
 Constant Shading (flat shading)
 Compute illumination at any one point on the surface. Use
face or one normal from a pair of edges. Good for far away
light and viewer .
 Per-Pixel Shading
 Compute illumination at every point on the surface.
 Interpolated Shading
 Compute illumination at vertices and interpolate color
Constant Shading

• Compute illumination only at one point on the


surface

• Okay to use if all of the following are true


– The object is not a curved (smooth) surface
– The light source is very far away
– The eye is very far away
– The surface is quite small (close to pixel size)
Smooth Shading
• Need to have per-vertex normals
• Gouraud Shading
– Interpolate color across triangles
– Fast, supported by most of the graphics
accelerator cards
• Phong Shading
– Interpolate normals across triangles
– More accurate, but slow. Not widely supported by
hardware
Constant-Intensity Shading/ Flat Shading
• Fast and simple method for rendering an object
with polygon surfaces
• A single intensity is calculated for each polygon.
All points over the surface of the polygon are then
displayed with the same intensity value.
• Flat shading of polygon facets provides an
accurate rendering for an object if all of the
following assumptions are valid:
– The object is a polyhedron and is not an
approximation of an object with a curved
surface.
Constant-Intensity Shading/ Flat Shading

– All light sources illuminating the object are


sufficiently far from the surface so that the N.L
and the attenuation function are constant over
the surface.
– The viewing position is sufficiently far from the
surface so that unit vector V and reflecting
vector R is constant over the surface.
Application of Flat Shading

• Applied to the scene where both light source and


viewer are far distant from the object.
• To display fast moving object in a scene. This
algorithm is suitable.
Drawback:
• Algorithm fails to represent a scene where the
intensity is varying uniformly. That means the
intensity discontinuities can occur in flat shading.
Gouraud Shading
• This is an intensity-interpolation scheme
developed by Gouraud.
• It renders the polygon surface by linearly
interpolating intensity values across the
surface.
• It eliminates the intensity discontinuities as
intensity values for each polygon are matched
with the values of adjacent polygons along the
common edges.
Gouraud Shading
• Gouraud Shading performs the following
calculations:
1. Determine the average unit normal vector at each
polygon vertex.
2. Apply an illumination model to each vertex to
calculate the vertex intensity
3. Linearly interpolate the vertex intensities over
the surface of the polygon.
Gouraud Shading
Step 1:
• At each polygon vertex, we obtain a normal vector by
averaging the surface normal of all polygons sharing that
vertex.
• For any vertex position V, we obtain the unit vector
normal
Gouraud Shading

Step 2:
• After finding the vertex normal at each vertex we
can determine the intensity at the vertices from a
lighting model.
Gouraud Shading
Step 3:
• For each scan line, the intensity at the intersection of the
scan line with a polygon edge is linearly interpolated from
the intensities at the edge end points.
• Use a fast method for obtaining the intensity at point 4 by
interpolating between the intensities of point 1(I1) and
point 2(I2) using only the vertical displacement.
Linear Interpolation

• Calculate the value of a point based on the distances to


the point’s two neighbor points

• If v1 and v2 are known, then


x = b/(a - b) * v1 + a/(a -b) * v2
Linear Interpolation in a Triangle
• To determine the intensity
(color) of point P in the
triangle, we will do:
a. determine the intensity of 4
by linearly interpolating
between 1 and 2
b. determine the intensity of 5
by linearly interpolating
between 2 and 3
c. determine the intensity of P
by linear interpolating
between 4 and 5
Advantages

• It can remove discontinuities associated with the


constant shading model.
Disadvantages:
• Highlights on the surface are sometimes displayed
with anomalous shapes.
• The linear interpolation can cause bright or dark
intensity streaks called Mach Band to appear on
the surface.
Problem
• A polygon has five vertices with coordinates A(-
20,50), B(10,-100), C(40,-60), D(20,70), and E(-
5,20). The intensity of different vertices are IA =50,
IB = 20, IC = 30, ID = 10 and IE =20. Compute the
intensity of a point P(5,10) by applying the
Gouraud shading algorithm.
Phong Shading / Normal-vector
interpolation shading
• This is a more accurate method for rendering
polygon surface.
• This method first interpolate normal vectors and
then apply the illumination model to each surface
point.
Steps of Phong Shading

• Determine the average unit normal vector at each


polygon vertex.
• Linearly interpolate the vertex normal over the
surface of the polygon.
• Apply an illumination model along each scan line
to calculate projected pixel intensities for the
surface points.
Steps of Phong Shading
• The normal vector N for the scan-line intersection
point along the edge between vertices 1 and 2 is
obtained as :
Steps of Phong Shading

• Incremental methods are used to evaluate normals


between scan lines and along each individual scan
line.
• At each pixel position along a scan line, the
illumination model is applied to determine the
surface intensity at that point.
Advantages

1. Intensity calculations are more accurate than


gouraud shading.
2. Suitable for shining surfaces.

Disadvantages:
• Needs more calculations.
Fast Phong Shading
• Speed up surface rendering with phong shading by
using approximations in the illumination model
calculations of normal vectors.
• It approximates the intensity calculation using a
Taylor series expansion and triangular surface
patches.
• Express surface normal N at any point (x,y) over a
triangle as: N = Ax + By + C
where A, B, C are determined from the three vertex
equations:
Nk = Axk + Byk + C, k = 1,2,3 with (xk,yk) denotes a
vertex position.
Fast Phong Shading
• We can write the calculation for light-source
diffuse reflection from a surface point (x,y) as:
Nk = Axk + Byk + C, k = 1,2,3 with (xk,yk) denotes a
vertex position.
Fast Phong Shading
• We can express the denominator as a Taylor-series
expansion and retain terms up to second degree in
x and y which yields
I diff(x,y) = T5x2 + Tyxy + T3y2 + T2x + T1y + To
• Using forward differences we can evaluate this
equation with only two additions for each pixel
position (x,y) once the initial forward difference
parameters have been evaluated.
• Normal Phong shading does 6 times more
calculations than Gouraud Shading whereas Fast
Phong Shading takes twice of Gouraud Shading
only.

You might also like