You are on page 1of 35

Light Models

Dept. of Computer Science and


Engineering
Islamic University, Kushtia.
Why Lighting?

3D without lighting 3D with lighting


Why Lighting?

3D without lighting 3D with lighting


Why Lighting?
 Realistic displays of a scene are obtained
 by generating perspective projections of objects and
 by applying natural lighting effects to the visible
surfaces.
 An illumination model / a lighting model / a shading
model, 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.
Lighting Model
 Photorealism in computer graphics involves two
elements:
1. accurate graphical representations of objects and
2. good physical descriptions of the lighting effects in a
scene.
 Lighting effects include
 light reflections,
 transparency,
 surface texture, and
 shadows.
Lighting Model
 Physical illumination models involve a number of factors,
such as
 object type,
 object position relative to
 light sources and

 other objects,

 the light-source conditions that we set for a scene.


 Objects can be constructed of opaque materials, or they
can be more or less transparent.
 Objects have shiny or dull surfaces and they can have a
variety of surface-texture patterns.
Lighting Model

 Light sources, of varying shapes, colors, and positions,


can be used to provide the illumination effects for a
scene.
 The intensity projected from a particular surface point in
a specified viewing direction calculates using the
parameters for
1. the optical properties of surfaces,
2. the relative positions of the surfaces in a scene,
3. the color and positions of the light sources, and
4. the position and orientation of the viewing plane,
illumination models
Light Sources
Light sources can be of
different types, for example:
 light-emitting (the sun)
 light-reflecting (the moon)
 point source
 distributed source
(fluorescent light)
 omni (all around)
 spotlight (directed)
Light Sources

Point light source

