10 SurfaceDetection En
10 SurfaceDetection En
Computer Graphics
Διαγραφή Πίσω Επιφανειών και Απόκρυψη
Andreas Aristidou
[email protected]
http://www.andreasaristidou.com
Review: Rendering Pipeline
▪ We almost completed the rendering pipeline:
▪ Modeling transformations
▪ Viewing transformations
▪ Projection transformations
▪ Clipping
▪ Scan conversion
▪ Now we know everything about how to draw a
polygon on the screen, except for determining
the non-visible subjects, or else visible surface
detection.
Pi
Ax + By + Cz + D 0
▪ where A, B, C & D are the plane parameters for the surface
▪ This can actually be made even easier if we organise things to suit ourselves
https://en.wikipedia.org/wiki/Back-face_culling
A triangle facing away from you is only guaranteed to be invisible if there’s something else in front of.
This is only guaranteed for closed, solid objects (e.g. a sphere)
Objects with ‘holes’ may expose back-facing triangles to the viewer; backface culling results in errors
(see skulls on right)
EPL426 | Computer Graphics
Back-Face Detection
▪ Most objects on stage are usually "solid" and non-transparent!
▪ What happens if it's not?
After all surfaces are processed depthBuff and frameBuff will store correct values
255 255 255 255 255 255 255 255 64 64 64 64 64 64 64 64 64 64 64 64 255 255
255 255 255 255 255 255 255 255 64 64 64 64 64 64 64 64 64 64 255 255 255
255 255 255 255 255 255 255 255 64 64 64 64 64 64 64 64 255 255 255 255
255 255 255 255 255 255 255 255 64 64 64 64 255 255 255 255 255 255
255 255 255 255 255 255 255 255 64 64 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
64
64
64
64
64
64
64
64
64
64
64
255
255
255
255
255
near = 0, far = 255 64
64
64
64
64
64
64
64
64
64
64
255
255
255
255
255
64 64 255 255 255 255 255 255 127 127 127 64 64 127 255 255 255 255 255
64 255 255 255 255 255 255 255 127 127 127 127 64 127 127 127 255 255 255 255
255 255 255 255 255 255 255 255 127 127 127 127 127 127 127 127 127 127 255 255 255
A +B
z' = z − m
C
EPL426 | Computer Graphics
Iterative Calculations
y scan line
y - 1 scan line
x x’
z z
zmax zmax
S S
z’max
zmin S’
z’max zmin
S’
z’min z’min
x x
No Depth Overlap Depth Overlap
◼ Given a set of S polygons and a viewpoint C, find a series of {P1…Pn} at S such that
any Pi polygon does not hide any of the polygons {Pi+1…Pn}.
◼ Another way to think about it: for every 2 polygons intersected by a ray through the C,
Pi ; has a higher priority than Pj, (with i < j)
P2
C P1
t2
t1
▪ It is a hybrid approach as the first step, the sorting, is in the object space and the second in
the image space
▪ The hardest part is sorting
P4
P2
P3
C
P5 P1
▪ Answer:
O(n2)