SlideShare a Scribd company logo
2IV60 Computer graphics
set 11: Hidden Surfaces
Jack van Wijk
TU/e
Visible-Surface Detection 1
Problem:
Given a scene and a projection,
what can we see?
Visible-Surface Detection 2
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 3
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
H&B 16-1:504
Object space Image space
Visible-Surface Detection 4
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
H&B 16-1:504
Visible-Surface Detection 5
Four algorithms:
• Back-face elimination
• Depth-buffer
• Depth-sorting
• Ray-casting
But there are many other.
H&B 16
Back-face elimination 1
We cannot see the back-face of solid objects:
Hence, these can be ignored
H&B 16-2:504-505
face
back
:
0

N
V
V
N
Back-face elimination 2
We cannot see the back-face of solid objects:
Hence, these can be ignored
face
front
:
0

N
V
V
N
H&B 16-2:504-505
Back-face elimination 3
• 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
H&B 16-2:504-505
Depth-Buffer Algorithm 1
• Image-space method
• Aka z-buffer algorithm
xv
yv
zv
Normalized view volume
View plane
pixel
front =
visible
Algorithm:
Draw polygons,
Remember the
color most in front.
H&B 16-3:505-508
Depth-Buffer Algorithm 2
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
Calculate depth z;
If z < zbuf[i,j] then { closer! }
zbuf[i,j] := z;
fbuf[i,j] := surfacecolor(i,j);
Sorting
H&B 16-3:505-508
polygon
Depth-Buffer Algorithm 3
Fast calculation z: use coherence.
C
A
y
x
z
y
x
z
C
D
By
x
A
y
x
z
C
D
By
Ax
y
x
z
D
Cz
By
Ax

















)
,
(
)
,
1
(
:
Thus
)
1
(
)
,
1
(
:
Also
)
,
(
:
Hence
0
:
Plane
scan line
x
y
x+1
display
C
B
y
x
z
y
x
z 

 )
