0% found this document useful (0 votes)
257 views40 pages

Lecture3334 - 16827 - Shading Models

The document discusses different shading models used in 3D computer graphics. It begins by explaining the need for light models, shading models, and color models. It then describes four common shading techniques: constant shading, faceted shading, Gouraud shading, and Phong shading. Gouraud shading linearly interpolates the intensity calculated at each vertex across the polygons. Phong shading interpolates surface normals to calculate intensity at points across polygons.

Uploaded by

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

Lecture3334 - 16827 - Shading Models

The document discusses different shading models used in 3D computer graphics. It begins by explaining the need for light models, shading models, and color models. It then describes four common shading techniques: constant shading, faceted shading, Gouraud shading, and Phong shading. Gouraud shading linearly interpolates the intensity calculated at each vertex across the polygons. Phong shading interpolates surface normals to calculate intensity at points across polygons.

Uploaded by

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

Chapter 14

Shading Models
3D Viewing Pipeline
Primitives
Object space
Modeling Transformation
World space
Viewing Transformation
Camera space

Hidden Surface Removal

Lighting & Shading

3D-Clipping

Projection
Normalized view space
Scan conversion, Hiding
Image space,
July 18, 2023 Computer Graphics Device coordinates 2
Image
Viewing Models
Need for different models
• Light Models: To take care of Light, its intensity and
effect on different textures.
• Shading Models: To take care of type of surface – its
shape, texture etc. and rendering the intensity at every
point of the surface.
• Colour Models: Various colour schemes present to
represent the calculated intensities on your computer.

July 18, 2023 Computer Graphics 3


Shading Models
• Shading Models: We have an illumination model for given
point on a surface and every point on the surface is unique.
• Should we calculate intensity of light at all points of the
object?
• If our surface is defined as mesh of polygons, which point
should be used?

July 18, 2023 Computer Graphics 4


Shading Models
• Keep in mind:
– It’s a fairly expensive calculation
Several possible answers, each with different implications for
the visual quality of the result
• Three common techniques are
– Constant shading (No Shading)
– Faceted shading
– Gouraud shading
– Phong shading
• Shading models dictate how often the color computation is
performed.

July 18, 2023 Computer Graphics 5


SHADING METHODS
POLYGON RENDERING METHODS

INTERPOLATION SHADING
CONSTANT SHADING FACETED SHADING Used for polyhedron-mesh
Is used for objects defined as
No Shading approximation of curved surfaces
polyhedral.

GOURAUD SHADING PHONG SHADING


Interpolate intensity Interpolate surface normal

July 18, 2023 Computer Graphics 6


CONSTANT SHADING

Effects of
different
shading
techniques
FACETED SHADING INTERPOLATION SHADING

GOURAUD SHADING PHONG SHADING

July 18, 2023 Computer Graphics 7


OBJECT MODEL

Effects of
different
shading
techniques
FACETED SHADING INTERPOLATION SHADING

GOURAUD SHADING PHONG SHADING

July 18, 2023 Computer Graphics 8


Shading Models
• We will start to look at shading or rendering methods
commonly used in computer graphics
– Constant surface shading/rendering
– Faceted surface shading/rendering
– Gouraud surface shading/rendering
– Phong surface shading/rendering

July 18, 2023 Computer Graphics 9


Contents

1. Constant Intensity Shading


2. Faceted Shading
3. Gouraud Shading
4. Phong and Fast Phong Shading
Constant Intensity Shading
• Constant intensity shading also refer to as no shading.
• It is done by giving same color to every polygon in the object.
• Thus entire object is painted with the same color.
• It is the simplest, but not realistic.

July 18, 2023 Computer Graphics 11


Contents

1. Constant Intensity Shading


