SlideShare a Scribd company logo
1 of 90
Unit 4:Visible surface detection methods,
Illumination models and surface rendering methods
Presented By : Tekendra Nath Yogi
Tekendranath@gmail.com
College Of Applied Business And Technology
Outline
• Unit 4. 12 Hrs.
– Visible Surface Determination:
• Various Techniques
• Algorithms for Visible Surface Detection, (Z- Buffer, List priority, Scan Line
Algorithms)
– Illumination models.
• Ambient light
• Diffuse reflection
• Specular reflection
• Light intensity attenuation
• Color consideration
• Transparency
• shadows
– Surface Shading Methods/surface Rendering Methods
• Constant intensity shading
• Gouraud
• Phong Shading
2By: Tekendra Nath Yogi2/9/2019
Visible surface determination/ Hidden surface Elimination methods
• For the generation of realistic graphics display. We have to identify those
parts of a scene that are visible from a chosen viewing position.
• To solve this problem different algorithms are used called the visible
surface detection or hidden surface elimination algorithms.
• These algorithms determines the lines, edges, or surfaces that are visible or
invisible to an observer located at a specific point in space.
• So, that we can display only the visible lines or surfaces to produce
realistic display.
3By: Tekendra Nath Yogi2/9/2019
Contd….
• Visible surface detection algorithms are broadly classified according to
whether they deal with object definitions directly or with their projected
images. These two approaches are called:
– Object space methods and
– Image space methods.
4By: Tekendra Nath Yogi2/9/2019
Contd….
Pseudo code for Image space Method
for(each pixel in the image)
determine the object closest to the viewer that is penetrated by the projector through
the pixel;
draw the pixel in the appropriate color;
Ex: Depth buffer method
Pseudo code for Object space Method
for(each object in the world)
determine those parts of the object whose view is not blocked by other parts of it or
any other object;
draw those parts in the appropriate color;
Ex: Back-face detection method
Image space methods are by far the more common!
5By: Tekendra Nath Yogi2/9/2019
Contd….
• Algorithms for Visible surface detection:
– Back face detection (plane equation method)
– z-buffer Algorithm(Depth buffer method)
– List Priority algorithm
– Scan Line Algorithm
6By: Tekendra Nath Yogi2/9/2019
Back face detection (plane equation method)
• It is fast and simple object-space method for identifying the back-faces of
polyhedron which is based on the inside –outside test.
• A point (x, y, z) is inside a polygon surface if
Ax+By+Cz+ D <0
• When an inside point is along the line of sight to the surface , the polygon must be a
back face
• We simplify this test by considering the normal vector N to a polygon surface
which has Cartesian component (A,B,C).
• If V is vector in viewing direction from the eye position then this polygon is back
face if
2/9/2019 7
faceback:0NV
VN
By: Tekendra Nath Yogi
2/9/2019 8
• If the object descriptions have been converted to a projection
coordinates and viewing direction is parallel to the viewing Zv axis
then V= (0,0,Vz) and
V.N= Vz . C
• If viewing direction along negative Zv axis the polygon is back
face if C<0
• If viewing direction along positive Zv axis , then polygon is back
surface if C>0
Limitation:
• It cannot be applicable for all case like overlapping case such as two
faces of single object is overlapping
Contd….
By: Tekendra Nath Yogi
Depth Buffer (Z- buffer)Method
• A commonly used image-space approach to detecting visible surfaces . It is
developed by CutMull in 1974.
• This method compares surface depths at each pixel position on the
projection plane
• Each surface of a scene is processed separately, one point at a time across
the surface.
• object depth is measured from the view plane along the z axis of a viewing
system.
• The Z buffer algorithm is usually implemented in the normalized
coordinates , so that Z values range form 0 at the back clipping plane to 1
at the front clipping plane.
9By: Tekendra Nath Yogi2/9/2019
Contd….
• Two buffers required
– Depth buffer:
• to store depth value for each (x, y) position as surfaces are
processed
• Initially set to 0, representing the z- value at the back clipping plane
.
– Refresh buffer:
• to store intensity values of each (x, y) position as surfaces
processed.
• Initially refresh buffer is initialized to background intensity
10By: Tekendra Nath Yogi2/9/2019
Contd…
• At viewing plane position (x, y), surface S1 has the smallest depth( means have
highest Z value in normalized coordinate.) from the view plane and so is visible
at top position
11By: Tekendra Nath Yogi2/9/2019
Contd….
• Algorithm:
1. Initialize the depth buffer and refresh buffer so that for all buffer positions (x,y)
depth(x, y) = 0,
refresh(x, y) = Ibackground
2. For each position on each polygon surface, compare depth values to previously
stored values in depth buffer to determine visibility.
● Calculate the depth z for each (x,y) position on the polygon.
● If z >depth(x,y), then
depth(x, y) = z,
refresh(x, y) = Isurf(x,y).
where, Ibackground is the value for the bacground intensity and Isurf(x,y), is the projected
intensity value for the surface at (x,y).
 After all surfaces have been processed, the depth buffer contains depth values for the visible
