Professional Documents
Culture Documents
Visual Realism
Visual Realism
Detection
Visible Surface Detection
● Visible surface detection or hidden surface
removal.
● Realistic scenes: closer objects occludes the
others.
● Classification:
– Object space methods
– Image space methods
Occlusion: Full, Partial, None
Ax By Cz D 0
𝑦1 − 𝑦2 𝑧1 − 𝑧2 𝑧1 − 𝑧2 𝑥1 − 𝑥2
Where A = 𝑦 − 𝑦 𝑧2 − 𝑧3 B= 𝑧 −𝑧 𝑥2 − 𝑥3
2 3 2 3
𝑥1 𝑦1 𝑧1
𝑥1 − 𝑥2 𝑦1 − 𝑦2
C= 𝑥 −𝑥 𝑦2 − 𝑦3 and D = − 𝑥2 𝑦2 𝑧2
2 3
𝑥3 𝑦3 𝑧3
Back face detection
● A fast and simple object-space method for
identifying the back face of poly-hedron is
based on the Inside-Outside (given a point is
inside or outside of a plane/surface).
● Let Plane Parameters are A, B, C, D then a
point (x, y, z) will be inside to a plane or on
the plane if
Ax + By + Cz + D ≤ 0
Back-Face Detection
● Back-face detection of 3D polygon surface is
easy
● Recall the polygon surface equation:
Ax By Cz D 0
● We need to also consider the viewing
direction when determining whether a surface
is back-face or front-face.
Backface Culling
Avoid drawing polygons facing away from the viewer
Front-facing polygons occlude these polygons in a closed
polyhedron
Test if a polygon is front- or back-facing?
back-facing
Ideas?
front-facing
Detecting Back-face Polygons
The polygon normal of a …
front-facing polygon points towards the viewer
back-facing polygon points away from the viewer
In otherwords
back
A polygon is front facing if its surface normal vector pointing 𝑛
𝜋
towards the view point else backface. 𝑉 𝜃<
2
Using n.V = 𝑛 𝑣 cos 𝜃 𝑛
If (n v) > 0 “back-face” 𝑉
𝜋
If (n v) ≤ 0 “front-face” 𝜃>
2
v = view vector
front
Back-Face Detection
● A polygon surface is a back face if:
Vview N 0
3 5,1 0 -1
4
2 3
4 3 -1 -1
5 2 1
6 -1 -1
Step 4
2 4, 3, 1 -1 5
-1
3 5,1 -1 4
-1
2 3
4 3 -1 -1
5 1 0
6 -1 1
-1
Step 5
A( x 1) By D
z
C
A
z
C
Z-buffer - Example
Z-buffer
Screen
Parallel with
the image plane
Not Parallel
Z-Buffer Algorithm
Algorithm easily handles this case
Depth-Buffer Method
● Is able to handle cases such as
𝑦3 − 𝑦5 𝑦5 − 𝑦2
𝐼5 = 𝐼 + 𝐼
𝑦3 − 𝑦2 2 𝑦3 − 𝑦2 3
Gouraud Shading
● Once the intensities of intersection points 4
and 5 are calculated for a scanline, the
intensity of an interior point (say, P) is
calculated as follows –
Flat shading Vs Gouraud Shading
Gouraud Shading
● Advantages
● 1. In this model, we calculate the intensity for
each pixel, it ends up with the neighbouring
pixel across the border having nearly the
same color intensity. So, the rendered
model appears continuous.
● 2. Gouraud shading can be combined with a
hidden surface algorithm to fill in the visible
polygons along each scanline.
Gouraud Shading
Disadvantages
1. Highlights on the surface are sometimes
displayed with irregular shapes.
2. This linear intensity interpolation can result
in bright or dark intensity streaks to appear on
the surface. These bright or dark intensity
streaks are called as mach bands. This mach
band effect can be reduced by breaking the
surface into a greater number of smaller
polygons.
Phong Shading
● Phong shading is similar to Gouraud
shading.
● The difference is that Phong shading
calculates the average unit normal vector
at each of the polygon vertices and then
interpolates the vertex normal over the
surface of the polygon.
● After calculating the surface normal, it
applies the illumination model to get the
colour intensity for each pixel of the polygon.
Phong Shading
● So for rendering a polygon surface, is to
interpolate normal vectors and then apply the
Illumination model to each surface point.
This method is also known as Phong shading
or normal-vector interpolation shading,
interpolates the surface normal vector N,
instead of the intensity.
Phong Shading
● To display the polygon surface, we follow
three steps –
Step 1. Determine the average unit normal
vector at each polygon vertex.
Step 2. Linearly interpolate the vertex normals
over the surface of the polygon.
Step 3. Apply an illumination model along
each scanline to determine projected pixel
intensities for the surface points.
Phong Shading
● Please note here that the first step is same as
in Gouraud shading.
● In second step, the vertex normals are
linearly interpolated over the surface of the
polygon.
The calculation of
interpolation of surface
normals along a polygon
edge is shown in Fig
Phong Shading
● the normal vector, , for the scanline
intersection point along the edge between
● vertices 1 and 2 can be obtained by vertically
interpolating between edge endpoint normal
i.e,
Phong Shading
● like Gouraud shading, we can use incremental
methods to evaluate normals between scan
lines and along each individual scanline.
Once the surface normals are evaluated, the
surface intensity at the point is determined by
applying the illumination model.
Phong Shading
● Advantages
● 1. It displays more realistic highlights on a
surface.
● 2. It reduces the Mach-Band effect.
● 3. It gives more accurate results.
Disadvantages
● 1. It requires more calculations.
● 2. It greatly increases the cost of shading
steeply.