This document discusses different methods for shading 3D graphics objects rendered as polygons, including flat shading (assigning a single color to each polygon), Gouraud shading (interpolating colors across polygon surfaces), Phong shading (interpolating normal vectors and applying lighting models at each surface point), and fast Phong shading (approximating Phong shading calculations for improved performance). Gouraud shading improves on flat shading by removing intensity discontinuities, while Phong shading produces more realistic highlights but requires more computation.
Shading involves implementing illumination models on graphics objects. These models define how light interacts with surfaces, identifying two light sources: emitting and reflecting.
Ambient light is uniformly distributed, creating diffuse illumination. Different shading methods include Constant-intensity, Gouraud, Phong, and Fast-Phong shading.
Flat shading calculates a single intensity per polygon, useful for curved surfaces. Assumptions for accuracy include object surfaces, light source position, and viewer distance.
Gouraud shading uses intensity interpolation across surfaces, requiring average normals at vertices, leading to smoother transitions without discontinuities.
Intensity at polygon edges is interpolated for scanlines. Gouraud shading can simplify process but may create artifacts like Mach bands, suggesting more polygons or Phong shading.
Phong shading improves realism by interpolating normals. It calculates intensities at pixel points using normal vectors, albeit requiring more computational resources.
Fast Phong shading approximates lighting calculations for efficiency, including specular reflections. It is less time-consuming than traditional Phong shading, though slower than Gouraud.
“ Shading isreferred as the implementation of
illumination model at the pixel points or
polygon surfaces of the graphics objects.”
3.
A model forinteraction of light with a surface is
called an illumination model.
Here we concentrate on the location and qualities of
the light that falls on the objects and the way in which
object intersects with it.
There are two types of light sources that illuminate an
object:-
(1) light - emitting sources
(2) light - reflecting sources
4.
An object isilluminated by light which does not come
from any particular source but which comes from all
directions that is ambient light.
When such illumination is uniform from all directions,
the illumination is called diffuse illumination.
Diffuse illumination is a background light which is
reflected from walls, floor and ceiling.
The reflection that is constant over each surface of the
object and they are independent of the viewing direction,
such a reflection is called diffuse reflection.
5.
This method weconsider the application of an
illumination model to the rendering of standard graphics
objects.
Each polygon can be rendered with a single intensity
or the intensity can be obtained at each point of surface.
There are four types of methods:-
(1) Constant-intensity Shading
(2) Gouraud Shading
(1) Phong Shading
(1) Fast-Phong Shading
6.
A fast andsimple method for rendering an object
with polygon surfaces is constant intensity shading, also
called flat 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, as
in fig(1)
7.
Fig(1). A polygonmesh approximation of an object (a) is
rendered with flat shading (b) and With Gouraud shading
(c).
(a) (b) (c)
8.
In general, flatshading of polygon facets provides an
accurate rendering for an object if all of the following
assumptions are valid: -
1. The object have many surfaces and is not an
approximation of an object with a curved surface
2. All light sources illuminating the objects are
sufficiently far from the surface so that is N. and L the
attenuation function and these are constant over the
surface.
(where N is the unit normal to a surface and L is the unit
direction vector to the point light source from a position
on the surface).
9.
3. The viewingposition is sufficiently far from the
surface that is V and R is constant over the surface.
(where V is the unit vector pointing to the viewer from
the surface position and R represent unit vector in the
direction of ideal specular reflection).
N
N1
N
N3
V
10.
This intensity-interpolation scheme,developed by
Gouraud and generally referred to as Gouraud shading,
renders a polygon surface by linearly interpolating
intensity values across the surface.
Intensity values for each polygon are matched with the
values of adjacent polygons along the common edges, thus
eliminating the intensity discontinuities that can occur in
flat shading.
11.
Each polygon surfaceis rendered with Gouraud shading
by performing 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.
12.
At each polygonvertex, we obtain a normal vector by
averaging the surface normal's of all polygons starting that
vertex.
The normal vector at vertex V is calculated as the
average of the surface normal's for each polygon sharing
that vertex.
4
N1
N3
V
N1
N3
N2
13.
Thus, for anyvertex position V, we obtain the unit vertex
normal with the calculation
Once we have the vertex normal's, we can determine the
intensity at the vertices from a lighting model.
14.
Following Figure demonstratesthe next step:
interpolating intensities along the polygon edges. 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 endpoints.
For the example in Fig.(3), the polygon edge with
endpoint vertices at positions 1 and 2 is intersected by the
scan line at point 4. A fast method for obtaining the
intensity at point 4 is to interpolate between intensities I1,
and I2 using only the vertical
15.
displacement of t3he scan line:
Y
X
Scan
Line5
2
4
1
Fig(3). For Gouraud shading, the intensity at point 4 is linearly
interpolated from the intensities at vertices 1 and2. The intensity at
point 5 is linearly interpolated from intensities at vertices 2 and 3.
An interior point p is then assigned an intensity value that is
linearly interpolated from intensities at positions 4 and 5.
3
P
16.
Similarly, intensity atthe right intersection of this scan
line (point 5) is interpolated from intensity values at
vertices 2 and 3. Once these bounding intensities are
established for a scan line, an interior point (such as point P
in Previous Fig(3)) is interpolated from the bounding
intensities at points 4 and 5 as
17.
Similar calculations areused to obtain intensities at
successive horizontal pixel positions along each scan line.
When surfaces are to be rendered in color, the intensity of each
color component is calculated at the vertices. Gouraud shading
can be combined with a hidden-surface algorithm to fill in the
visible polygons along each scan line. An example of an object
shaded with the Gouraud method appears in following Fig.
A polygon mesh approximation of an object (a) is rendered with
flat shading (b) and With Gouraud shading (c).
18.
Gouraud shading removesthe intensity
discontinuities associated with the constant-shading
model, but it has some other deficiencies. on the
surface are sometimes displayed with anomalous
shapes, and the linear intensity interpolation can
cause bright or dark intensity streaks, called Mach
bands, to appear on the surface.
These effects can be reduced by dividing the
surface into a greater number of polygon faces or by
using other methods, such as Phong-shading, that
require more calculations.
19.
A more accuratemethod for rendering a polygon
surface is to interpolate normal vectors, and then
apply the illumination model to each surface point.
This method, developed by Phong Bui Tuong, is
called Phong shading, or normal vector interpolation
shading. It displays more realistic highlights on a
surface and greatly reduces the Mach-band effect.
A polygon surface is rendered using Phong shading
by carrying out the following steps:
1. Determine the average unit normal vector at each
polygon vertex.
2. Linearly & interpolate the vertex normals over the
surface of the polygon.
3. Apply an illumination model along each scan line
to calculate projected pixel intensities for the
surface points.
20.
Interpolation of surfacenormals along a polygon
edge between two vertices is illustrated in Fig.(5). The
normal vector N for the scan-line intersection point
along the edge between vertices 1 and 2 can be
obtained by vertically interpolating between edge
endpoint normals.
Scan
Line
N
N 3
N 2
Fig.(5) Interpolation of
surface normals Along
a polygon edge.
21.
Incremental methods areused 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.
Intensity calculations using an approximated
normal vector at each point along the scan line
produce more accurate results than the direct
interpolation of intensities, as in Gouraud shading.
The trade-off, however, is that Phong shading
requires considerably more calculations.
22.
Surface rendering withPhong shading can be
speeded up by using approximations in the
illumination-model calculations of normal vectors.
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 vectors A, B, and C are determined from
the the three vertexequations are: Nk=Axk+Byk+C, k=1,2,3
with (xk,yk) denoting a vector
23.
Omitting the reflectivityand attenuation
parameters, we can write the calculation for light-
source diffuse reflection from a surface point (x, y) as
24.
ax+by+c
(dx2+exy+fy2+gx+hy+i)1/2
eq(1
)
T5x2+T4xy+T3y2+T2x+T1y+T0 eq(2)
where eachTk, is a function of parameters a, b, c,
and so forth.
Idiff(x,y) =
Idiff(x,y) =
where parameters such as a, b, c, and d are used to
represent the various dot products. For example
a= L.A
|L|
Finally, we can express the denominator in Eq. (1) as
a Taylor-series expansion and retain terms up to
second degree in x and y. This yields
We can rewrite this expression in the form
25.
Using forward differences,we can evaluate Eq.
(2) with only two additions for each pixel position (x,
y) once the initial forward-difference parameters
have been evaluated.
Although fast Phong shading reduces the Phong-
shading calculations, it still takes approximately
twice as long to render a surface with fast Phong
shading as it does with Gouraud shading.
Normal Phong shading using forward differences
takes about six to seven times longer than Gouraud
shading.
26.
Fast Phong shadingfor diffuse reflection can be
extended to include specular reflections.
Calculations similar to those for diffuse
reflections are used to evaluate specular terms such
as (N.H)ns in the basic illumination model. In
addition,
we can generalize the algorithm to include
polygons other than triangles and finite viewing
positions.