surfaces and the refresh buffer contains the corresponding intensity values for those
surfaces.
12By: Tekendra Nath Yogi2/9/2019
Contd….
13By: Tekendra Nath Yogi2/9/2019
Contd….
• Example: Let us consider two surfaces present in the scene as
shown in fig below
14By: Tekendra Nath Yogi2/9/2019
Contd….
• Step 1: Initialize the depth buffer
15By: Tekendra Nath Yogi2/9/2019
Contd….
• Step 2: Draw the polygon with depth 0.3
16By: Tekendra Nath Yogi2/9/2019
Contd….
• Step 3: Draw the polygon with depth 0.5
17By: Tekendra Nath Yogi2/9/2019
Contd….
• Advantages:
– For polygon surfaces, the depth buffer method is very easy
to implement, and it requires no sorting of the surfaces in a
scene.
– It can be implemented in hardware to overcome the speed
problem.
• Disadvantages:
– It requires an additional buffer and hence the large memory.
– It is a time consuming process as it requires comparison of
each pixel instead of for the entire polygon.
18By: Tekendra Nath Yogi2/9/2019
List Priority Algorithms
• List-Priority-Algorithms determine a visibility ordering for
objects ensuring that a correct picture results if the objects are
rendered in that order.
• E.g. if no object overlap another in z, then we need to sort the
objects by increasing z and render them in that order.
• The types of LPA algorithms
– Depth Sorting Algorithms
– Binary Space Partitioning Trees
19By: Tekendra Nath Yogi2/9/2019
Contd….
• Depth Sorting Algorithms (painter’s Algorithm): Each layer
of paint covers up the previous layer.
– i.e., first paints the background colors
– Next, the most distant objects are added, then the nearer objects, and so forth
– At the final step, the foreground objects are painted on the canvas
20By: Tekendra Nath Yogi2/9/2019
Contd….
• Depth sorting algorithm uses the similar technique: paint the
surface intensity into the frame buffer in order of decreasing distance from
the viewpoint.
• Three steps:
1. Sort all surfaces according to the smallest (farthest from view plane) z
coordinate value on each surface.
2. Resolve if any ambiguities( e.g., polygon’s z extents overlap->splitting
polygons if necessary).
3. Scan convert each polygon in ascending order of smallest z
coordinate.(i.e. back to front).
21By: Tekendra Nath Yogi2/9/2019
Contd….
• For scan conversion make the following tests for each surface that
overlaps with S.
• If any one of these tests is true, no reordering is necessary for that
surface.
– The bounding rectangles in the xy plane for the two surfaces do not
overlap
– Surface S is completely behind the overlapping surface relative to the
viewing position.
– The overlapping surface is completely in front of S relative to the
viewing position.
– The projections of the two surfaces onto the view plane do not overlap.
22By: Tekendra Nath Yogi2/9/2019
Test #1
• The boundary rectangles (minimum closed rectangles for the
surfaces) in the xy-plane for the two surfaces do not overlap.
• Test # 1 is passed, scan convert S2 and then S1. Because, S2
has the highest depth.
23By: Tekendra Nath Yogi2/9/2019
Test #2
• Surface S1 is completely behind the overlapping surface S2
relative to the viewing position.
• S1 is scan converted first, then S2 is scan converted.
24By: Tekendra Nath Yogi2/9/2019
Test #3
• The overlapping surface S2 is completely in front of S1 relative to the
viewing position.
• S1 is not completely behind S2. So, Test #2 fails.
• S1 is scan converted first.
25
In figure, S2 is in front of S1, but S1 is
not completely inside/behind S2 Test #2
is not true or fails, although
Test #3 is true.
By: Tekendra Nath Yogi2/9/2019
Test #4
• Bounding rectangles overlap but the projections of the two surfaces onto the
view plane do not overlap.
• Use plane equations and test for intersection if no intersection then scan convert
s1 first and s2 next.
• Note: all the tests are failed in second figure.
26
Test #4 passed for the first figure
but it fails for the second figure.
By: Tekendra Nath Yogi2/9/2019
Continue Test #4..
• Case Study-1
Non of the tests
are true, so we have to
reorder the sequence
of the surfaces.
27
Initial Order:
S1->S2
Change the order:
S2->S1
By: Tekendra Nath Yogi2/9/2019
Continue..
• Case Study 2:
Initial order:
S1->S2->S3
Because S1 has the Maximum
depth, then S2 has the maximum
depth and lastly S3 but painters
logic fails.
S1->S2:
Test #1 passed.
Check for S1 and S3 : All Tests fails.
Now, interchanging S3->S2->S1.
Check S2 and S3, all tests fail again.
Correct order is by swapping S2 and S3 position:
S2->S3->S1
28By: Tekendra Nath Yogi2/9/2019
Continue..
• Process of checking the order results in an infinite loop.
• So avoiding
infinite loop
any of the
polygon is
clipped or
split.
29By: Tekendra Nath Yogi2/9/2019
Contd….
• BSP-Tree Method:
– Binary space partitioning method is one of the efficient method for
determining object visibility
– Paint the surfaces onto the frame buffer from back to front.
– Particularly useful when the view reference point changes, but the
objects in a scene are at fixed positions.
30By: Tekendra Nath Yogi2/9/2019
Contd….
• To Build a BSP Tree :
1. Choose a polygon plane Pi, and compute the equation of the plane it
defines.
2. Test all the vertices of all the other polygons to determine if they are in
front of, behind, or in the same plane as Pi. If the plane intersects a
polygon, divide the polygon at the plane.
3. Polygons are placed into a binary search tree with Pi as the root.
4. Call the procedure recursively on the left and right sub-tree.
When the BSP Tree is complete, we process the tree by selecting the surfaces
for display in the order back to front.
31By: Tekendra Nath Yogi2/9/2019
Contd….
32By: Tekendra Nath Yogi2/9/2019
Contd….
• Scan Line Algorithm:
• Extension of the scan-line algorithm for filling polygon interiors.
• In this method, as each scan line is processed, all polygon surfaces
intersecting that lines are examined to determine which are visible.
• Across each scan line, depth calculations are made for each overlapping
surface to determine which is nearest to the view plane.
• When the visible surface has been determined, the intensity value for
that position is entered into the refresh buffer.
33By: Tekendra Nath Yogi2/9/2019
Contd…
Algorithm:
1. Initialize the necessary data structure
a. Edge table containing end point coordinates, slope and polygon pointer.
b. Surface table containing plane coefficients and surface intensity
c. Active Edge List, keep a trace of which edges are intersected by the given scan line
d. Flag for each surface (on entry of scan set on, on exit set off)
2. For each scan line repeat
a. update active edge list
b. determine point of intersection and set surface on or off.
c. If flag is on, store its Intensity value in the refresh buffer
d. If more than one surface is on, do depth sorting and store the intensity of surface
nearest to view plane in the refresh buffer
34By: Tekendra Nath Yogi2/9/2019
Contd…
• Illustration:
– For scan line 1
• The active edge list contains edges:
– AB,BC,EH, FG
• Between edges AB and BC, only flags for s1 = on and between edges
EH and FG, only flags for s2=on
• So, no depth calculation needed and corresponding surface intensities
are entered in refresh buffer
35By: Tekendra Nath Yogi2/9/2019
Contd..
• For scan line 2
– The active edge list contains edges:
• AD,EH,BC and FG
– Between edges AD and EH, only the flag for surface s1= on
– Between edges EH and BC flags for both surfaces = on
• Depth calculation (using plane coefficients) is needed.
• In this example ,say s2 is nearer to the view plane than s1, so intensities for surface s2 are
loaded into the refresh buffer until boundary BC is encountered
– Between edges BC and FG flag for s1=off and flag for s2 = on
• Intensities for s2 are loaded on refresh buffer
36By: Tekendra Nath Yogi2/9/2019
Contd..
• For scan line 3
– Same coherent property as scan line 2 as noticed from active list, so no
depth calculation needed between edges BC and EH
37By: Tekendra Nath Yogi2/9/2019
Contd…
• Problem: arise when surfaces cut through and cyclic overlap
• Solution: divide the surfaces (e.g. dashed lines) to eliminate overlap and cut
through
Fig: Intersecting and cyclically overlapping surfaces that alternately obscure one
another.
38By: Tekendra Nath Yogi2/9/2019
Contd….
• Area-subdivision Method:
– This visible surface detection algorithm is applied by
successively dividing the total view plane area into smaller and
smaller rectangles until each rectangle area contains either
• The projection of part of a single visible surface
• No surface projections
• Or the area has been reduced to the size of a pixel
39By: Tekendra Nath Yogi2/9/2019
Contd….
• Algorithm:
– divide image into 4 equal areas
– for each area (see tests below):
1. are all polygons disjoint from area? (test d)
• yes --> display background color
2. only one intersecting or contained polygon (tests b, c)
• yes --> fill with background color, and then draw contained polygon or intersecting portion
3. one single surrounding polygon, no intersecting or contained polygons (test a)
• yes --> draw area with that polygon's color
4. more than one polygon is intersecting, contained in, or surrounding, but only one
polygon is surrounding the area and is in front of others (test a)
• yes --> draw area with that front polygon's color
– ELSE --> subdivide the area into 4 equal areas and recurse
40By: Tekendra Nath Yogi2/9/2019
Contd….
E.g.,
41By: Tekendra Nath Yogi2/9/2019
Homework
• What are the object space and image space method of hidden surface removal?
Explain back surface detection method in detail with an example.
• Justify that hidden surface removal is required in computer graphics. Explain
in detail about depth buffer method.
• Explain in detail about depth buffer method. Justify that is better than plane
equation method.
• Explain in detail about scan line method for removing hidden surfaces. Just
that it is better than depth buffer method.
• Explain how BSP Tree method is used for hidden surface elimination
• Explain how area sub-division method is used for hidden surface elimination.
2/9/2019 42By: Tekendra Nath Yogi
Illumination models
• Introduction:
– A projection describes only where an object has to be drawn on the projection
plane.
– The determination of visible surfaces also focused only on the question which
objects should be drawn and which ones are hidden from view by others.
– The information where an object should be drawn on the projection plane is not
at all sufficient for a realistic representation of a 3D scene.
– Realistic displays of a scene are obtained by generating perspective projections
of objects and by applying natural lighting effects to the visible surfaces.
43By: Tekendra Nath Yogi2/9/2019
Contd….
• Illumination Model:
– Also called a lighting model or shading model
– Model for calculating light intensity at a single surface point.
– used to calculate the intensity of light that we should see at a given point on
the surface of an object.
• Surface Rendering methods:
– Also called surface-shading methods.
– defined as a procedure for applying a lighting model to obtain pixel
intensities for all the projected surface positions in a scene.
44By: Tekendra Nath Yogi2/9/2019
Contd….
• Light Sources:
• Light source is defined as an object that is emitting radiant
energy, such as a Light bulb or the sun.
– Two types of light sources:
• Point light source and
• Distributed light source
45By: Tekendra Nath Yogi2/9/2019
Contd..
• Point light source:
– The simplest model for a light emitter is a point source.
– Rays from the source follow radially diverging paths from the source position, as
shown in Figure below:
– This light-source model is a reasonable approximation for sources whose
dimensions are small compared to the size of objects in the scene.
– Sources, such as the sun, that are sufficiently far from the scene can be accurately
modeled as point sources.
Fig: Diverging ray paths from the point source
2/9/2019 46By: Tekendra Nath Yogi
Contd..
• Distributed light source:
– A nearby source, such as the long fluorescent light as shown in figure below is more
accurately modeled as a distributed light source.
– In this case, the illumination effects cannot be approximated realistically with a
point source, because the area of the source is not small compared to the surfaces in
the scene.
– An accurate model for the distributed source is one that considers the accumulated
illumination effects of the points over the surface of the source.
Fig: An object illuminated with a distributed light source
2/9/2019 47By: Tekendra Nath Yogi
Contd…
• Basic 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:
• Optical properties of surfaces, such as glossy, matte, opaque, and
transparent. This controls the amount of reflection and absorption
of incident light.
• The background lighting conditions.
• The light-source specifications. All light sources are considered to
be point sources, specified with a coordinate position and intensity
value (color).
2/9/2019 48By: Tekendra Nath Yogi
Contd..
• Ambient light :
– A surface that is not exposed directly to a light source still will be visible if
nearby objects are illuminated.
– The combination of light reflections from various surfaces produce a
uniform illumination called the ambient light, or background light.
– For example: Light in the Room.
– Ambient light has no spatial or directional characteristics.
– The amount of ambient light incident on each object is a constant for all surfaces and
over all directions.
– The amount of ambient light that is reflected by an object is independent of the
objects position or orientation and depends only on the optical properties of the
surface.
2/9/2019 49By: Tekendra Nath Yogi
Contd..
• The level of ambient light in a scene is a parameter Ia , and each surface
illuminated with this constant value.
• Illumination equation for ambient light is:
I = kaIa
where
I is the resulting intensity
Ia is the incident ambient light intensity
ka ambient- reflection coefficient. Ka ranges from 0 to 1.
2/9/2019 50By: Tekendra Nath Yogi
Contd…
• Ambient Light - Example
Fig. : An ambient illumination only.
2/9/2019 51By: Tekendra Nath Yogi
Contd..
• Diffuse Reflection:
– 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.
2/9/2019 52By: Tekendra Nath Yogi
Contd…
• The amount of Diffuse reflections(the brightness of the surface ) depends on:
– The amount of the incident light that is diffusely reflected (Il )
– diffuse-reflection coefficient, or diffuse reflectivity of the surface (kd).
• 0  kd  1;
• If kd is near 1 – then the surface highly reflective;
• If kd is near 0 – then the surface absorbs most of the incident light;
– orientation of the surface relative to the light source:
• As the angle between the surface normal and the incoming light direction()
increases, less of the incident light falls on the surface.
• If the incoming light from the source is perpendicular to the surface at a
particular point, that point is fully illuminated as shown in figure below.
• Thus, the amount of illumination depends on cos.
2/9/2019 53By: Tekendra Nath Yogi
Contd…
(a) (b)
Fig.
A surface perpendicular to the direction of the incident light (a) is more
illuminated than an equal-sized surface at an oblique angle (b) to the incoming
light direction.
2/9/2019 54By: Tekendra Nath Yogi
Contd…
• If Il is the intensity of the point Light source, then the diffuse reflection
equation for a point on the surface can be written As:
• Il,diff = kdIlcos or
• Il,diff = kdIl(N.L)
• where
• 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.
Fig.
Angle of incidence between the unit light-source
direction vector L and the unit surface normal N.
N
L
To Light Source