2. Faceted Shading
3. Gouraud Shading
4. Phong and Fast Phong Shading
Faceted Shading
• Also known as flat shading or fast shading it is an extension
to Constant intensity shading.
• The entire object is divided into number of polygons surfaces
called facets.
• Determine the orientation of each facet and does one color
computation for each polygon or facet.
• It is simple, fast (?) and produce better results than no shading.

July 18, 2023 Computer Graphics 13


Faceted Shading

Original Faceted Shaded


• Just add lots and lots of polygons – however, this is SLOW!
July 18, 2023 Computer Graphics 14
Faceted Shading
• Still it is not realistic as
– For point sources, the direction to light varies across the facet
– For specular reflectance, direction to eye varies across the facet

• We have to determine the orientation of each facet we have to


find the normal for each facet. This approximation effect the
result.

July 18, 2023 Computer Graphics 15


Faceted Shading
• To determine the orientation of each facet we introduce vertex
normal at each vertex
– Usually different from facet normal
– Used only for shading
– Think of as a better approximation of the real surface that the polygons
approximate

July 18, 2023 Computer Graphics 16


Faceted Shading
• Vertex normals may be
– Approximated by averaging the normals of the facets that
share the vertex
– Provided with the model
– Computed from first principles

July 18, 2023 Computer Graphics 17


Faceted Shading
• It is very useful for quickly displaying the general appearance
of surfaces
• It is more applicable when
– the object must be polyhedron and 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 functions
are constant over the surface.
– The viewing position is sufficiently far from the surface so
that V.R is constant over the surface.

July 18, 2023 Computer Graphics 18


Contents

1. Constant Intensity Shading


2. Faceted Shading
3. Gouraud Shading
4. Phong and Fast Phong Shading
Gouraud Shading
• Gouraud surface shading was developed in the 1970s by Henri
Gouraud while working at the University of Utah along with
Ivan Sutherland and David Evans
• Often also called intensity-interpolation surface rendering
• This is the most common approach
– Intensity levels are calculated at each vertex
– Linearly interpolate the resulting colors over faces
• Along edges
• Along scanlines

July 18, 2023 Computer Graphics 20


Gouraud Shading
• To render a polygon, Gouraud surface rendering proceeds as
follows:
1. Determine the average unit normal vector at each vertex of
the polygon
2. Apply an illumination model at each polygon vertex to
obtain the light intensity at that position
3. Linearly interpolate the vertex intensities over the
projected area of the polygon

July 18, 2023 Computer Graphics 21


Gouraud Shading
Step 1: Determine the average unit normal vector at each vertex of the polygon

• The average unit normal


N1
vector at v is given as:
N1  N 2  N 3  N 4
Nv Nv 
v
N1  N 2  N 3  N 4
N4 N2
• or more generally:
n

N3
N i
Nv  i 1
n

N
i 1
i

July 18, 2023 Computer Graphics 22


Gouraud Shading
Step 2: Apply an illumination model at each polygon vertex
I2 • You have to apply the
N1
illumination model to take of
– ambient light
I1 Nv – Diffuse reflection
I
v – Specular reflection (?)
N4 N2 – Transparency (Refraction)

N3
I4
I3

July 18, 2023 Computer Graphics 23


Gouraud Shading
Step 3: Linearly interpolate the vertex intensities over the projected area of
the polygon along edges and along scan lines

y y4  y2 y1  y4
3
I4  I1  I2
y1  y2 y1  y2

1 y5  y 2 y3  y5
I5  I3  I2
Scan-line y3  y 2 y3  y 2
4 p 5
x5  x p x p  x4
Ip  I4  I5
x5  x4 x5  x4
2
July 18, 2023 x
Computer Graphics 24
Gouraud Shading

Original Gouraud Shaded

July 18, 2023 Computer Graphics 25


Gouraud Shading
• It can be combined with hidden surface algorithms to fill in
visible surfaces/polygons along each scan line.
• It removes the intensity discontinuities associated with the
constant shading.

July 18, 2023 Computer Graphics 26


