• No results found

9-culling-visibility.ppt

N/A
N/A
Protected

Academic year: 2020

Share "9-culling-visibility.ppt"

Copied!
38
0
0

Loading.... (view fulltext now)

Full text

(1)

If you cannot see it, ignore it

CULLING

– Do not render the primitives that are not visible

– Throw away the primitives that do not change

the scene

• Or with negligible impact

– Do it as soon as possible! (in the pipeline)

(2)

Notation

We call it

culling

if we discard primitives

– Or groups of primitives

If a primitive is divided into a visible part and a not

visible one, we call it

clipping

If we discard a fragment, this is

fragment

testing

(3)

Notation

We call it

culling

if we discard primitives

– Or groups of primitives

If a primitive is divided into a visible part and a not

visible one, we call it

clipping

If we discard a fragment, this is

fragment testing

(in most cases)

an

optimization

!

(in most cases)

(in most cases)

(4)

Forms of Culling

Occlusion

culling

– Not visible ... because it is covered

View-frustum

culling

– Not visible... because it is outside the view frustum

Backface

culling

– Not visible... because it is in the inside of a closed figure

Importance

culling

(5)

Forms of Culling

• Executed in hardware

– automated

– Very efficient (very small overhead)

– But discard late and only one primitive at the time

• Executed by the application (SW)

– Require algorithms and data structures

– Less efficient (quite large overhead)

(6)

Forms of Culling

• Conservative

– Only discard when sure

– Sometimes they draw objects not visible

• Non Conservative

– Discrad according to an heuristics

– Sometimes they DO NOT draw a (partly) visible

object!

Less efficient but sound.

(7)

We call artifact a rendering error,

– A discrepancy between the model and the image

– Or between reality and the model

– In most cases, it draws on the screen a

non-existant detail

parentesi notazione parentesi notazione parentesi notazione

(8)

Culling and Visibility

Computer Graphics Pagina 8

We call artifact a rendering error,

– A discrepancy between the model and the image

– Or between reality and the model

– In most cases, it draws on the screen a non-existant

detail

parentesi notazione parentesi notazione parentesi notazione

(9)

Forms of Culling

Occlusion

culling

– Not visible ... because it is covered

View-frustum

culling

– Not visible... because it is outside the view frustum

Backface

culling

– Not visible... because it is in the inside of a closed figure

Importance

culling

(10)

Backface Culling

Idea:

– We are modeling the surface of a

closed

object

...

– I cannot see the inside

(11)

(HW) Backface Culling: Where?

Final pixels

(12)

(HW) Backface Culling: How much?

Throw away approx 50% of the faces...

The speed-up?

x2

?

...only after this step!

Final pixels

(13)

(HW) Backface culling: when?

I cannto use it always!

– Need to know

a priori

that the object is closed

primitives

here

OpenGL state

(14)

(HW) Backface culling: How?

Turn it on and off:

glEnable( GL_CULL_FACE );

glDisable( GL_CULL_FACE );

• Deciding whether to discard the front

orback-facing faces:

glCullFace(GL_FRONT );

glCullFace(GL_BACK );

These commands only change

the state. “not the screen"

(15)

Metodologie di Culling

Occlusion

culling

– Not visible ... because it is covered

View-frustum

culling

– Not visible... because it is outside the view frustum

Backface

culling

– Not visible... because it is in the inside of a closed figure

Importance

culling

(16)

(HW) View-frustum culling

Given a primitive

– triangle, segment, point

Is it inside the view frustum?

– (or partly inside- conservative!)

y

x

• Better working in normalized

coordinates

(17)

(HW) View-frustum Culling: where?

...as usual, only from this step!

Final pixels

(18)

Software View-frustum Culling

Idea: do it before pushing the triangles in the

rendering pipeline

Divide the scene into blocks

– Most scenes are naturally organized in blocks

(19)

Forms of Culling

Occlusion

culling

– Not visible ... because it is covered

View-frustum

culling

– Not visible... because it is outside the view frustum

Backface

culling

– Not visible... because it is in the inside of a closed figure

Importance

culling

(20)

Occlusion Culling

Very important form of culling

Can discard lots of primitives

– Mostly the primitives composing the

– environment

Where can we apply it ?

Final pixels

(21)

Hidden surfaces removal

Closer objects must cover thode more far

away

(22)

Hidden surfaces removal

Different from

occlusion culling

– Can only remove whole triangles (or groups of

triangles)

– It is only an optimization

Back-face culling is not enough

– example:

non back-facing

surfaces, not totally,

(23)

Hidden surfaces removal

Solution 1:

– Split any triangle into a visible and an occluded

part?

• By performing a clipping

How to decide when a triangle occludes another one?

One triangle is clipped and what about the other?

(24)

Hidden surfaces removal

Solution 2:

– Draw only whole triangles, but in the

right order

(25)

Painter’s algorithm (depth sorting)

Given a scene (composed of primitives)

– Sort the primitives by depth

• From the farthest away to the closest one to the viewpoint

– Draw them all (according to the ordering)

(26)

Painter’s algorithm (depth sorting)

Where?

y

v

0

v

1

v

0

v

1

Before feeding the triangles.

Executed by the CPU ! 

Final pixels

(27)

Painter’s algorithm (depth sorting)

Given a scene (composed of primitives)

– Sort the primitives by depth

• From the farthest away to the closest one to the viewpoint

– Draw them all (according to the ordering)

Sorting

!

Pseudolinear

complexity wrt the

number of primitives.

   

The primitive has more than

one depth value!

(28)

Painter’s algorithm (depth sorting)

Should we draw C or D?

Does there exist a

“right order"?

D

ep

th

z

min

Primitives

B

z

max

A

E

D

C

(29)