2/9/2019 55By: Tekendra Nath Yogi
Contd…
Figure below illustrates the illumination with diffuse reflection, using various
values of parameter kd between 0 and1.
Fig.: Series of pictures of sphere illuminated by diffuse reflection model only
using different kd values (0.4, 0.55, 0.7, 0.85,1.0).
2/9/2019 56By: Tekendra Nath Yogi
Contd….
• Total Diffuse Reflection:
– We can combine the ambient and point-source intensity calculations to
obtain an expression for the total diffuse reflection.
– Idiff = kaIa+kdIl(N.L)
– where both ka and kd depend on surface material properties and are assigned
values in the range from 0 to 1.
Fig. Series of pictures of sphere illuminated by ambient and diffuse reflection model.
Ia = Il = 1.0, kd = 0.4 and ka values (0.0, 0.15, 0.30, 0.45, 0.60).
2/9/2019 57By: Tekendra Nath Yogi
Contd…
• Specular Reflection:
– When we look at an illuminated shiny surface, such as polished metal,
we see a highlight, or bright spot, at certain viewing directions. This
phenomenon, 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.
2/9/2019 58
Figure: Specular Reflection
By: Tekendra Nath Yogi
Contd…
• Figure below shows the specular reflection direction at a point on the illuminated
surface.
In this figure,
– R represents the unit vector in the direction of specular reflection;
– L – unit vector directed toward the point light source;
– V – unit vector pointing to the viewer from the surface position;
– Angle  is the viewing angle relative to the specular-reflection direction R.
• shiny surfaces have a narrow specular- reflection range, and dull surfaces have a wider
reflection range. (i.e., for shiny surface = 0 and for rough surface  > 0 )
Fig. : Modeling specular reflection.
N
L
To Light Source
 
R
V
2/9/2019 59By: Tekendra Nath Yogi
Contd…
• Phong Specular Reflection Model (phong model):
– Phong model is a model for calculating the specular-reflection range:
• Sets the intensity of specular reflection proportional to cosns;
• Angle  can be assigned values in the range 0o to 90o, so that cos varies from 0 to
1;
• Specular-reflection parameter ns is determined by the type of surface that we want to
display.
– Very shiny surface is modeled with a large value for ns (say, 100 or more);
– Small values (down to 1) are used for duller surfaces.
– For perfect reflector (perfect mirror), ns is infinite;
• Specular-reflection coefficient ks equal to some value in the range 0 to 1 for each
surface.
2/9/2019 60By: Tekendra Nath Yogi
Contd…
N
L
R
Shiny Surface (Large ns)
N
L
R
Dull Surface (Small ns)
Fig. : Modeling specular reflection with parameter ns.
2/9/2019 61By: Tekendra Nath Yogi
Contd…
• The intensity of Phong specular-reflection model depends on the intensity of
the incident light, material properties of the surface and the angle of
incidence, so that intensity of the reflected light can be expressed as:
Ispec = ksIl cosns
• Since V and R are unit vectors in the viewing and specular-reflection
directions, we can calculate the value of cosns with the dot product V.R.
Ispec = ksIl (V.R)ns
Fig. : Modeling specular reflection.
N
L
To Light Source
 
