+ All Categories
Home > Documents > Where We Stand At this point we know how to: –Convert points from local to window coordinates...

Where We Stand At this point we know how to: –Convert points from local to window coordinates...

Date post: 19-Jan-2016
Category:
Upload: lauren-norman
View: 212 times
Download: 0 times
Share this document with a friend
24
Where We Stand At this point we know how to: Convert points from local to window coordinates Clip polygons and lines to the view volume Determine which pixels are covered by any given line or polygon – Anti-alias Three methods for figuring out what’s in front Next thing: More on determine which polygon is in front
Transcript
Page 1: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Where We Stand

• At this point we know how to:– Convert points from local to window coordinates– Clip polygons and lines to the view volume– Determine which pixels are covered by any given line

or polygon– Anti-alias– Three methods for figuring out what’s in front

• Next thing:– More on determine which polygon is in front

Page 2: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Depth Sorting (Object Precision, in view space)

• An example of a list-priority algorithm

• Sort polygons on depth of some point

• Render from back to front (modifying order on the fly)

• Rendering: For surface S with greatest depth– If no overlap in depth with other polygons, scan convert

– Else, for overlaps in depth, test for overlaps in the image plane• If none, scan convert and go to next polygon

– If S, S’ overlap in depth and in image plane, swap order and try again

– If S, S’ have been swapped already, split and reinsert

Page 3: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Depth Sorting (2)

• Testing for overlaps: Start drawing when first condition is met:

– x-extents or y-extents do not overlap

– S is behind the plane of S’

– S’ is in front of the plane of S

– S and S’ do not intersect in the image plane

SS’

S

S’or

z

x

SS’

z

x

SS’

SS’

Page 4: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Depth sorting

• Advantages:– Filter anti-aliasing works fine

• Composite in back to front order with a sequence of over operations

– No depth quantization error• Depth comparisons carried out in high-precision view space

• Disadvantages:– Over-rendering– Potentially very large number of splits - (n2)

fragments from n polygons

Page 5: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Area Subdivision

• Exploits area coherence: Small areas of an image are likely to be covered by only one polygon

• Four easy cases for determining what’s in front in a given region:

1. a polygon is completely in front of everything else in that region

2. no surfaces project to the region3. only one surface is completely inside the region,

overlaps the region, or surrounds the region

Page 6: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Warnock’s Area Subdivision (Image Precision)

• Start with whole image• If one of the easy cases is satisfied (previous slide), draw

what’s in front• Otherwise, subdivide the region and recurse• If region is single pixel, choose surface with smallest depth• Advantages:

– No over-rendering– Anti-aliases well - just recurse deeper to get sub-pixel information

• Disadvantage:– Tests are quite complex and slow

Page 7: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Warnock’s Algorithm

• Regions labeled with case used to classify them:1) One polygon in front

2) Empty

3) One polygon inside, surrounding or intersecting

• Small regions not labeled

2 2 2

2222

2

2

3

3

3

3 33

3

3

3

3

3

333

3

3

1

1 1 11

Page 8: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

BSP-Trees (Object Precision)(Watt 2.3.2 and 6.6.10)

• Construct a binary space partition tree– Tree gives a rendering order

– A list-priority algorithm

• Tree splits 3D world with planes– The world is broken into convex cells

– Each cell is the intersection of all the half-spaces of splitting planes on tree path to the cell

• Also used to model the shape of objects, and in other visibility algorithms– BSP visibility in games does not refer to this algorithm

Page 9: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

BSP-Tree ExampleA

C

B

2

4

1

3

A

B C

3 2 4 1

-

- -

+

++

Page 10: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Building BSP-Trees

• Choose polygon (arbitrary)

• Split its cell using plane on which polygon lies– May have to chop polygons in two (Clipping!)

• Continue until each cell contains only one polygon fragment

• Splitting planes could be chosen in other ways, but there is no optimal algorithm for building BSP trees– Optimal means minimum number of polygon fragments in a

balanced tree

Page 11: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

BSP-Tree Rendering

• Observation: Things on the opposite side of a splitting plane from the viewpoint cannot obscure things on the same side as the viewpoint

• Rendering algorithm is recursive descent of the BSP Tree

• At each node (for back to front rendering):– Recurse down the side of the sub-tree that does not contain the

viewpoint

– Draw the polygon in the splitting plane• Paint over whatever has already been drawn

– Recurse down the side of the tree containing the viewpoint

Page 12: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

BSP-Tree Rendering ExampleA

C

B

2

4

1

3

A

B C

3 2 4 1

-

- -

+

++

1st

View

2nd3rd 4th

Page 13: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

BSP-Tree Rendering (2)

• Advantages:– One tree works for any focal point– Filter anti-aliasing and transparency work

• Have back to front ordering for compositing

– Can also render front to back, and avoid drawing back polygons that cannot contribute to the view

• Computer games!

• Disadvantages:– Can be many small pieces of polygon– Over-rendering

Page 14: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Exact Visibility

• An exact visibility algorithm tells you what is visible and only what is visible– No over-rendering– Warnock’s algorithm is an example

• Difficult to achieve efficiently in practice– Small detail objects in an environment make it

particularly difficult

• But, in mazes and other simple environments, exact visibility is extremely efficient

Page 15: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cells and Portals

• Assume the world can be broken into cells– Simple shapes– Rooms in a building, for instance

• Define portals to be the transparent boundaries between cells– Doorways between rooms, windows, etc

• In a world like this, can determine exactly which parts of which rooms are visible– Then render visible rooms plus contents

Page 16: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell and Portal Visibility

• Start in the cell containing the viewer, with the full viewing frustum

• Render the walls of that room and its contents• Recursively clip the viewing frustum to each

portal out of the cell, and call the algorithm on the cell beyond the portal

Page 17: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Example (1)

View

Page 18: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Example (2)

View

Page 19: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Example (3)

View

Page 20: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Example (4)

View

Page 21: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Example (5)

View

Page 22: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Example (6)

View

Page 23: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Operations

• Must clip polygons to the current view frustum (not the original one)– Can be done with additional hardware clipping planes

• Must clip the view frustum to the portal– Easiest to clip portal to frustum, then set frustum to

exactly contain clipped portal

• In Project 2, you implement these things in software

Page 24: Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.

Cell-Portal Properties

• Advantages– Extremely efficient - only looks at cells that are actually

visible: visibility culling

– Easy to modify for approximate visibility - render all of partially visible cells, let depth buffer clean up

– Can handle mirrors as well - flip world about the mirror and pretend mirror is a portal

• Disadvantages– Restricted to environments with good cell/portal structure


Recommended