0% found this document useful (0 votes)
17 views20 pages

Mod 2 Lecture 3 CG Hidden Lines

The document discusses visible-surface detection in computer graphics, focusing on algorithms for determining which surfaces are visible in a scene. It categorizes algorithms into object-space and image-space methods, highlighting techniques such as back-face elimination and the depth-buffer algorithm. The document also compares the performance and applicability of various algorithms based on scene complexity and object types.

Uploaded by

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

Mod 2 Lecture 3 CG Hidden Lines

The document discusses visible-surface detection in computer graphics, focusing on algorithms for determining which surfaces are visible in a scene. It categorizes algorithms into object-space and image-space methods, highlighting techniques such as back-face elimination and the depth-buffer algorithm. The document also compares the performance and applicability of various algorithms based on scene complexity and object types.

Uploaded by

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

Module 2

Lecture 3
Computer graphics
Hidden Surfaces
Visible-Surface Detection
Problem:
Given a scene and a projection,
what can we see?
Visible-Surface Detection
Terminology:
Visible-surface detection vs. hidden-surface removal
Hidden-line removal vs. hidden-surface removal
Many algorithms:
• Complexity scene
• Type of objects
• Hardware
Visible-Surface Detection
Two main types of algorithms:
Object space: Determine which part of the object
are visible
Image space: Determine per pixel which point of
an object is visible

Object space Image space


Visible-Surface Detection
Visible-surface detection = sort for depth
• what and in what order varies
Performance: use coherence
• Objects
• Position in world space
• Position in image space
• Time
Visible-Surface Detection
Four algorithms:
• Back-face elimination
• Depth-buffer
• Depth-sorting
• Ray-casting
But there are many other.
Algorithm Classifications
• Object-Space Methods:
– Visibility is decided by comparing objects in object-
space.
e.g. Back face elimination, painter’s algorithm.

• Image-Space Methods:
– Visibility is decided at each pixel position in the
projection plane.
e.g. Z-Buffer algorithm
Back-Face Elimination
Don’t draw surfaces facing away from viewpoint:
– Assumes objects are solid polyhedra
• Usually combined with additional methods c
– Compute polygon normal n:
• Assume counter-clockwise vertex
n
order
a
• For a triangle (a, b, c): n = (b – a)  (c – a)
b
– Compute vector from viewpoint to any y
point p on polygon v:
– Facing away (don’t draw) if n and v are
pointed in opposite directions 
dot product n · v > 0 x

z
8
Back Face Elimination

• A polygon is a back face if V • N > 0.


x

z
Back-face elimination
We cannot see the back-face of solid objects:
Hence, these can be ignored

V  N  0 : back face
N V
Back-face elimination
We can see the front-face of solid objects:
Hence, that face is accepted

V  N  0 : front face
V

N
Back-face elimination
• Object-space method
• Works fine for convex polyhedra: ±50% removed
• Concave or overlapping polyhedra: require additional
processing
• Interior of objects can not be viewed
Partially visible front faces
Back-Face Culling Example
n1·v = (2, 1, 2) · (-1, 0, -1)
= -2 – 2 = -4,
n2 = (-3, 1, -2) So n1·v < 0
n1 = (2, 1, 2)
So n1 front facing polygon

n2 ·v = (-3, 1, -2) · (-1, 0, -1)


=3+2=5
v = (-1, 0, -1) So n2 · v > 0
So n2 back facing polygon

13
Z-Buffering
Z-Buffer Algorithm
• Most widely used Image-space algorithm.
• Easy to implement, both in software and
hardware. y
• Incremental computation.

(x, y)

x
z
Depth-Buffer Algorithm
• Image-space method
• Otherwise called z-buffer algorithm
Normalized view volume

Algorithm:
Draw polygons,
yv
Remember the
xv
color most in front.
zv Stores two arrays
front =
1. Z depth, z(x,y)
visible pixel View plane
2. Pixel data,I(x,y)
Depth-Buffer Algorithm
Fast calculation z: use coherence.
polygon Plane : Ax  By  Cz  D  0
scan line  Ax  By  D
Hence : z ( x, y ) 
y C
 A( x  1)  By  D
Also : z ( x  1, y ) 
C
x x+1 A
Thus : z ( x  1, y )  z ( x, y ) 
display C
B
Also : z ( x, y )  z ( x, y  1) 
C
Depth-Buffer Algorithm
+ Easy to implement
+ Hardware supported
+ Polygons can be processed in arbitrary order
+ Fast: ~ #polygons, #covered pixels

- Costs memory
- Color calculation sometimes done multiple times
- Transparancy is tricky
Depth-Buffer Algorithm
var zbuf: array[N,N] of real; { z-buffer: 0=near, 1=far }
fbuf: array[N,N] of color; { frame-buffer }

For all 1<= i, j <=N do


zbuf[i,j] := 1.0; col[i,j] := BackgroundColour;
For all polygons do { scan conversion }
For all covered pixels (i,j) do Sorting
Calculate depth z;
If z < zbuf[i,j] then { closer! }
zbuf[i,j] := z;
fbuf[i,j] := surfacecolor(i,j);
Comparison
• Hardware available? Use depth-buffer, possibly in
combination with back-face elimination or depth-sort for
part of scene.
• If not, choose dependent on complexity scene and type
of objects:
– Simple scene, few objects: depth-sort
– Quadratic surfaces: ray-casting
– Otherwise: depth-buffer
• Many additional methods to boost performance
(kD-trees, scene decomposition, etc.)

You might also like