R
V
2/9/2019 62By: Tekendra Nath Yogi
Contd…
• Phong Model Using Halfway vector:
– Simplified way of formulation of phong illumination model is the use of
halfway vector H.
– The halfway vector H = (L + V)/|(L + V)|
– The intensity for the specular reflection is:
Ispec = ksIl (N.H)ns
2/9/2019 63By: Tekendra Nath Yogi
Contd…
• Combine Diffuse & Specular Reflections:
– For a single point light source, we can model the combined diffuse and
specular reflections from a point on an illuminated surface as:
I = Idiff + Ispec
I = kaIa + kdIl(N.L) + ksIl(N.H)ns
2/9/2019 64By: Tekendra Nath Yogi
Contd….
• Combine Diffuse & Secular Reflections with Multiple Light
Sources :
– If we place more than one point source in a scene, we obtain the light
reflection at any surface point by summering the contributions from the
individual sources:
I = kaIa + n
i=1 Ili [kd (N.Li) + ks(N.Hi)ns]
2/9/2019 65By: Tekendra Nath Yogi
Light Intensity Attenuation
• As the light emitted from a light source travels through space, its intensity
decreases. This is called attenuation.
– Example: a traffic light will not be able to illuminate an object 2km away.
• The intensity is attenuated by the factor: l/d2 where, d is the distance that the
light has traveled.
• This means that a surface close to the light source (small d) receives a higher
incident intensity from the source than a distant surface (large d).
• Therefore, to produce realistic lighting effects, take this intensity attenuation
into account.
2/9/2019 66By: Tekendra Nath Yogi
Contd…
• Problem : Too much intensity variation for objects that are close to the light
source and too little intensity variation for object that are far away
– Solution: Use the following function instead
– The constants can be adjusted to produce better attenuation effects.
• Using this function, we can then write our basic illumination model as:
2/9/2019 67By: Tekendra Nath Yogi
Color considerations
• Most graphics displays of realistic scenes are in color. But the illumination
model we have described so far considers only monochromatic lighting
effects.
• To incorporate color, we need to write the intensity equation as a function
of the color properties of the light sources and object surfaces.
• For an RGB description, each color in a scene is expressed in terms of red,
green, and blue components.
• We then specify the RGB components of light source intensities and
surface colors, and the illumination model calculates the RGB components
of the reflected light.
2/9/2019 68By: Tekendra Nath Yogi
Contd..
• One way to set surface colors is by specifying the reflectivity
coefficients as three-element vectors.
• For Example:
– The diffuse reflection coefficient vector, have RGB components (kdR, k dC,
kdB).
– If we want an object to have a blue surface, we select a nonzero value in the
range from 0 to 1 for the blue reflectivity component, kdB while the red and
green reflectivity components are set to zero (kdR = kdG = 0).
– Any nonzero red or green components in the incident light are absorbed,
and only the blue component is reflected. The intensity calculation for this
example reduces to the single Expression:
2/9/2019 69By: Tekendra Nath Yogi
Transparency
• Transparent surface produces both reflected and transmitted light as shown in
figure below:
• The relative contribution of the transmitted light depends on the degree of
transparency of the surface(kt) and whether any light sources or illuminated
surfaces are behind the transparent surface.
2/9/2019 70By: Tekendra Nath Yogi
Contd…
• When a transparent surface is to be modeled, the intensity equations must be
include contributions from light passing through the surface.
• So, intensity equation becomes:
• Where, Itrans -> Transmitted intensity through a transparent surface.
• Irefl -> Reflected intensity from the transparent surface.
• Kt -> transparency coefficient , kt =1 for highly transparent objects and is 0
for highly opaque objects.
2/9/2019 By: Tekendra Nath Yogi 71
Contd..
• Transmitted intensity Itrans through a transparent surface from a background object
and Reflected intensity Irefl from the transparent surface with transparency
coefficient kt is given by:
• term (1 - kt) is the opacity factor. For highly transparent objects, we assign kt a
value near 1.
• Nearly opaque object transmits very little light from background object , and we
can set kt to a value near 0 for these materials (opacity near 1).
2/9/2019 72By: Tekendra Nath Yogi
shadows
• A shadow is a dark area where light from a light source is blocked by
an opaque object.
• Why shadows?
– Make image more realistic
– Visual clues as how objects are positioned with respect to each other.
• How shadows are generated?
– Hidden surface method with light source at the view position can be used
to produce shadows
Fig: Objects modeled with shadow regions.
2/9/2019 73
By: Tekendra Nath Yogi
Polygon (Surface) Rendering Method
• Rendering means giving proper intensities at each point in a
graphical object to make it look like a real world object.
• Application of an illumination model.
• Different Rendering methods are:
– Constant intensity shading
– Gouraud shading
– Phong shading
2/9/2019 74By: Tekendra Nath Yogi
Constant-Intensity Shading
• A fast and simple method for rendering an object with polygon
surfaces is constant-intensity shading, also called flat shading.
• Procedure
– take a point on the object surface and calculate the intensity at this point by
using a illumination model.
– All points over the surface of the object are then displayed with the same
intensity value.
– Repeat above procedure for each object surface.
2/9/2019 75By: Tekendra Nath Yogi
Contd..
• In general, 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 objects 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.
• Even if all of these conditions are not true, we can still reasonably approximate
surface-lighting effects using small polygon facets with flat shading and
calculate the intensity for each facet, say, at the center of the polygon.
• DRAWBACK: intensity discontinuity at the edges of polygons
2/9/2019 76By: Tekendra Nath Yogi
Gouraud Shading(Intensity Interpolation shading)
• This intensity-interpolation scheme, developed by Gouraud.
– 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.
• Each polygon surface is rendered with Gouraud shading by performing the
following calculations:
– Determine the average unit normal vector at each polygon vertex.
– Apply an illumination model to each vertex to calculate the vertex intensity.
– Linearly interpolate the vertex intensities over the surface of the polygon.
2/9/2019 77By: Tekendra Nath Yogi
Contd..
• Step1: Unit Normal Vector calculation:
– The normal vector at vertex V is calculated as the average of the surface
normals for each polygon sharing that vertex.
– E.g.,
2/9/2019 78By: Tekendra Nath Yogi
Contd..
• Step2: Vertex intensity calculation:
– Once we have the vertex normals, we can determine the intensity at the
vertices from a lighting model.
2/9/2019 79By: Tekendra Nath Yogi
Contd..
• Step3: Linearly interpolate the vertex intensities over the surface of the
polygon.
• Two step Process:
• Bounding Intensity calculation: Intensity calculation at the intersection
of the scan line with a polygon edge
• Interior intensity calculation
2/9/2019 80By: Tekendra Nath Yogi
Contd..
• Bounding Intensity calculation:
– 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.
2/9/2019 81By: Tekendra Nath Yogi
Contd..
– For the example in Figure below, 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:
– Similarly, intensity at the right intersection of this scan line (point 5)
is interpolated from intensity values at vertices 2 and 3.
2/9/2019 82By: Tekendra Nath Yogi
Contd..
• Interior intensity calculation: Once these bounding intensities are
established for a scan line, an interior point (such as point p in Fig.
above) is interpolated from the bounding intensities at points 4 and
5 as:
2/9/2019 83By: Tekendra Nath Yogi
Contd..
• Incremental calculations are used to obtain successive edge intensity values
between scan lines and to obtain successive intensities along a scan line. As
shown in Figure below:
• if the intensity at edge position (x, y) is interpolated as:
• then we can obtain the intensity along this edge for the next scan line, y - 1, as:
2/9/2019 84By: Tekendra Nath Yogi
Contd …
• Advantages:
– Gouraud shading removes the intensity discontinuities associated with the constant-shading
model.
• But it has some other deficiencies.
– Highlights 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.
• Solutions: These effects can be reduced by using Phong shading, that require
more calculations.
2/9/2019 85By: Tekendra Nath Yogi
Phong Shading(Normal Vector Interpolation 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.
• This method, developed by Phong Bui Tuong, is called Phong shading, or normalvector
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:
– 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.
2/9/2019 86By: Tekendra Nath Yogi
Contd..
• Interpolation of surface normals along a polygon edge between two vertices is
illustrated in Figure below:
Fig: Interpolation of surface normal along a polygon edge
• 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:
2/9/2019 87By: Tekendra Nath Yogi
Gouraud versus Phong Shading
• Gouraud shading is faster than Phong shading
• Phong shading is more accurate
2/9/2019 88By: Tekendra Nath Yogi
Homework
• Explain in detail about diffuse reflection model.
• Difference between diffuse reflection and specular reflection. Why do we require shading
model? Explain it.
• Explain the visible effect that occurs when during animation of a Gouraud shading
polyhedron, the center of a highlight moves from one vertex to another along an edge.
• Why shading is required in the computer graphics? Explain in detail about constant intensity
shading.
• Explain in detail about Phong shading. How can you modify Phong shading model?
• Explain in detail about Gourand shading model. Compare it with Phong shading model.
• Explain in detail about Phong shading model. Compare it with Gouraud Shading model.
2/9/2019 89By: Tekendra Nath Yogi
Thank You !
90By: Tekendra Nath Yogi2/9/2019

More Related Content

What's hot

3 d viewing projection
3 d viewing  projection3 d viewing  projection
3 d viewing projectionPooja Dixit
 
Scan line method
Scan line methodScan line method
Scan line methodPooja Dixit
 
3 d transformation
3 d transformation3 d transformation
3 d transformationPooja Dixit
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer GraphicsAnkur Soni
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingAnkit Garg
 
B. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath YogiTekendra Nath Yogi
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphicanku2266
 
Unit 3
Unit 3Unit 3
Unit 3ypnrao
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer GraphicsSanu Philip
 
Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Iftikhar Ahmad
 
3D Transformation
3D Transformation3D Transformation
3D TransformationSwatiHans10
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithmKKARUNKARTHIK
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notessmruti sarangi
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSnehrurevathy
 
B. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Lab By Tekendra Nath YogiB. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Lab By Tekendra Nath YogiTekendra Nath Yogi
 
Computer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displaysComputer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displaysVishnupriya T H
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)Timbal Mayank
 

What's hot (20)

3 d viewing projection
3 d viewing  projection3 d viewing  projection
3 d viewing projection
 
Scan line method
Scan line methodScan line method
Scan line method
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
B. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.1 By Tekendra Nath Yogi
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Unit 3
Unit 3Unit 3
Unit 3
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICS
 
B. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Lab By Tekendra Nath YogiB. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi
 
Computer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displaysComputer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displays
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - Shading
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 

Similar to B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi

B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath YogiTekendra Nath Yogi
 
Visible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptx
Visible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptxVisible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptx
Visible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptxJeoJoyA
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmrajivagarwal23dei
 
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...rohitjasudkar
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsJoseph Charles
 
Visible surface determination
Visible  surface determinationVisible  surface determination
Visible surface determinationPatel Punit
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identificationPooja Dixit
 
Hidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferHidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferRaj Sikarwar
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unitaravindangc
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalAnkit Garg
 
visible surface detection in 3D objects for viewing
visible surface detection in 3D objects for viewingvisible surface detection in 3D objects for viewing
visible surface detection in 3D objects for viewingsrinivasan779644
 
Unit 3 visual realism
Unit 3 visual realismUnit 3 visual realism
Unit 3 visual realismJavith Saleem
 
visual realism Unit iii
 visual realism Unit iii visual realism Unit iii
visual realism Unit iiiArun Prakash
 
rural marketing ppt
rural marketing pptrural marketing ppt
rural marketing pptelaya1984
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection ielaya1984
 
3 d display-methods-in-computer-graphics(For DIU)
3 d display-methods-in-computer-graphics(For DIU)3 d display-methods-in-computer-graphics(For DIU)
3 d display-methods-in-computer-graphics(For DIU)Rajon rdx
 

Similar to B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi (20)

B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi
 
Visible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptx
Visible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptxVisible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptx
Visible Surfacte Detection Methods - Z-Buffer and Scanline methods.pptx
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
 
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methods
 