Gouraud Shading
• It can be combined with hidden surface algorithms to fill in
visible surfaces/polygons along each scan line.
• It removes the intensity discontinuities associated with the
constant shading.
• Gouraud is more efficient using an iterative approach

July 18, 2023 Computer Graphics 27


Gouraud Shading
• Objects shaded with Gouraud shading often appears
dull, chalky
• Lacks accurate specular component
– If included, will be averaged over entire polygon

C1

C3

C2 Can’t shade that effect!

July 18, 2023 Computer Graphics 28


Gouraud Shading
• Gouraud shading can introduce anomalies known as
Mach bands
• Mach banding
– Artifact at discontinuities in intensity or intensity slope
C1

C4
C3

C2

Discontinuity in rate
July 18, 2023 Computer Graphics of color change 29
occurs here
Mach Bands
A psychological phenomenon
whereby we see bright bands
where two blocks of solid colour
meet
A good demo is available to
experiment with this at:

http://www.nbb.cornell.edu/neur
obio/land/OldStudentProjects/cs4
90-96to97/anson/MachBandingA
pplet/

Try playing with the various


parameters and see if you can
predict what the sphere will look
like
July 18, 2023 Computer Graphics 30
Contents

1. Constant Intensity Shading


2. Faceted Shading
3. Gouraud Shading
4. Phong and Fast Phong Shading
Phong Shading
• A more accurate interpolation based approach for rendering a
polygon was developed by Phong Bui Tuong
• Basically the Phong surface rendering model interpolates
normal vectors instead of intensity values and then compute
the actual intensity value using Phong Lighting Model.
• Often also called normal or vector – interpolation surface
rendering

July 18, 2023 Computer Graphics 32


Phong Shading
• Phong shading is not the same as Phong lighting,
though they are sometimes mixed up
– Phong lighting: the empirical model we’ve been
discussing to calculate illumination at a point on a surface
– Phong shading: linearly interpolating the surface normal
across the facet, applying the Phong lighting model at
every pixel

   
#lights
I i  k d Nˆ  Lˆi  k s Vˆ  Rˆ i
nshiny

I total  k a I ambient  
i 1  

July 18, 2023 Computer Graphics 33


Phong Shading
• To render a polygon, Phong surface rendering proceeds as
follows:
1. Determine the average unit normal vector at each vertex of
the polygon
2. Linearly interpolate the vertex normals over the projected
area of the polygon
3. Apply an illumination model at positions along scan lines
to calculate pixel intensities using the interpolated normal
vectors

July 18, 2023 Computer Graphics 34


Phong Shading
• Interpolating Normal
N3
y4  y2 y1  y4
N1 N4  N1  N2
y1  y2 y1  y2
y5  y 2 y3  y5
N5  N3  N2
N4 y3  y 2 y3  y 2
Np
Scan line
p N5
y p  y5 y4  y p
Np  N4  N5
y 4  y5 y 4  y5
N2
July 18, 2023 Computer Graphics 35
Phong Shading
• Phong shading accept the same input as Gouraud shading and
produce very smooth-looking results.
• Phong shading is considerably more expensive.
• Phong shading is much slower than Gouraud shading as the
lighting model is revaluated so many times
• However, there are fast Phong surface rendering approaches
that can be implemented iteratively.
• Typically Phong shading is implemented as part of a visible
surface detection technique.

July 18, 2023 Computer Graphics 36


Phong Shading
• An example of bad Vertex Averaging

July 18, 2023 Computer Graphics 37


Phong Shading Examples

July 18, 2023 Computer Graphics 38


Phong Shading Examples

July 18, 2023 Computer Graphics 39


Summary
• For realistic rendering of polygons we need
interpolation methods to determine lighting positions
• Flat shading is fast, but unrealistic
• Gouraud shading is better, but does not handle
specular reflections very well
• Phong shading is better still, but can be slow

July 18, 2023 Computer Graphics 40

You might also like