Painter’s algorithm (depth sorting)

• The primitive A can be drawn first

Should we draw C or D?

Does there exist a “right order"?

– NO!

• intersections

(30)

Painter’s algorithm (depth sorting)

Computationally expensive

– sorting: (n log (n))

– Made in software!

Poorly integrated in the HW schema

– Works in eye coordinates

...but before the HW projection ?!

– Needs to work globally on the scene, not parallelizable

Difficult to test

– When the intervals overlap

It also uses clipping

(31)

Painter’s algorithm (depth sorting)

Only used when the primitives are already

sorted

– During the preprocessing phase

Example: ground represented as an

(32)

Hidden surfaces removal

Solution 3:

– Remove the hidden surfaces with a

FRAGMENT TEST

– "

Z-buffer

“ algorithm

(33)

z-buffer

Algorithm

fr

a

gm

e

nt

s

(c

an

di

da

te

p

ix

el

s)

V

e

rt

ic

es

(p

oi

nt

s

in

R

3

)

P

ro

je

ct

e

d

ve

rt

ic

e

s

(p

oi

nt

s

in

R

2

)

Z

V

er

te

x

c

om

pu

ta

tio

ns

F

ra

gm

en

t

co

m

pu

ta

tio

ns

set-up

set-up

set-up

rasterizer

triangoli

Segments

rasterizer

rasterizer

punti

Triangles

rasterizer

Points

rasterizer

Screen

buffer

Depth

buffer

RGB values

(34)

fr

ag

m

en

ts

(c

an

di

da

te

p

ix

el

s)

V

er

tic

es

(p

oi

nt

s

in

R

3

)

P

ro

je

ct

e

d

ve

rt

ic

es

(p

oi

nt

s

in

R

2

)

Z

V

er

te

x

c

om

pu

ta

tio

ns

F

ra

gm

en

t

co

m

pu

ta

tio

ns

set-up

set-up

set-up

rasterizer

triangoli

Segments

rasterizer

rasterizer

punti

Triangles

rasterizer

Points

rasterizer

Screen

buffer

Depth

buffer

z-buffer

Algorithm

Transform.

Add the

resulting z

As an

attribute

Interpolate

s

the z

(likewise

other

attributes)

depth test

Fragment with screen coordinates

(x,y)

and interpolated z:

if ( z <= DepthBuffer[x,y] ) {

WriteFragment

(35)

fr

a

gm

e

nt

s

(c

an

di

da

te

p

ix

el

s)

V

e

rt

ic

es

(p

oi

nt

s

in

R

3

)

P

ro

je

ct

e

d

ve

rt

ic

e

s

(p

oi

nt

s

in

R

2

)

Z

V

er

te

x

c

om

pu

ta

tio

ns

F

ra

gm

en

t

co

m

pu

ta

tio

ns

set-up

set-up

set-up

rasterizer

triangoli

Segments

rasterizer

rasterizer

punti

Triangles

rasterizer

Points

rasterizer

Screen

buffer

Depth

buffer

z-buffer

Algorithm

(36)

z-buffer

Algorithm

:

example

64 64 64 64 64 64 64 64

64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64

5 5

5

5 5 5 5 5 5 5 64 5 5 5 5 5 5 64 64 5 5 5 5 5 64 64 64 5 5 5 5 64 64 64 64 5 5 5 64 64 64 64 64 5 5 64 64 64 64 64 64 5 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64

+

=

5 5 5 5 5 5 5 64 5 5 5 5 5 5 64 64 5 5 5 5 5 64 64 64 5 5 5 5 64 64 64 64 5 5 5 64 64 64 64 64 5 5 64 64 64 64 64 64 5 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64

7

2 7

5 5 5 5 5 5 5 64 5 5 5 5 5 5 64 64 5 5 5 5 5 64 64 64 5 5 5 5 64 64 64 64 4 5 5 7 64 64 64 64 3 4 5 6 7 64 64 64 2 3 4 5 6 7 64 64 64 64 64 64 64 64 64 64

+

=

5 5 5 5 5 5 5 5 5 5 5 5 5

(37)

z-buffer

Algorithm

:

properties

Does not depend on the order of the primitives

Works in all cases

– even:

Fragment Operation

– Is executed in the

“fragment computations"

Well suited for a HW implementation

5 5 5 5 5 5 5 64

(38)

z-buffer

Algorithm

:

problems

Needs memory

– depth buffer = at least half of screen buffer

Reads and writes shared data

– (the HW implementation should take care)

Problems with

aliasing

– When precision is insufficient

– As an example, if we render two surfaces that

are parallel and very close

Not suitable for transparent surfaces

References

Related documents

Favor you leave and sample policy employees use their job application for absence may take family and produce emails waste company it discusses email etiquette Deviation from

De gir også uttrykk for at de ser betydningen av å være godt forberedt og kunne mestre prosedyrene før de skal utføre de med pasienter.. En student som ikke fikk bestått på

I would recommend that philosophers cut loose from the personhood, criteria driven, approach to the self; rather than offering a new discourse of 'persons' understood as human

Again… deep vascular loss – not typical of glaucoma.. Glaucoma as a diagnosis of exclusion. ▪ Glaucoma defined as a disease of the

In Germany, these include subsidies to the hard coal industry; “eco-taxes” that are to increase energy taxes 10% during 2001–2004 (although, in late 2001, the chancellor’s

CTM is derived from the idea of the Triangular Model (TM), which represents time intervals as points in a two-dimensional space.. 418 The International Arab Journal

Since the signature is extracted from the acceleration signals, the data collection stage is also an acceleration data processing stage, and since this is the operation

Bell-LaPadula: model based on the simple security rule which a subject cannot read data at a higher security level (no-read up) and security rule which a subject cannot