Visible surface determination
Visible  surface determinationVisible  surface determination
Visible surface determination
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identification
 
Hidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferHidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-buffer
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
visible surface detection in 3D objects for viewing
visible surface detection in 3D objects for viewingvisible surface detection in 3D objects for viewing
visible surface detection in 3D objects for viewing
 
Unit 3 visual realism
Unit 3 visual realismUnit 3 visual realism
Unit 3 visual realism
 
Sr 01-40 good
Sr 01-40 goodSr 01-40 good
Sr 01-40 good
 
visual realism Unit iii
 visual realism Unit iii visual realism Unit iii
visual realism Unit iii
 
3 d
3 d3 d
3 d
 
rural marketing ppt
rural marketing pptrural marketing ppt
rural marketing ppt
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection i
 
3 d display-methods-in-computer-graphics(For DIU)
3 d display-methods-in-computer-graphics(For DIU)3 d display-methods-in-computer-graphics(For DIU)
3 d display-methods-in-computer-graphics(For DIU)
 
Darkonoid
DarkonoidDarkonoid
Darkonoid
 

More from Tekendra Nath Yogi

More from Tekendra Nath Yogi (20)

Unit9:Expert System
Unit9:Expert SystemUnit9:Expert System
Unit9:Expert System
 
Unit7: Production System
Unit7: Production SystemUnit7: Production System
Unit7: Production System
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
 
Unit5: Learning
Unit5: LearningUnit5: Learning
Unit5: Learning
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
 
Unit2: Agents and Environment
Unit2: Agents and EnvironmentUnit2: Agents and Environment
Unit2: Agents and Environment
 
Unit1: Introduction to AI
Unit1: Introduction to AIUnit1: Introduction to AI
Unit1: Introduction to AI
 
Unit 6: Application of AI
Unit 6: Application of AIUnit 6: Application of AI
Unit 6: Application of AI
 
Unit10
Unit10Unit10
Unit10
 
Unit9
Unit9Unit9
Unit9
 
Unit8
Unit8Unit8
Unit8
 
Unit7
Unit7Unit7
Unit7
 
BIM Data Mining Unit5 by Tekendra Nath Yogi
 BIM Data Mining Unit5 by Tekendra Nath Yogi BIM Data Mining Unit5 by Tekendra Nath Yogi
BIM Data Mining Unit5 by Tekendra Nath Yogi
 
BIM Data Mining Unit4 by Tekendra Nath Yogi
 BIM Data Mining Unit4 by Tekendra Nath Yogi BIM Data Mining Unit4 by Tekendra Nath Yogi
BIM Data Mining Unit4 by Tekendra Nath Yogi
 
BIM Data Mining Unit3 by Tekendra Nath Yogi
 BIM Data Mining Unit3 by Tekendra Nath Yogi BIM Data Mining Unit3 by Tekendra Nath Yogi
BIM Data Mining Unit3 by Tekendra Nath Yogi
 
BIM Data Mining Unit2 by Tekendra Nath Yogi
 BIM Data Mining Unit2 by Tekendra Nath Yogi BIM Data Mining Unit2 by Tekendra Nath Yogi
BIM Data Mining Unit2 by Tekendra Nath Yogi
 
BIM Data Mining Unit1 by Tekendra Nath Yogi
 BIM Data Mining Unit1 by Tekendra Nath Yogi BIM Data Mining Unit1 by Tekendra Nath Yogi
BIM Data Mining Unit1 by Tekendra Nath Yogi
 