Distributed light
Illumination Model
To illumination an object there are primarily of two kinds of
light sources:
 ambient light (background light)
 all points on a surface have the same intensity
 with only ambient light, no realism (e.g. a sphere will
look like a circle slice
 point source light
 emphasizes 3D
 without ambient light, like a spotlight in a dark room
Components of Reflections
 Ambient reflection: All
surfaces in all positions
and orientations are
illuminated equally by this
light energy.
 Diffuse reflection:
Surfaces that are rough,
or grainy, tend to scatter
the reflected light in all
directions.
 Diffuse reflections are constant over each surface in a scene,
independent of the viewing direction.
Components of Reflections
 Specular reflection: The
bright spots appearing on
smooth shiny surfaces.
 Related to pure refection
(as with mirrors);
 These two are different
particularly specular
reflection only reflects light;
not the surrounding objects
in the scene.
 There are four factors
(1) distribution of the surface facets,
(2) the direction of the surface,
(3) the absorption of the surface and
(4) the blockage of light due to the surface roughness.
Components of Reflections
ambient diffuse

specular final
Diffuse reflections
Diffuse Reflection for Ambient Light
 If a surface is exposed only to ambient light, the intensity
of the diffuse reflection at any point on the surface as

I amb.diff  k a .I a
 where
ka = diffuse reflection coefficient or
diffuse reflectivity for ambient light.
ka = 0 ~ 1. It is set to 1 for good reflected surface.
Ia = Intensity of the ambient light sources
Diffuse reflections
Diffuse Reflection for Point Source:
N
 In diffuse reflections light from the
surface are scattered with equal N Radiant
intensity in all directions, Energy
independent of the viewing
direction. dA
• Lambert’s cosine law: The radiant energy from any small
surface area dA in any direction N relative to the surface
normal is proportional to cosN
• The light intensity is dA cosN.,
• Depends on the radiant energy per projected area
• Light is the same over all viewing directions.
Diffuse reflections

 The amount of incident light depends on the orientation


of the surface relative to the light source direction.
 If  is the angle between the incoming light direction and
the surface normal then the projected area of a surface
patch perpendicular to the light direction is proportional
to cos.
Diffuse reflections
 If Il, is the intensity of the point
N
light source and
 kd is the surface reflection  
Il
parameter
Incident light
 diffuse reflection equation for a
point on the surface is
I po int .diff  k d .I l cos 
 If N is the unit normal vector to a surface and
 L is the unit direction vector to the point light source from a
position on the surface then cos =N.L
I po int .diff  k d .I l N.L
Diffuse reflections
Combined Diffuse Reflection
 Total diffuse reflection for ambient and point source is
I diff  I amb.diff  I po int .diff  k a .I a  k d .I l cos
I diff  k a .I a  k d .I l N.L

More ambient

more diffuse
Specular Reflection and the Phong Model
N normal
L light R reflection
 

V viewing

The bright spot (specular reflection) sown on shiny surfaces is the


outcome of total reflection of the incident light in a concentrated region
around the specular-reflection angle.

A shiny surface has a narrow specular reflection range.

A dull (rough) surface has a wide specular reflection range.


Specular Reflection

Unit vectors
 R represents the direction of
ideal specular reflection;
 L represents toward the point
light source
 V is pointing to the viewer
from the surface position.
  is the angle between V and
R
 For an ideal reflector we
would only see reflected light
when vectors V and R
coincide (  0).
Phong Specular-reflection model
 An empirical model for calculating the specular-reflection
range, developed by Phong Bui Tuong
cos ns ( )
 where
  is the angle between viewing and specular-reflection
direction
  can be assigned values in the range 0 to 90. So
cos = 0 ~ 1.
 n is the specular-reflection parameter is determined by the
s
type of surface that we want to display.
 For very shiny surface n may be 100 or more.
s
 For duller surfaces n near to 1.
s
 For a perfect reflector, n is infinite.
s
Phong Specular-reflection model
 Specular-reflection for point source Il can be written as

I spec  k s .I l cos ns 

where ks is specular-reflection coefficient.


 Since  is the angle between two vectors R and V then
(cos  ) n s  (V .R ) n s

I spec  k s .I l (V .R) ns
Combined Diffuse and Specular
Reflections
 For a single point light source the combined diffuse and
specular reflections from a point on an illuminated
surface
I  I diff  I spec
I  k a .I a  k d .I l cos  k s .I l cos ns 
I  k a .I a  k d .I l N.L   k s .I l V.R n s
 If we place more than one point source in a scene, the
light reflection at any surface point by summing the
contributions from the individual sources:
n
I  k a .I a   I l [k d N.L  k s V.R n s ]
l 1
Polygon Rendering Methods

• Illumination model can be applied at every projected


pixel. Very expensive.

• Intensity can be calculated at few locations of the


surface and then approximated at other locations

• Usually only surface approximation by polygons and


scan-line rendering are supported.

• Color intensities are calculated at vertices and then


interpolated for the rest points.
Constant-Intensity Shading
 In this method, a single intensity is calculated for each
polygon.
 All points over the surface of the polygon are then
displayed with the same intensity value.
 Constant shading can be useful for quickly displaying the
general appearance of a curved surface
 Problem: abrupt color change across edges.
Constant-Intensity Shading

 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.
 All light sources illuminating the object are
sufficiently far from the surface so that N.L and the
attenuation function are constant over the surface.
 The viewing position is sufficiently far from the
surface so that V.R is constant over the surface.
Gouraud Surface Rendering
• Gouraud surface rendering, called also intensity-interpolation
surface rendering, provides smooth color transitions across
edges of polygon surfaces.
• It eliminates the intensity discontinuities occurring in flat
rendering.
• Each polygon surface is rendered with Gouraud shading by
performing the following calculations:
• Determine the average unit vector at each polygon
vertex.
• Apply illumination model at each vertex to obtain color
intensities at that position.
• Linearly interpolate intensities over projected areas.
Flat rendering Gouraud rendering
N2
N1 N3

N4
V

The normal vector at the vertex  Nk


k 1
V is the average of the polygon NV 
n
normal vectors sharing that
point.
 Nk
k 1
y I3 3
Ends of a scan-line are
I1 interpolated from vertices.
1
Scan-line y4  y2 y1  y4
I4  I1  I2
p y1  y2 y1  y2
I4 4 5
I5
y5  y 2 y3  y5
I5  I3  I2
y3  y 2 y3  y 2
I2
2
x x5  x p x p  x4
Internal point is interpolated from end points. Ip  I4  I5
x5  x4 x5  x4
 Incremental calculations are
used to obtain successive
edge intensity values between
scan lines and to obtain
successive intensities along a
scan line.

y  y2 y1  y
 If the intensity at edge position I I1  I2
y1  y 2 y1  y 2
(x, y) is interpolated as
 then we can obtain the
intensity along this edge for I 2  I1
I  I 
the next scan line, y - I, as y1  y 2
Phong Surface Rendering
Gouraud rendering may miss specular reflections and also create
anomalies of bright or dark bands in image.

Gouraud rendering Phong rendering


Phong Shading
 A more accurate method for rendering a polygon surface
is to interpolate normal vectors, and then apply the
illumination model to each surface point.
 A polygon surface is rendered using Phong shading by
carrying out the following steps:
 Determine the average unit normal vector at each
polygon vertex.
 Linearly interpolate the vertex normals over the surface
of the polygon.
 Apply an illumination model along each scan line to
calculate projected pixel intensities for the surface
points.
N1
N3
y  y2 y y
N N N1  1 N2
Scan-line y
y1  y2 y1  y2

N2

Instead of interpolating intensities, the average normal vectors at


vertices are interpolated. Interpolation is done similarly as for
intensities, taking advantage that y is progressing to y-1 and x to
x+1.

The computation penalty is that the illumination model is now


computed for every point of surface.

You might also like