1
,
(
)
,
(
:
Also
H&B 16-3:505-508
Depth-Buffer Algorithm 4
+ 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
H&B 16-3:505-508
Depth-Sorting Algorithm 1
• Image and Object space
• Aka Painter’s algorithm
1. Sort surfaces for depth
2. Draw them back to front
H&B 16-6:511-514
Depth-Sorting Algorithm 2
Simplistic version sorting:
• Sort polygons for (average/frontal) z-value
xv
zv
4
3
2
1
display
xv
zv
4?
3?
2?
1?
display
3!
4!
1!
2!
H&B 16-6:511-514
Depth-Sorting Algorithm 3
A polygon S can be drawn if all remaining polygons S’
satisfy one of the following tests:
1. No overlap of bounding rectangles of S and S’
2. S is completely behind plane of S’
3. S’ is completely in front of plane of S
4. Projections S and S’ do not overlap
H&B 16-6:511-514
Depth-Sorting Algorithm 4
1. No overlap of bounding rectangles of S and S’
xv
zv
display
xv
yv
S
S’
S
S’
H&B 16-6:511-514
Depth-Sorting Algorithm 5
xv
zv
display
xv
yv
2. S is completely behind plane of S’
Substitute all vertices of S in plane equation S’, and
test if the result is always negative.
S
S’
S
S’
H&B 16-6:511-514
Depth-Sorting Algorithm 6
xv
zv
display
xv
yv
3. S’ is completely in front of plane of S
Substitute all vertices of S’ in plane equation of S, and
test if the result is always positive
S
S’
S
S’
H&B 16-6:511-514
Depth-Sorting Algorithm 7
xv
zv
display
xv
yv
4. Projections S and S’ do not overlap
S
S’
S
S’
H&B 16-6:511-514
Depth-Sorting Algorithm 8
xv
zv
display
If all tests fail: Swap S and S’,
and restart with S’.
S’
S S’’
H&B 16-6:511-514
Depth-Sorting Algorithm 9
xv
yv
Problems: circularity and intersections
Solution: Cut up polygons.
xv
yv
H&B 16-6:511-514
Depth-Sorting Algorithm 10
- Tricky to implement
- Polygons have to be known from the start
- Slow: ~ #polygons2
0
1
2
3
0
1
2
3
-1
-0.5
0
0.5
1
0
1
2
3
+ Fine for certain types of objects,
such as plots of z=f(x, y) or
non-intersecting spheres
+ Produces exact boundaries polygons
H&B 16-6:511-514
Ray-casting Algorithm 1
• Image-space method
• Related to depth-buffer, order is different
xv
yv
zv
Normalized view volume
View plane
pixel
front =
visible
Algorithm:
Per pixel:
- Calculate
intersection points
- Determine front one
z
H&B 16-10:518-519
Ray-casting Algorithm 2
Var fbuf: array[N,N] of colour; { frame-buffer }
n : integer; { #intersections }
z : array[MaxIntsec] of real; { intersections }
p : array[MaxIntsec] of object; { corresp. objects }
For all 1<= i, j <=N do { for alle pixels }
For all objects do
Calculate intersections and add these to z and p,
keeping z and p sorted;
if n > 1 then fbuf[i,j] := surfacecolor(p[1], z[1]);
H&B 16-10:518-519
Ray-casting Algorithm 3
Acceleration intersection calculations:
Use (hierarchical) bounding boxes
xv
yv
zv
z
H&B 16-10:518-519
Ray-casting algorithm 4
+ Relatively easy to implement
+ For some objects very suitable (for instance
spheres and other quadratic surfaces)
+ Transparency can be dealt with easily
- Objects must be known in advance
- Sloooow: ~ #objects*pixels, little coherence
+ Special case of ray-tracing
H&B 16-10:518-519
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.)
H&B 16-11:519
glEnable(GL_CULL_FACE); // Turn culling on
glCullFace(mode); // Specify what to cull
mode = GL_FRONT or GL_BACK // GL_BACK is default
Orientation matters! If you want to change the default:
glFrontFace(vertexOrder); // Order of vertices
vertexOrder = GL_CW or // Clockwise
GL_CCW; // Counterclockwise (default)
OpenGL backface removal
H&B 16-11:523-525
1
2
3
4
CCW:
front
4
3
2
1
CW:
back
glEnable(GL_DEPTH_TEST); // Turn testing on
glClear(GL_DEPTH_BUFFER_BIT); // Clear depth-buffer,
// typically once per frame
glDepthFunc(condition); // Change test used
condition: GL_LESS // Closer: visible (default)
GL_GREATER // Farther: visible
Note: range between znear and zfar is mapped to [0,1], using one or
two bytes precision. If zfar has an unnecessarily high value,
you loose precision, and artifacts can appear.
OpenGL depth-buffer functions
H&B 16-11:523-525
Next…
• We know how to determine what is visible,
and we looked at illumination and shading.
• Next: Let’s consider more advanced shading.

More Related Content

Similar to 2IV60_11_hidden_surfaces (6).ppt

UNIT-III
UNIT-IIIUNIT-III
UNIT-III
VarthiniRamesh
 
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
srinivasan779644
 
zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...
zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...
zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...
Alex Pruden
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
iftakhar8
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
Mark Kilgard
 
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
Alex Pruden
 
clipping
clippingclipping
clipping
HiteshJain007
 
Dsoop (co 221) 1
Dsoop (co 221) 1Dsoop (co 221) 1
Dsoop (co 221) 1
Puja Koch
 
Hidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferHidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-buffer
Raj Sikarwar
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
SigSegVSquad
 
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation PipelineComputer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
💻 Anton Gerdelan
 
【英】QuadceptVer10-7_ReleaseNote.pdf
【英】QuadceptVer10-7_ReleaseNote.pdf【英】QuadceptVer10-7_ReleaseNote.pdf
【英】QuadceptVer10-7_ReleaseNote.pdf
Quadcept
 
Unit 4 dica
Unit 4 dicaUnit 4 dica
Unit 4 dica
Pavan Mukku
 
Mission Planning and Execution for the Unmanned Rotorcraft ARTIS
Mission Planning and Execution for the Unmanned Rotorcraft ARTISMission Planning and Execution for the Unmanned Rotorcraft ARTIS
Mission Planning and Execution for the Unmanned Rotorcraft ARTIS
Florian-Michael Adolf
 
3306565.ppt
3306565.ppt3306565.ppt
3306565.ppt
JP Chicano
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
KKARUNKARTHIK
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection i
elaya1984
 
rural marketing ppt
rural marketing pptrural marketing ppt
rural marketing ppt
elaya1984
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
ilias ahmed
 
ch02.ppt
ch02.pptch02.ppt
ch02.ppt
Godwin585235
 

Similar to 2IV60_11_hidden_surfaces (6).ppt (20)

UNIT-III
UNIT-IIIUNIT-III
UNIT-III
 
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
 
zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...
zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...
zkStudyClub: PLONKUP & Reinforced Concrete [Luke Pearson, Joshua Fitzgerald, ...
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
zkStudyClub - Improving performance of non-native arithmetic in SNARKs (Ivo K...
 
clipping
clippingclipping
clipping
 
Dsoop (co 221) 1
Dsoop (co 221) 1Dsoop (co 221) 1
Dsoop (co 221) 1
 
Hidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferHidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-buffer
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation PipelineComputer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
 
【英】QuadceptVer10-7_ReleaseNote.pdf
【英】QuadceptVer10-7_ReleaseNote.pdf【英】QuadceptVer10-7_ReleaseNote.pdf
【英】QuadceptVer10-7_ReleaseNote.pdf
 
Unit 4 dica
Unit 4 dicaUnit 4 dica
Unit 4 dica
 
Mission Planning and Execution for the Unmanned Rotorcraft ARTIS
Mission Planning and Execution for the Unmanned Rotorcraft ARTISMission Planning and Execution for the Unmanned Rotorcraft ARTIS
Mission Planning and Execution for the Unmanned Rotorcraft ARTIS
 
3306565.ppt
3306565.ppt3306565.ppt
3306565.ppt
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection i
 
rural marketing ppt
rural marketing pptrural marketing ppt
rural marketing ppt
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
 
ch02.ppt
ch02.pptch02.ppt
ch02.ppt
 

Recently uploaded

1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf
1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf
1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf
ISONIKELtd
 
IMG_20240615_091110.pdf dpboss guessing
IMG_20240615_091110.pdf dpboss  guessingIMG_20240615_091110.pdf dpboss  guessing
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results
 
The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...
The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...
The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...
YourLegal Accounting
 
Cover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SUCover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SU
msthrill
 
AI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your BusinessAI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your Business
Arijit Dutta
 
8328958814KALYAN MATKA | MATKA RESULT | KALYAN
8328958814KALYAN MATKA | MATKA RESULT | KALYAN8328958814KALYAN MATKA | MATKA RESULT | KALYAN
8328958814KALYAN MATKA | MATKA RESULT | KALYAN
➑➌➋➑➒➎➑➑➊➍
 
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
valvereliz227
 
Efficient PHP Development Solutions for Dynamic Web Applications
Efficient PHP Development Solutions for Dynamic Web ApplicationsEfficient PHP Development Solutions for Dynamic Web Applications
Efficient PHP Development Solutions for Dynamic Web Applications
Harwinder Singh
 
GKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt PresentationGKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt Presentation
GraceKohler1
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
 
Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...
Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...
Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...
IPLTech Electric
 
Pro Tips for Effortless Contract Management
Pro Tips for Effortless Contract ManagementPro Tips for Effortless Contract Management
Pro Tips for Effortless Contract Management
Eternity Paralegal Services
 
State of D2C in India: A Logistics Update
State of D2C in India: A Logistics UpdateState of D2C in India: A Logistics Update
State of D2C in India: A Logistics Update
RedSeer
 
Science Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around UsScience Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around Us
PennapaKeavsiri
 
Registered-Establishment-List-in-Uttarakhand-pdf.pdf
Registered-Establishment-List-in-Uttarakhand-pdf.pdfRegistered-Establishment-List-in-Uttarakhand-pdf.pdf
Registered-Establishment-List-in-Uttarakhand-pdf.pdf
dazzjoker
 
一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理
一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理
一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理
taqyea
 
The latest Heat Pump Manual from Newentide
The latest Heat Pump Manual from NewentideThe latest Heat Pump Manual from Newentide
The latest Heat Pump Manual from Newentide
JoeYangGreatMachiner
 
Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...
Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...
Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...
Niswey
 
The Most Inspiring Entrepreneurs to Follow in 2024.pdf
The Most Inspiring Entrepreneurs to Follow in 2024.pdfThe Most Inspiring Entrepreneurs to Follow in 2024.pdf
The Most Inspiring Entrepreneurs to Follow in 2024.pdf
thesiliconleaders
 

Recently uploaded (20)

1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf
1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf
1 Circular 003_2023 ISO 27001_2022 Transition Arrangments v3.pdf
 
IMG_20240615_091110.pdf dpboss guessing
IMG_20240615_091110.pdf dpboss  guessingIMG_20240615_091110.pdf dpboss  guessing
IMG_20240615_091110.pdf dpboss guessing
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
 
The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...
The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...
The Role of White Label Bookkeeping Services in Supporting the Growth and Sca...
 
Cover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SUCover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SU
 
AI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your BusinessAI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your Business
 
8328958814KALYAN MATKA | MATKA RESULT | KALYAN
8328958814KALYAN MATKA | MATKA RESULT | KALYAN8328958814KALYAN MATKA | MATKA RESULT | KALYAN
8328958814KALYAN MATKA | MATKA RESULT | KALYAN
 
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
 
Efficient PHP Development Solutions for Dynamic Web Applications
Efficient PHP Development Solutions for Dynamic Web ApplicationsEfficient PHP Development Solutions for Dynamic Web Applications
Efficient PHP Development Solutions for Dynamic Web Applications
 
GKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt PresentationGKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt Presentation
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
 
Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...
Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...
Sustainable Logistics for Cost Reduction_ IPLTech Electric's Eco-Friendly Tra...
 
Pro Tips for Effortless Contract Management
Pro Tips for Effortless Contract ManagementPro Tips for Effortless Contract Management
Pro Tips for Effortless Contract Management
 
State of D2C in India: A Logistics Update
State of D2C in India: A Logistics UpdateState of D2C in India: A Logistics Update
State of D2C in India: A Logistics Update
 
Science Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around UsScience Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around Us
 
Registered-Establishment-List-in-Uttarakhand-pdf.pdf
Registered-Establishment-List-in-Uttarakhand-pdf.pdfRegistered-Establishment-List-in-Uttarakhand-pdf.pdf
Registered-Establishment-List-in-Uttarakhand-pdf.pdf
 
一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理
一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理
一比一原版(QMUE毕业证书)英国爱丁堡玛格丽特女王大学毕业证文凭如何办理
 
The latest Heat Pump Manual from Newentide
The latest Heat Pump Manual from NewentideThe latest Heat Pump Manual from Newentide
The latest Heat Pump Manual from Newentide
 
Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...
Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...
Unlocking WhatsApp Marketing with HubSpot: Integrating Messaging into Your Ma...
 
The Most Inspiring Entrepreneurs to Follow in 2024.pdf
The Most Inspiring Entrepreneurs to Follow in 2024.pdfThe Most Inspiring Entrepreneurs to Follow in 2024.pdf
The Most Inspiring Entrepreneurs to Follow in 2024.pdf
 

2IV60_11_hidden_surfaces (6).ppt

  • 1. 2IV60 Computer graphics set 11: Hidden Surfaces Jack van Wijk TU/e
  • 2. Visible-Surface Detection 1 Problem: Given a scene and a projection, what can we see?
  • 3. Visible-Surface Detection 2 Terminology: Visible-surface detection vs. hidden-surface removal Hidden-line removal vs. hidden-surface removal Many algorithms: • Complexity scene • Type of objects • Hardware
  • 4. Visible-Surface Detection 3 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 H&B 16-1:504 Object space Image space
  • 5. Visible-Surface Detection 4 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 H&B 16-1:504
  • 6. Visible-Surface Detection 5 Four algorithms: • Back-face elimination • Depth-buffer • Depth-sorting • Ray-casting But there are many other. H&B 16
  • 7. Back-face elimination 1 We cannot see the back-face of solid objects: Hence, these can be ignored H&B 16-2:504-505 face back : 0  N V V N
  • 8. Back-face elimination 2 We cannot see the back-face of solid objects: Hence, these can be ignored face front : 0  N V V N H&B 16-2:504-505
  • 9. Back-face elimination 3 • 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 H&B 16-2:504-505
  • 10. Depth-Buffer Algorithm 1 • Image-space method • Aka z-buffer algorithm xv yv zv Normalized view volume View plane pixel front = visible Algorithm: Draw polygons, Remember the color most in front. H&B 16-3:505-508
  • 11. Depth-Buffer Algorithm 2 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 Calculate depth z; If z < zbuf[i,j] then { closer! } zbuf[i,j] := z; fbuf[i,j] := surfacecolor(i,j); Sorting H&B 16-3:505-508
  • 12. polygon Depth-Buffer Algorithm 3 Fast calculation z: use coherence. C A y x z y x z C D By x A y x z C D By Ax y x z D Cz By Ax                  ) , ( ) , 1 ( : Thus ) 1 ( ) , 1 ( : Also ) , ( : Hence 0 : Plane scan line x y x+1 display C B y x z y x z    ) 1 , ( ) , ( : Also H&B 16-3:505-508
  • 13. Depth-Buffer Algorithm 4 + 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 H&B 16-3:505-508
  • 14. Depth-Sorting Algorithm 1 • Image and Object space • Aka Painter’s algorithm 1. Sort surfaces for depth 2. Draw them back to front H&B 16-6:511-514
  • 15. Depth-Sorting Algorithm 2 Simplistic version sorting: • Sort polygons for (average/frontal) z-value xv zv 4 3 2 1 display xv zv 4? 3? 2? 1? display 3! 4! 1! 2! H&B 16-6:511-514
  • 16. Depth-Sorting Algorithm 3 A polygon S can be drawn if all remaining polygons S’ satisfy one of the following tests: 1. No overlap of bounding rectangles of S and S’ 2. S is completely behind plane of S’ 3. S’ is completely in front of plane of S 4. Projections S and S’ do not overlap H&B 16-6:511-514
  • 17. Depth-Sorting Algorithm 4 1. No overlap of bounding rectangles of S and S’ xv zv display xv yv S S’ S S’ H&B 16-6:511-514
  • 18. Depth-Sorting Algorithm 5 xv zv display xv yv 2. S is completely behind plane of S’ Substitute all vertices of S in plane equation S’, and test if the result is always negative. S S’ S S’ H&B 16-6:511-514
  • 19. Depth-Sorting Algorithm 6 xv zv display xv yv 3. S’ is completely in front of plane of S Substitute all vertices of S’ in plane equation of S, and test if the result is always positive S S’ S S’ H&B 16-6:511-514
  • 20. Depth-Sorting Algorithm 7 xv zv display xv yv 4. Projections S and S’ do not overlap S S’ S S’ H&B 16-6:511-514
  • 21. Depth-Sorting Algorithm 8 xv zv display If all tests fail: Swap S and S’, and restart with S’. S’ S S’’ H&B 16-6:511-514
  • 22. Depth-Sorting Algorithm 9 xv yv Problems: circularity and intersections Solution: Cut up polygons. xv yv H&B 16-6:511-514
  • 23. Depth-Sorting Algorithm 10 - Tricky to implement - Polygons have to be known from the start - Slow: ~ #polygons2 0 1 2 3 0 1 2 3 -1 -0.5 0 0.5 1 0 1 2 3 + Fine for certain types of objects, such as plots of z=f(x, y) or non-intersecting spheres + Produces exact boundaries polygons H&B 16-6:511-514
  • 24. Ray-casting Algorithm 1 • Image-space method • Related to depth-buffer, order is different xv yv zv Normalized view volume View plane pixel front = visible Algorithm: Per pixel: - Calculate intersection points - Determine front one z H&B 16-10:518-519
  • 25. Ray-casting Algorithm 2 Var fbuf: array[N,N] of colour; { frame-buffer } n : integer; { #intersections } z : array[MaxIntsec] of real; { intersections } p : array[MaxIntsec] of object; { corresp. objects } For all 1<= i, j <=N do { for alle pixels } For all objects do Calculate intersections and add these to z and p, keeping z and p sorted; if n > 1 then fbuf[i,j] := surfacecolor(p[1], z[1]); H&B 16-10:518-519
  • 26. Ray-casting Algorithm 3 Acceleration intersection calculations: Use (hierarchical) bounding boxes xv yv zv z H&B 16-10:518-519
  • 27. Ray-casting algorithm 4 + Relatively easy to implement + For some objects very suitable (for instance spheres and other quadratic surfaces) + Transparency can be dealt with easily - Objects must be known in advance - Sloooow: ~ #objects*pixels, little coherence + Special case of ray-tracing H&B 16-10:518-519
  • 28. 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.) H&B 16-11:519
  • 29. glEnable(GL_CULL_FACE); // Turn culling on glCullFace(mode); // Specify what to cull mode = GL_FRONT or GL_BACK // GL_BACK is default Orientation matters! If you want to change the default: glFrontFace(vertexOrder); // Order of vertices vertexOrder = GL_CW or // Clockwise GL_CCW; // Counterclockwise (default) OpenGL backface removal H&B 16-11:523-525 1 2 3 4 CCW: front 4 3 2 1 CW: back
  • 30. glEnable(GL_DEPTH_TEST); // Turn testing on glClear(GL_DEPTH_BUFFER_BIT); // Clear depth-buffer, // typically once per frame glDepthFunc(condition); // Change test used condition: GL_LESS // Closer: visible (default) GL_GREATER // Farther: visible Note: range between znear and zfar is mapped to [0,1], using one or two bytes precision. If zfar has an unnecessarily high value, you loose precision, and artifacts can appear. OpenGL depth-buffer functions H&B 16-11:523-525
  • 31. Next… • We know how to determine what is visible, and we looked at illumination and shading. • Next: Let’s consider more advanced shading.