Unit6
Unit6Unit6
Unit6
 
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi

  • 1. Unit 4:Visible surface detection methods, Illumination models and surface rendering methods Presented By : Tekendra Nath Yogi Tekendranath@gmail.com College Of Applied Business And Technology
  • 2. Outline • Unit 4. 12 Hrs. – Visible Surface Determination: • Various Techniques • Algorithms for Visible Surface Detection, (Z- Buffer, List priority, Scan Line Algorithms) – Illumination models. • Ambient light • Diffuse reflection • Specular reflection • Light intensity attenuation • Color consideration • Transparency • shadows – Surface Shading Methods/surface Rendering Methods • Constant intensity shading • Gouraud • Phong Shading 2By: Tekendra Nath Yogi2/9/2019
  • 3. Visible surface determination/ Hidden surface Elimination methods • For the generation of realistic graphics display. We have to identify those parts of a scene that are visible from a chosen viewing position. • To solve this problem different algorithms are used called the visible surface detection or hidden surface elimination algorithms. • These algorithms determines the lines, edges, or surfaces that are visible or invisible to an observer located at a specific point in space. • So, that we can display only the visible lines or surfaces to produce realistic display. 3By: Tekendra Nath Yogi2/9/2019
  • 4. Contd…. • Visible surface detection algorithms are broadly classified according to whether they deal with object definitions directly or with their projected images. These two approaches are called: – Object space methods and – Image space methods. 4By: Tekendra Nath Yogi2/9/2019
  • 5. Contd…. Pseudo code for Image space Method for(each pixel in the image) determine the object closest to the viewer that is penetrated by the projector through the pixel; draw the pixel in the appropriate color; Ex: Depth buffer method Pseudo code for Object space Method for(each object in the world) determine those parts of the object whose view is not blocked by other parts of it or any other object; draw those parts in the appropriate color; Ex: Back-face detection method Image space methods are by far the more common! 5By: Tekendra Nath Yogi2/9/2019
  • 6. Contd…. • Algorithms for Visible surface detection: – Back face detection (plane equation method) – z-buffer Algorithm(Depth buffer method) – List Priority algorithm – Scan Line Algorithm 6By: Tekendra Nath Yogi2/9/2019
  • 7. Back face detection (plane equation method) • It is fast and simple object-space method for identifying the back-faces of polyhedron which is based on the inside –outside test. • A point (x, y, z) is inside a polygon surface if Ax+By+Cz+ D <0 • When an inside point is along the line of sight to the surface , the polygon must be a back face • We simplify this test by considering the normal vector N to a polygon surface which has Cartesian component (A,B,C). • If V is vector in viewing direction from the eye position then this polygon is back face if 2/9/2019 7 faceback:0NV VN By: Tekendra Nath Yogi
  • 8. 2/9/2019 8 • If the object descriptions have been converted to a projection coordinates and viewing direction is parallel to the viewing Zv axis then V= (0,0,Vz) and V.N= Vz . C • If viewing direction along negative Zv axis the polygon is back face if C<0 • If viewing direction along positive Zv axis , then polygon is back surface if C>0 Limitation: • It cannot be applicable for all case like overlapping case such as two faces of single object is overlapping Contd…. By: Tekendra Nath Yogi
  • 9. Depth Buffer (Z- buffer)Method • A commonly used image-space approach to detecting visible surfaces . It is developed by CutMull in 1974. • This method compares surface depths at each pixel position on the projection plane • Each surface of a scene is processed separately, one point at a time across the surface. • object depth is measured from the view plane along the z axis of a viewing system. • The Z buffer algorithm is usually implemented in the normalized coordinates , so that Z values range form 0 at the back clipping plane to 1 at the front clipping plane. 9By: Tekendra Nath Yogi2/9/2019
  • 10. Contd…. • Two buffers required – Depth buffer: • to store depth value for each (x, y) position as surfaces are processed • Initially set to 0, representing the z- value at the back clipping plane . – Refresh buffer: • to store intensity values of each (x, y) position as surfaces processed. • Initially refresh buffer is initialized to background intensity 10By: Tekendra Nath Yogi2/9/2019
  • 11. Contd… • At viewing plane position (x, y), surface S1 has the smallest depth( means have highest Z value in normalized coordinate.) from the view plane and so is visible at top position 11By: Tekendra Nath Yogi2/9/2019
  • 12. Contd…. • Algorithm: 1. Initialize the depth buffer and refresh buffer so that for all buffer positions (x,y) depth(x, y) = 0, refresh(x, y) = Ibackground 2. For each position on each polygon surface, compare depth values to previously stored values in depth buffer to determine visibility. ● Calculate the depth z for each (x,y) position on the polygon. ● If z >depth(x,y), then depth(x, y) = z, refresh(x, y) = Isurf(x,y). where, Ibackground is the value for the bacground intensity and Isurf(x,y), is the projected intensity value for the surface at (x,y).  After all surfaces have been processed, the depth buffer contains depth values for the visible surfaces and the refresh buffer contains the corresponding intensity values for those surfaces. 12By: Tekendra Nath Yogi2/9/2019
  • 14. Contd…. • Example: Let us consider two surfaces present in the scene as shown in fig below 14By: Tekendra Nath Yogi2/9/2019
  • 15. Contd…. • Step 1: Initialize the depth buffer 15By: Tekendra Nath Yogi2/9/2019
  • 16. Contd…. • Step 2: Draw the polygon with depth 0.3 16By: Tekendra Nath Yogi2/9/2019
  • 17. Contd…. • Step 3: Draw the polygon with depth 0.5 17By: Tekendra Nath Yogi2/9/2019
  • 18. Contd…. • Advantages: – For polygon surfaces, the depth buffer method is very easy to implement, and it requires no sorting of the surfaces in a scene. – It can be implemented in hardware to overcome the speed problem. • Disadvantages: – It requires an additional buffer and hence the large memory. – It is a time consuming process as it requires comparison of each pixel instead of for the entire polygon. 18By: Tekendra Nath Yogi2/9/2019
  • 19. List Priority Algorithms • List-Priority-Algorithms determine a visibility ordering for objects ensuring that a correct picture results if the objects are rendered in that order. • E.g. if no object overlap another in z, then we need to sort the objects by increasing z and render them in that order. • The types of LPA algorithms – Depth Sorting Algorithms – Binary Space Partitioning Trees 19By: Tekendra Nath Yogi2/9/2019
  • 20. Contd…. • Depth Sorting Algorithms (painter’s Algorithm): Each layer of paint covers up the previous layer. – i.e., first paints the background colors – Next, the most distant objects are added, then the nearer objects, and so forth – At the final step, the foreground objects are painted on the canvas 20By: Tekendra Nath Yogi2/9/2019
  • 21. Contd…. • Depth sorting algorithm uses the similar technique: paint the surface intensity into the frame buffer in order of decreasing distance from the viewpoint. • Three steps: 1. Sort all surfaces according to the smallest (farthest from view plane) z coordinate value on each surface. 2. Resolve if any ambiguities( e.g., polygon’s z extents overlap->splitting polygons if necessary). 3. Scan convert each polygon in ascending order of smallest z coordinate.(i.e. back to front). 21By: Tekendra Nath Yogi2/9/2019
  • 22. Contd…. • For scan conversion make the following tests for each surface that overlaps with S. • If any one of these tests is true, no reordering is necessary for that surface. – The bounding rectangles in the xy plane for the two surfaces do not overlap – Surface S is completely behind the overlapping surface relative to the viewing position. – The overlapping surface is completely in front of S relative to the viewing position. – The projections of the two surfaces onto the view plane do not overlap. 22By: Tekendra Nath Yogi2/9/2019
  • 23. Test #1 • The boundary rectangles (minimum closed rectangles for the surfaces) in the xy-plane for the two surfaces do not overlap. • Test # 1 is passed, scan convert S2 and then S1. Because, S2 has the highest depth. 23By: Tekendra Nath Yogi2/9/2019
  • 24. Test #2 • Surface S1 is completely behind the overlapping surface S2 relative to the viewing position. • S1 is scan converted first, then S2 is scan converted. 24By: Tekendra Nath Yogi2/9/2019
  • 25. Test #3 • The overlapping surface S2 is completely in front of S1 relative to the viewing position. • S1 is not completely behind S2. So, Test #2 fails. • S1 is scan converted first. 25 In figure, S2 is in front of S1, but S1 is not completely inside/behind S2 Test #2 is not true or fails, although Test #3 is true. By: Tekendra Nath Yogi2/9/2019
  • 26. Test #4 • Bounding rectangles overlap but the projections of the two surfaces onto the view plane do not overlap. • Use plane equations and test for intersection if no intersection then scan convert s1 first and s2 next. • Note: all the tests are failed in second figure. 26 Test #4 passed for the first figure but it fails for the second figure. By: Tekendra Nath Yogi2/9/2019
  • 27. Continue Test #4.. • Case Study-1 Non of the tests are true, so we have to reorder the sequence of the surfaces. 27 Initial Order: S1->S2 Change the order: S2->S1 By: Tekendra Nath Yogi2/9/2019
  • 28. Continue.. • Case Study 2: Initial order: S1->S2->S3 Because S1 has the Maximum depth, then S2 has the maximum depth and lastly S3 but painters logic fails. S1->S2: Test #1 passed. Check for S1 and S3 : All Tests fails. Now, interchanging S3->S2->S1. Check S2 and S3, all tests fail again. Correct order is by swapping S2 and S3 position: S2->S3->S1 28By: Tekendra Nath Yogi2/9/2019
  • 29. Continue.. • Process of checking the order results in an infinite loop. • So avoiding infinite loop any of the polygon is clipped or split. 29By: Tekendra Nath Yogi2/9/2019
  • 30. Contd…. • BSP-Tree Method: – Binary space partitioning method is one of the efficient method for determining object visibility – Paint the surfaces onto the frame buffer from back to front. – Particularly useful when the view reference point changes, but the objects in a scene are at fixed positions. 30By: Tekendra Nath Yogi2/9/2019
  • 31. Contd…. • To Build a BSP Tree : 1. Choose a polygon plane Pi, and compute the equation of the plane it defines. 2. Test all the vertices of all the other polygons to determine if they are in front of, behind, or in the same plane as Pi. If the plane intersects a polygon, divide the polygon at the plane. 3. Polygons are placed into a binary search tree with Pi as the root. 4. Call the procedure recursively on the left and right sub-tree. When the BSP Tree is complete, we process the tree by selecting the surfaces for display in the order back to front. 31By: Tekendra Nath Yogi2/9/2019
  • 33. Contd…. • Scan Line Algorithm: • Extension of the scan-line algorithm for filling polygon interiors. • In this method, as each scan line is processed, all polygon surfaces intersecting that lines are examined to determine which are visible. • Across each scan line, depth calculations are made for each overlapping surface to determine which is nearest to the view plane. • When the visible surface has been determined, the intensity value for that position is entered into the refresh buffer. 33By: Tekendra Nath Yogi2/9/2019
  • 34. Contd… Algorithm: 1. Initialize the necessary data structure a. Edge table containing end point coordinates, slope and polygon pointer. b. Surface table containing plane coefficients and surface intensity c. Active Edge List, keep a trace of which edges are intersected by the given scan line d. Flag for each surface (on entry of scan set on, on exit set off) 2. For each scan line repeat a. update active edge list b. determine point of intersection and set surface on or off. c. If flag is on, store its Intensity value in the refresh buffer d. If more than one surface is on, do depth sorting and store the intensity of surface nearest to view plane in the refresh buffer 34By: Tekendra Nath Yogi2/9/2019
  • 35. Contd… • Illustration: – For scan line 1 • The active edge list contains edges: – AB,BC,EH, FG • Between edges AB and BC, only flags for s1 = on and between edges EH and FG, only flags for s2=on • So, no depth calculation needed and corresponding surface intensities are entered in refresh buffer 35By: Tekendra Nath Yogi2/9/2019
  • 36. Contd.. • For scan line 2 – The active edge list contains edges: • AD,EH,BC and FG – Between edges AD and EH, only the flag for surface s1= on – Between edges EH and BC flags for both surfaces = on • Depth calculation (using plane coefficients) is needed. • In this example ,say s2 is nearer to the view plane than s1, so intensities for surface s2 are loaded into the refresh buffer until boundary BC is encountered – Between edges BC and FG flag for s1=off and flag for s2 = on • Intensities for s2 are loaded on refresh buffer 36By: Tekendra Nath Yogi2/9/2019
  • 37. Contd.. • For scan line 3 – Same coherent property as scan line 2 as noticed from active list, so no depth calculation needed between edges BC and EH 37By: Tekendra Nath Yogi2/9/2019
  • 38. Contd… • Problem: arise when surfaces cut through and cyclic overlap • Solution: divide the surfaces (e.g. dashed lines) to eliminate overlap and cut through Fig: Intersecting and cyclically overlapping surfaces that alternately obscure one another. 38By: Tekendra Nath Yogi2/9/2019
  • 39. Contd…. • Area-subdivision Method: – This visible surface detection algorithm is applied by successively dividing the total view plane area into smaller and smaller rectangles until each rectangle area contains either • The projection of part of a single visible surface • No surface projections • Or the area has been reduced to the size of a pixel 39By: Tekendra Nath Yogi2/9/2019
  • 40. Contd…. • Algorithm: – divide image into 4 equal areas – for each area (see tests below): 1. are all polygons disjoint from area? (test d) • yes --> display background color 2. only one intersecting or contained polygon (tests b, c) • yes --> fill with background color, and then draw contained polygon or intersecting portion 3. one single surrounding polygon, no intersecting or contained polygons (test a) • yes --> draw area with that polygon's color 4. more than one polygon is intersecting, contained in, or surrounding, but only one polygon is surrounding the area and is in front of others (test a) • yes --> draw area with that front polygon's color – ELSE --> subdivide the area into 4 equal areas and recurse 40By: Tekendra Nath Yogi2/9/2019
  • 42. Homework • What are the object space and image space method of hidden surface removal? Explain back surface detection method in detail with an example. • Justify that hidden surface removal is required in computer graphics. Explain in detail about depth buffer method. • Explain in detail about depth buffer method. Justify that is better than plane equation method. • Explain in detail about scan line method for removing hidden surfaces. Just that it is better than depth buffer method. • Explain how BSP Tree method is used for hidden surface elimination • Explain how area sub-division method is used for hidden surface elimination. 2/9/2019 42By: Tekendra Nath Yogi
  • 43. Illumination models • Introduction: – A projection describes only where an object has to be drawn on the projection plane. – The determination of visible surfaces also focused only on the question which objects should be drawn and which ones are hidden from view by others. – The information where an object should be drawn on the projection plane is not at all sufficient for a realistic representation of a 3D scene. – Realistic displays of a scene are obtained by generating perspective projections of objects and by applying natural lighting effects to the visible surfaces. 43By: Tekendra Nath Yogi2/9/2019
  • 44. Contd…. • Illumination Model: – Also called a lighting model or shading model – Model for calculating light intensity at a single surface point. – used to calculate the intensity of light that we should see at a given point on the surface of an object. • Surface Rendering methods: – Also called surface-shading methods. – defined as a procedure for applying a lighting model to obtain pixel intensities for all the projected surface positions in a scene. 44By: Tekendra Nath Yogi2/9/2019
  • 45. Contd…. • Light Sources: • Light source is defined as an object that is emitting radiant energy, such as a Light bulb or the sun. – Two types of light sources: • Point light source and • Distributed light source 45By: Tekendra Nath Yogi2/9/2019
  • 46. Contd.. • Point light source: – The simplest model for a light emitter is a point source. – Rays from the source follow radially diverging paths from the source position, as shown in Figure below: – This light-source model is a reasonable approximation for sources whose dimensions are small compared to the size of objects in the scene. – Sources, such as the sun, that are sufficiently far from the scene can be accurately modeled as point sources. Fig: Diverging ray paths from the point source 2/9/2019 46By: Tekendra Nath Yogi
  • 47. Contd.. • Distributed light source: – A nearby source, such as the long fluorescent light as shown in figure below is more accurately modeled as a distributed light source. – In this case, the illumination effects cannot be approximated realistically with a point source, because the area of the source is not small compared to the surfaces in the scene. – An accurate model for the distributed source is one that considers the accumulated illumination effects of the points over the surface of the source. Fig: An object illuminated with a distributed light source 2/9/2019 47By: Tekendra Nath Yogi
  • 48. Contd… • Basic 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: • Optical properties of surfaces, such as glossy, matte, opaque, and transparent. This controls the amount of reflection and absorption of incident light. • The background lighting conditions. • The light-source specifications. All light sources are considered to be point sources, specified with a coordinate position and intensity value (color). 2/9/2019 48By: Tekendra Nath Yogi
  • 49. Contd.. • Ambient light : – A surface that is not exposed directly to a light source still will be visible if nearby objects are illuminated. – The combination of light reflections from various surfaces produce a uniform illumination called the ambient light, or background light. – For example: Light in the Room. – Ambient light has no spatial or directional characteristics. – The amount of ambient light incident on each object is a constant for all surfaces and over all directions. – The amount of ambient light that is reflected by an object is independent of the objects position or orientation and depends only on the optical properties of the surface. 2/9/2019 49By: Tekendra Nath Yogi
  • 50. Contd.. • The level of ambient light in a scene is a parameter Ia , and each surface illuminated with this constant value. • Illumination equation for ambient light is: I = kaIa where I is the resulting intensity Ia is the incident ambient light intensity ka ambient- reflection coefficient. Ka ranges from 0 to 1. 2/9/2019 50By: Tekendra Nath Yogi
  • 51. Contd… • Ambient Light - Example Fig. : An ambient illumination only. 2/9/2019 51By: Tekendra Nath Yogi
  • 52. Contd.. • Diffuse Reflection: – 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. 2/9/2019 52By: Tekendra Nath Yogi
  • 53. Contd… • The amount of Diffuse reflections(the brightness of the surface ) depends on: – The amount of the incident light that is diffusely reflected (Il ) – diffuse-reflection coefficient, or diffuse reflectivity of the surface (kd). • 0  kd  1; • If kd is near 1 – then the surface highly reflective; • If kd is near 0 – then the surface absorbs most of the incident light; – orientation of the surface relative to the light source: • As the angle between the surface normal and the incoming light direction() increases, less of the incident light falls on the surface. • If the incoming light from the source is perpendicular to the surface at a particular point, that point is fully illuminated as shown in figure below. • Thus, the amount of illumination depends on cos. 2/9/2019 53By: Tekendra Nath Yogi
  • 54. Contd… (a) (b) Fig. A surface perpendicular to the direction of the incident light (a) is more illuminated than an equal-sized surface at an oblique angle (b) to the incoming light direction. 2/9/2019 54By: Tekendra Nath Yogi
  • 55. Contd… • If Il is the intensity of the point Light source, then the diffuse reflection equation for a point on the surface can be written As: • Il,diff = kdIlcos or • Il,diff = kdIl(N.L) • where • 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. Fig. Angle of incidence between the unit light-source direction vector L and the unit surface normal N. N L To Light Source  2/9/2019 55By: Tekendra Nath Yogi
  • 56. Contd… Figure below illustrates the illumination with diffuse reflection, using various values of parameter kd between 0 and1. Fig.: Series of pictures of sphere illuminated by diffuse reflection model only using different kd values (0.4, 0.55, 0.7, 0.85,1.0). 2/9/2019 56By: Tekendra Nath Yogi
  • 57. Contd…. • Total Diffuse Reflection: – We can combine the ambient and point-source intensity calculations to obtain an expression for the total diffuse reflection. – Idiff = kaIa+kdIl(N.L) – where both ka and kd depend on surface material properties and are assigned values in the range from 0 to 1. Fig. Series of pictures of sphere illuminated by ambient and diffuse reflection model. Ia = Il = 1.0, kd = 0.4 and ka values (0.0, 0.15, 0.30, 0.45, 0.60). 2/9/2019 57By: Tekendra Nath Yogi
  • 58. Contd… • Specular Reflection: – When we look at an illuminated shiny surface, such as polished metal, we see a highlight, or bright spot, at certain viewing directions. This phenomenon, 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. 2/9/2019 58 Figure: Specular Reflection By: Tekendra Nath Yogi
  • 59. Contd… • Figure below shows the specular reflection direction at a point on the illuminated surface. In this figure, – R represents the unit vector in the direction of specular reflection; – L – unit vector directed toward the point light source; – V – unit vector pointing to the viewer from the surface position; – Angle  is the viewing angle relative to the specular-reflection direction R. • shiny surfaces have a narrow specular- reflection range, and dull surfaces have a wider reflection range. (i.e., for shiny surface = 0 and for rough surface  > 0 ) Fig. : Modeling specular reflection. N L To Light Source   R V 2/9/2019 59By: Tekendra Nath Yogi
  • 60. Contd… • Phong Specular Reflection Model (phong model): – Phong model is a model for calculating the specular-reflection range: • Sets the intensity of specular reflection proportional to cosns; • Angle  can be assigned values in the range 0o to 90o, so that cos varies from 0 to 1; • Specular-reflection parameter ns is determined by the type of surface that we want to display. – Very shiny surface is modeled with a large value for ns (say, 100 or more); – Small values (down to 1) are used for duller surfaces. – For perfect reflector (perfect mirror), ns is infinite; • Specular-reflection coefficient ks equal to some value in the range 0 to 1 for each surface. 2/9/2019 60By: Tekendra Nath Yogi
  • 61. Contd… N L R Shiny Surface (Large ns) N L R Dull Surface (Small ns) Fig. : Modeling specular reflection with parameter ns. 2/9/2019 61By: Tekendra Nath Yogi
  • 62. Contd… • The intensity of Phong specular-reflection model depends on the intensity of the incident light, material properties of the surface and the angle of incidence, so that intensity of the reflected light can be expressed as: Ispec = ksIl cosns • Since V and R are unit vectors in the viewing and specular-reflection directions, we can calculate the value of cosns with the dot product V.R. Ispec = ksIl (V.R)ns Fig. : Modeling specular reflection. N L To Light Source   R V 2/9/2019 62By: Tekendra Nath Yogi
  • 63. Contd… • Phong Model Using Halfway vector: – Simplified way of formulation of phong illumination model is the use of halfway vector H. – The halfway vector H = (L + V)/|(L + V)| – The intensity for the specular reflection is: Ispec = ksIl (N.H)ns 2/9/2019 63By: Tekendra Nath Yogi
  • 64. Contd… • Combine Diffuse & Specular Reflections: – For a single point light source, we can model the combined diffuse and specular reflections from a point on an illuminated surface as: I = Idiff + Ispec I = kaIa + kdIl(N.L) + ksIl(N.H)ns 2/9/2019 64By: Tekendra Nath Yogi
  • 65. Contd…. • Combine Diffuse & Secular Reflections with Multiple Light Sources : – If we place more than one point source in a scene, we obtain the light reflection at any surface point by summering the contributions from the individual sources: I = kaIa + n i=1 Ili [kd (N.Li) + ks(N.Hi)ns] 2/9/2019 65By: Tekendra Nath Yogi
  • 66. Light Intensity Attenuation • As the light emitted from a light source travels through space, its intensity decreases. This is called attenuation. – Example: a traffic light will not be able to illuminate an object 2km away. • The intensity is attenuated by the factor: l/d2 where, d is the distance that the light has traveled. • This means that a surface close to the light source (small d) receives a higher incident intensity from the source than a distant surface (large d). • Therefore, to produce realistic lighting effects, take this intensity attenuation into account. 2/9/2019 66By: Tekendra Nath Yogi
  • 67. Contd… • Problem : Too much intensity variation for objects that are close to the light source and too little intensity variation for object that are far away – Solution: Use the following function instead – The constants can be adjusted to produce better attenuation effects. • Using this function, we can then write our basic illumination model as: 2/9/2019 67By: Tekendra Nath Yogi
  • 68. Color considerations • Most graphics displays of realistic scenes are in color. But the illumination model we have described so far considers only monochromatic lighting effects. • To incorporate color, we need to write the intensity equation as a function of the color properties of the light sources and object surfaces. • For an RGB description, each color in a scene is expressed in terms of red, green, and blue components. • We then specify the RGB components of light source intensities and surface colors, and the illumination model calculates the RGB components of the reflected light. 2/9/2019 68By: Tekendra Nath Yogi
  • 69. Contd.. • One way to set surface colors is by specifying the reflectivity coefficients as three-element vectors. • For Example: – The diffuse reflection coefficient vector, have RGB components (kdR, k dC, kdB). – If we want an object to have a blue surface, we select a nonzero value in the range from 0 to 1 for the blue reflectivity component, kdB while the red and green reflectivity components are set to zero (kdR = kdG = 0). – Any nonzero red or green components in the incident light are absorbed, and only the blue component is reflected. The intensity calculation for this example reduces to the single Expression: 2/9/2019 69By: Tekendra Nath Yogi
  • 70. Transparency • Transparent surface produces both reflected and transmitted light as shown in figure below: • The relative contribution of the transmitted light depends on the degree of transparency of the surface(kt) and whether any light sources or illuminated surfaces are behind the transparent surface. 2/9/2019 70By: Tekendra Nath Yogi
  • 71. Contd… • When a transparent surface is to be modeled, the intensity equations must be include contributions from light passing through the surface. • So, intensity equation becomes: • Where, Itrans -> Transmitted intensity through a transparent surface. • Irefl -> Reflected intensity from the transparent surface. • Kt -> transparency coefficient , kt =1 for highly transparent objects and is 0 for highly opaque objects. 2/9/2019 By: Tekendra Nath Yogi 71
  • 72. Contd.. • Transmitted intensity Itrans through a transparent surface from a background object and Reflected intensity Irefl from the transparent surface with transparency coefficient kt is given by: • term (1 - kt) is the opacity factor. For highly transparent objects, we assign kt a value near 1. • Nearly opaque object transmits very little light from background object , and we can set kt to a value near 0 for these materials (opacity near 1). 2/9/2019 72By: Tekendra Nath Yogi
  • 73. shadows • A shadow is a dark area where light from a light source is blocked by an opaque object. • Why shadows? – Make image more realistic – Visual clues as how objects are positioned with respect to each other. • How shadows are generated? – Hidden surface method with light source at the view position can be used to produce shadows Fig: Objects modeled with shadow regions. 2/9/2019 73 By: Tekendra Nath Yogi
  • 74. Polygon (Surface) Rendering Method • Rendering means giving proper intensities at each point in a graphical object to make it look like a real world object. • Application of an illumination model. • Different Rendering methods are: – Constant intensity shading – Gouraud shading – Phong shading 2/9/2019 74By: Tekendra Nath Yogi
  • 75. Constant-Intensity Shading • A fast and simple method for rendering an object with polygon surfaces is constant-intensity shading, also called flat shading. • Procedure – take a point on the object surface and calculate the intensity at this point by using a illumination model. – All points over the surface of the object are then displayed with the same intensity value. – Repeat above procedure for each object surface. 2/9/2019 75By: Tekendra Nath Yogi
  • 76. Contd.. • In general, 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 objects 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. • Even if all of these conditions are not true, we can still reasonably approximate surface-lighting effects using small polygon facets with flat shading and calculate the intensity for each facet, say, at the center of the polygon. • DRAWBACK: intensity discontinuity at the edges of polygons 2/9/2019 76By: Tekendra Nath Yogi
  • 77. Gouraud Shading(Intensity Interpolation shading) • This intensity-interpolation scheme, developed by Gouraud. – 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. • Each polygon surface is rendered with Gouraud shading by performing the following calculations: – Determine the average unit normal vector at each polygon vertex. – Apply an illumination model to each vertex to calculate the vertex intensity. – Linearly interpolate the vertex intensities over the surface of the polygon. 2/9/2019 77By: Tekendra Nath Yogi
  • 78. Contd.. • Step1: Unit Normal Vector calculation: – The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex. – E.g., 2/9/2019 78By: Tekendra Nath Yogi
  • 79. Contd.. • Step2: Vertex intensity calculation: – Once we have the vertex normals, we can determine the intensity at the vertices from a lighting model. 2/9/2019 79By: Tekendra Nath Yogi
  • 80. Contd.. • Step3: Linearly interpolate the vertex intensities over the surface of the polygon. • Two step Process: • Bounding Intensity calculation: Intensity calculation at the intersection of the scan line with a polygon edge • Interior intensity calculation 2/9/2019 80By: Tekendra Nath Yogi
  • 81. Contd.. • Bounding Intensity calculation: – 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. 2/9/2019 81By: Tekendra Nath Yogi
  • 82. Contd.. – For the example in Figure below, 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: – Similarly, intensity at the right intersection of this scan line (point 5) is interpolated from intensity values at vertices 2 and 3. 2/9/2019 82By: Tekendra Nath Yogi
  • 83. Contd.. • Interior intensity calculation: Once these bounding intensities are established for a scan line, an interior point (such as point p in Fig. above) is interpolated from the bounding intensities at points 4 and 5 as: 2/9/2019 83By: Tekendra Nath Yogi
  • 84. Contd.. • Incremental calculations are used to obtain successive edge intensity values between scan lines and to obtain successive intensities along a scan line. As shown in Figure below: • if the intensity at edge position (x, y) is interpolated as: • then we can obtain the intensity along this edge for the next scan line, y - 1, as: 2/9/2019 84By: Tekendra Nath Yogi
  • 85. Contd … • Advantages: – Gouraud shading removes the intensity discontinuities associated with the constant-shading model. • But it has some other deficiencies. – Highlights 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. • Solutions: These effects can be reduced by using Phong shading, that require more calculations. 2/9/2019 85By: Tekendra Nath Yogi
  • 86. Phong Shading(Normal Vector Interpolation 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. • This method, developed by Phong Bui Tuong, is called Phong shading, or normalvector 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: – 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. 2/9/2019 86By: Tekendra Nath Yogi
  • 87. Contd.. • Interpolation of surface normals along a polygon edge between two vertices is illustrated in Figure below: Fig: Interpolation of surface normal along a polygon edge • 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: 2/9/2019 87By: Tekendra Nath Yogi
  • 88. Gouraud versus Phong Shading • Gouraud shading is faster than Phong shading • Phong shading is more accurate 2/9/2019 88By: Tekendra Nath Yogi
  • 89. Homework • Explain in detail about diffuse reflection model. • Difference between diffuse reflection and specular reflection. Why do we require shading model? Explain it. • Explain the visible effect that occurs when during animation of a Gouraud shading polyhedron, the center of a highlight moves from one vertex to another along an edge. • Why shading is required in the computer graphics? Explain in detail about constant intensity shading. • Explain in detail about Phong shading. How can you modify Phong shading model? • Explain in detail about Gourand shading model. Compare it with Phong shading model. • Explain in detail about Phong shading model. Compare it with Gouraud Shading model. 2/9/2019 89By: Tekendra Nath Yogi
  • 90. Thank You ! 90By: Tekendra Nath Yogi2/9/2019