Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.
com
Illumination and Surface Rendering:
Realistic displays of a scene are obtained by perspective projections and applying
natural lighting effects to the visible surfaces of object.
An illumination model is also called lighting model and some times called as a
shading model which is used to calculate the intensity of light that we should see at a
given point on the surface of a object.
A surface-rendering algorithm uses the intensity calculations from an illumination
model.
Light Sources:
Sometimes light sources are referred as light emitting object and light reflectors.
Generally light source is used to mean an object that is emitting radiant energy e.g.
Sun.
Point Source: Point source is the simplest light emitter e.g. light bulb.
Distributed light source: Fluorescent light
When light is incident on an opaque surface part of it is reflected and part of it is
absorbed.
Surface that are rough or grainy, tend to scatter the reflected light in all direction
which is called diffuse reflection.
Diffuse reflection
When light sources create highlights, or bright spots, called specular reflection
Specuular reflection
Illumination models:
Illumination models are used to calculate light intensities that we should see at a given
point on the surface of an object. Lighting calculations are based on the optical
properties of surfaces, the background lighting conditions and the light source
specifications. All light sources are considered to be point sources, specified with a co-
ordinate position and an intensity value (color). Some illumination models are:
1. Ambient light:
This is a simplest illumination model. We can think of this model, which has no
external light source-self-luminous objects. A surface that is not exposed directly
to light source still will be visible if nearby objects are illuminated.
The combination of light reflections form various surfaces to produce a uniform
illumination is called ambient light or background light.
Ambient light has no spatial or directional characteristics and amount on each
object is a constant for all surfaces and all directions. In this model, illumination
1
Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.com
can be expressed by an illumination equation in variables associated with the
point on the object being shaded. The equation expressing this simple model is
I Ka
Where I is the resulting intensity and K a is the object's intrinsic intensity.
If we assume that ambient light impinges equally on all surface from all direction,
then
I Ia Ka
Where I a is intensity of ambient light. The amount of light reflected from an object's
surface is determined by K a , the ambient-reflection coefficient.
K a ranges from 0 to 1.
2. Diffuse reflection:
Objects illuminated by ambient light are uniformally illuminated across their
surfaces even though light are more or less bright in direct proportion of ambient
intensity. Illuminating object by a point light source, whose rays enumerate uniformly in
all directions from a single point. The object's brightness varies form one part to another,
depending on the direction of and distance to the light source.
The fractional amount of the incident light that is diffusely reflected can be set for
each surface with parameter K d , the coefficient of diffuse-reflection.
Value of K d is in interval 0 to 1. If surface is highly reflected, K d is set to near 1.
The surface that absorbs almost incident light, K d is set to nearly 0.
Diffuse reflection intensity at any point on the surface if exposed only to ambient
light is
Im abdiff I d K d
Assuming diffuse reflections from the surface are scattered with equal intensity in all
directions, independent of the viewing direction (surface called. "Ideal diffuse
reflectors") also called Lambertian reflectors and governed by Lambert's cosine law.
Idiff K d I l cos
Where I l is the intensity of the point light source.
L N → Surface Normal
Light Source
It N is unit vector normal to the surface & L is unit vector in the direction to the point
slight source then
I l , diff K d I l ( N .L)
In addition, many graphics packages introduce an ambient reflection coefficient K a to
modify the ambient-light intensity I a
Idiff K a I a K d I l ( N .L)
2
Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.com
3. Specular reflection and pong model.
When we look at an illuminated shiny surface, such as polished metal, a person's
forehead, we see a highlight or bright spot, at certain viewing direction. Such
phenomenon is called specular reflection. It is the result of total or near total reflection of
the incident light in a concentrated region around the " specular reflection angle = angle
of incidence".
Let SR angle = angle of incidence as in figure.
N - unit vector normal to surface at incidence point
R - unit vector in the direction of ideal specular reflection.
L - unit vector directed to words point light source.
V - unit vector pointing to the viewer from surface.
the viewing angle relative to the specular reflection
direction.
For ideal reflector (perfect mirror), incident light is reflected only in the specular
reflection direction.
V & R concide ( 0)
Shiny surface have narrow and dull surface wider .
An empirical model for calculating specular-reflection range developed by Phong
Bui Tuong-called "Phong specular reflection model (or simply Phong model), sets
the intensity of specular reflection proportional to cos ns 0to90 0.
Specular reflection parameter ns is determined by type of surface
Very shiny surface with large value ns (say 100 or more) and dull surface , smaller ns
(down to 1)
Rough surface such as chalk , ns = 1.
Shhiny surface Dull surface
( large ns) ( small ns)
- Intensity of specular reflection depends upon material properties of the surface
and . Other factors such as the polarization and color of the incident light.
- For monochromatic specular intersity variations can approximated by SR
coefficient w( )
3
Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.com
Fresnal's law of reflection describe specular reflection intensity with and using
w( ) , Phong specular reflection model as
Ispec = w( ) I l cos ns
Where Il is intensity of light source. is viewing angle relative to SR direction R.
For a glass, we can replace w( ) with constant Ks specular reflection coefficient.
So , Ispec = K s I l cos ns
] = K s I l (V .R) ns Since cos = V.R
Polygon (surface) Rendering Method
Application of an illumination model to the rendering of standard graphics objects
those formed with polygon surfaces are key technique for polygon rendering
algorithm.
Calculating the surface normal at each visible point and applying the desired
illumination model at that point is expensive. We can describe more efficient shading
models for surfaces defined by polygons and polygon meshes.
Scan line algorithms typically apply a lighting model to obtain polygon surface
rendering in one of two ways. Each polygon can be rendered with a single intensity,
or the intensity can be obtained at each point of the surface using an interpolating
scheme.
1. Constant Intensity Shading: (Flat Shading)
The simplest model for shading for a polygon is constant intensity shading also
called as Faceted Shading Or flat shading. This approach implies an illumination model
once to determine a single intensity value that is then used to render an entire polygon.
Constant shading is useful for quickly displaying the general appearance of a curved
surface.
This approach is valid if several assumptions are true:
1. The light source is at infinity, so N.L is constant across the polygon face.
2. The viewer is at infinity, so N.V is constant across the polygon face.
3. The polygon represents the actual surface being modeled and is not an
approximation to a curved surface.
Even if all conditions are not true, we
can still reasonably approximate surface
-lighting effects using small polygon
facets with fast shading and calculate
the intensity for each facet, at the centre
of the polygon of course constant shading
does not produce the variations in shade a
cross the polygon that should occur.
4
Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.com
2. Interpolated Shading:
An alternative to evaluating the illumination equation at each point on the polygon,
we can use the interpolated shading, in which shading information is linearly interpolated
across a triangle from the values determined for its vertices. Gouraud generalized this
technique for arbitrary polygons. This is particularly easy for a scan line algorithm that
already interpolates the z- value across a span from interpolated z-values computed for
the span's endpoints.
Gouraud Shading:
Gouraud shading , also called intensity interpolating shading or color interpolating
shading, eliminates intensity discontinuities that occur in flat shading. Each polygon
surface is rendered with Gouraud shading by performing following calculations.
1. Determine the average unit normal vector at each vertex. At each polygon vertex,
we obtain a normal vertex by averaging the surface normals of all polygons
sharing the vertex as: N2
n
N k
Nv k 1
n
N1
| Nk | N
k 1
N1 N 2 N 3 N 4
Here N v
| N1 N 2 N 3 N 4 | N4
Where Nv is normal vector at a vertex sharing
N3
Four surfaces as in figure.
2. Apply illumination model to calculate each vertex intensity.
3. Linearly interpolate the vertex intensity over the surface of the polygon.
Once Nv is known, intensity at the vertices can obtain from lighting model.
(x1,y1) I1 (x3,y3) I3
-Here in figure, the intensity of vertices 1,2,3
are I1 , I2, I3 . are obtained by averaging
ya
normals of each surface sharing the vertices
A P B and applying a illumination model.
- For each scan line , intensity at intersection
of line with Polygon edge are linearly
(x2,y2) I2 interpolated from the intensities at the edge
end point.
xa
So Intensity at intersection point A, Ia is obtained by linearly interpolating intensities of
I1 and I2 as`
5
Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.com
ya y2 y ya
Ia I 1 1 I2
y1 y 2 y1 y 2
Similarly, the intensity at point B is obtained by linearly interpolating intensities at I2 and
I3 as
y y2 y ya
Ib a I 3 3 I2
y3 y 2 y3 y 2
The intensity of a point P in the polygon surface along scan-line is obtained by linearly
interpolating intensities at Ia and Ib as,
x p xa xb x p
Ip I b Ia
xb x a xb x a
(x1,y1) (x3,y3)
Then incremental calculations are used to obtain
Successive edge intensity values between scan- y
lines as :
y-1
y y2 y y x
I I 1 1 I2
y1 y 2 y1 y 2
Then we can obtain the intensity along this edge
for next scan line at y -1 position as (x2,y2)
y 1 y2 y ( y 1)
I' I 1 1 I2 x
y1 y 2 y1 y 2
I I
I 2 1
y1 y 2
Similar calculations are made to obtain intensity successive horizontal pixel.
Advantages: Removes intensity discontinuities at the edge as compared to constant
shading.
Disadvantages: Highlights on the surface are sometimes displayed with anomalous
shape and linear intensity interpolation can cause bright or dark intensity streak called
mach-bands.
Phong Shading:
A more accurate method for rendering a polygon surface is to interpolate normal
vector and then apply illumination model to each surface point. This method is called
Phong shading or normal vector interpolation method for shading. It displays more
realistic highlights and greatly reduce the mach band effect.
A polygon surface is rendered with Phong shading by carrying out following
calculations.
- Determine the average normal unit vectors at each polygon vertex.
- Linearly interpolate vertex normals over the surface of polygon.
6
Graphics/ Illumination and Shading Downloaded from: http://www.bsccsit.com
-Apply illumination model along each scan line to calculate the pixel intensities for
the surface point.
In figure, N1, N2, N3 are the normal unit vectors
at each vertex of polygon surface. For scan-line N1 N3
that intersect an edge, the normal vector N can be (x1,y1) (x3,y3)
obtained by vertically interpolating normal vectors
of the vertex on that edge as. N
y y2 y y y
N N 1 1 N2 x
y1 y 2 y1 y 2
N2
Incremental calculations are used to evaluate
(x2,y2)
normals between scanlines and along each in-
dividual scan line as in Gouraud shading. Phong
shading produces accurate results than the direct x
interpolation but it requires considerably more calculations.
Fast Phong Shading:
Fast Phong shading approximates the intensity calculations using a Taylor series
expansion and Triangular surface patches. Since Phong shading interpolates normal
vectors from vertex normals , we can express the 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 for (xk , yk ) vertex.
Omitting the reflectivity and attenuation parameters
L.N L.( Ax By C ) ( L. A) x ( L.B) y ( L.C )
I diff ( x, y )
| L | . | N | | L | . | Ax By C | | L | . | Ax By C |
Re writing this
ax by c
I diff ( x, y ) 1
(dx exy fy gx hy i) --------------------(1)
2 2 2
Where a,b,c,d….. are used to represent the various dot products as
L.N
a ............. and so on
|L|
Finally, denominator of equation (1) can express as Taylor series expansions and
relations terms up to second degree in x,y. This yields,
I diff ( x, y) T5 x 2 T4 xy T3 y 2 T2 x T1 y T0
Where each Tk is a function of parameters a,b,c,d,……. And so forth.
This method still takes twice as long as in Gouraud shading. Normal Phong shading
takes six to seven times that of Gouraud shading