Visible Surface Determination: Painter's Algorithm, Z-Buffer Algorithm, and Ray Casting - , Study notes of Computer Graphics

Various methods for determining the visible surface in computer graphics, including the painter's algorithm, z-buffer algorithm, and ray casting. The strengths and weaknesses of each method and provides insights into making them more efficient.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-8hj
koofers-user-8hj 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Visible Surface Determination
Rasterization will convert are primitives to pixels in the image
but we need to make sure we don’t draw occluded objects
For each pixel, what is the nearest object in the scene?
this is the only thing we need to draw at this pixel
provided the object isn’t trans parent
we need to determine the visible surface
Painter’s Algorithm
Developed thousands of years ago
probably by cave dwellers
Draws every object in depth order
from back to front
near objects overwrite far objects
What could be simpler?
Painter’s Algorithm:
sort objects back to front
loop over objects
rasterize current object
write pixels
first second third
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Visible Surface Determination: Painter's Algorithm, Z-Buffer Algorithm, and Ray Casting - and more Study notes Computer Graphics in PDF only on Docsity!

Visible Surface Determination

Rasterization will convert are primitives to pixels in the image • but we need to make sure we don’t draw occluded objects For each pixel, what is the nearest object in the scene? • this is the only thing we need to draw at this pixel

  • we need to determine the^ –^ provided the object isn’t transparent visible surface

Painter’s Algorithm

Developed thousands of years ago • probably by cave dwellers Draws every object in depth order • from back to front

  • near objects overwrite far objects What could be simpler?

Painter’s Algorithm: sort objects back to front loop over objects rasterize current object write pixels first second (^) third

But the Catch is in the Depth Sorting

What do we sort by? • minimum z value — no maximum z value — no

  • in fact, there’s no single z value we can sort by

Worse yet, depth ordering of objects can be cyclic • may need to split polygons to break cycles

Looking at Painter’s Algorithm

It has some nice strengths

  • • the principle is very simplehandles transparent objects nicely
    • just composite new pixels with what’s already there But it also has some noticeable weaknesses • general sorting is a little expensive — worse than O(n)
  • • need to do splitting for depth cycles, interpenetration,and what if the objects aren’t planar polygons? …

Looking at the Z-Buffer Algorithm

It has some attractive strengths • it’s very simple, and easy to implement in hardware

  • can easily accommodate any primitive you can – not just planar polygons rasterize

But it does have a few problems • it doesn’t handle transparency well

  • needs intelligent selection of – z-buffers typically use integer depth values znear & zfar clipping planes
    • fixed bit precision mapped to range znear..zfar

Making Z-Buffers Efficient

When we • we could just compute it at every pixel rasterize a polygon, we need z value at each pixel

  • but this is pretty expensive Can use a handy • the projected polygon satisfies some plane equation incrementalization trick
  • we could compute the depth as
  • but taking account of coherence

ax + by + cz + d = 0 z d^ ax^ by c

=^!^!^!

! z = "^ a c! x for fixed values of y

Ray Casting

This is a very general algorithm • works with any primitive we can write intersection tests for

  • but it’s hard to make it run fast We’ll come back to this idea later can use it for much more than visibility testing
  • shadows, refractive objects, reflections, motion blur, …

Ray Casting: loop over every pixel (x,y) shoot ray from eye through (x,y) intersect with all surfaces find first intersection point write pixel

Culling

Rendering is expensive — Don’t draw what you can’t see

  • this becomes critical for top efficiency What can • anything in complete shadow ’t we see?
  • • anything very much smaller than a pixelanything occluded by another object
  • anything outside view volume We’ll focus on the last two categories

Culling with Bounding Volumes

Let’ s enclose our object in a bounding sphere convex volume

  • – compact representationmay not fit object tightly
  • bounding box – axis-aligned or oriented with object
  • convex – allows tightest fit polytope
  • most expensive to deal with Now test bounding volume first • if outside frustum, reject object
  • otherwise visit individual components

Hierarchical Bounding Volumes

And we can do even better with a hierarchy of volumes Begin testing at the root node • if outside, reject all objects

  • otherwise, recursively test sub-nodes Of course this raises the question: how best to build this hierarchy?

Back-face Culling

Even for polygons inside frustum, some may be culled • if we assume that our objects are closed

Consider the normal of a given polygon • if it’s pointing towards the eye, we may be able to see it

  • pointing away means it’s on the opposite side of the object So, any back-facing polygon can be culled • again, assuming closed objects
  • see glCullFace(…)

Visibility in Complex Worlds

Highly complex scenes lead to significant problems

  • basic system draws every polygon every time We talked about culling to cut down on number of polygons • visibility culling is important for really high performance
  • • hierarchical z-buffers are one examplecompute potentially visible sets for static worlds

To better resolve visibility, we often use spatial data structures

  • • octreeshierarchical bounding volumes
  • • gridsBSP trees