Docsity

Binary Space Partitioned Trees for Fast and Correct Polygon Ordering in Computer Graphics , Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Binary Space Partitioned Trees for Fast and Correct Polygon Ordering in Computer Graphics and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Binary Space Partitioned Trees

John E. Laird

Motivation

 Want to find fast, correct method for ordering polygons in the Painters algorithm

  • Avoid the five checks of painters algorithm
  • Preprocessing to determine the split planes  Create a binary tree that partitions space.
  • Can use it to find ordering for drawing polygons.
  • Will be << n^2 for rendering  Technique used in Doom, Quake, Descent, ...

General Idea

 Recursively divide space into pairs of regions

  • Stop when regions are “atomic”
    • Doesn’t matter which order walls are drawn no matter where you are in the space: convex
  • Builds up a binary tree  When rendering, traverse tree depth-first, always first rendering region that you are not in
  • This does the right thing! !

BSP Tree Dividing Issues

 Want to maintain a balanced tree if possible  Want to minimize splits of existing walls

  • If divider crosses wall, wall must be split into two walls  Keep dividers orthogonal to principle axes
  • Simplifies math with splits being more likely to be integer values.

Example: Step 1

1

Example: Step 2

2 1

Rendering

 To start with, all we care about ordering of rendering  Not going to worry about line of sight or orientation of viewer  Depth-first traversal, always visiting nodes on opposite side of divisor from current node.

  • Render space when atomic

2 1 3 A B C D A B C D 1 2 3

Rendering

 Go to node 2 (because C is right of divider 1)  Go to A (because C is right of 2)  Render A  Render B  Go to 3  Go to D  Render D  Render C

Inverted Painters: Front-to-Back

 Problem with Back-to-Front is lots of “over-draw”

  • Set same pixel over and over
  • Expensive because of lighting and texture calculations  Front-to-back can avoid this
  • First draw front rooms first
  • Keep track of which pixels are filled in
  • Only draw pixels in back rooms that haven’t been filled in
  • Stop completely when all pixels are filled in
  • Dynamically cuts off processing of rooms far away.

Front-to-Back: Field of View

 Don’t traverse a node if field of view completely on other side of divider. 2 1 3 A B C D

Dynamic Modification of BSP

 Extremely expensive to dynamically recalculate BSP if topology of game can arbitrarily change  Can have pre-stored variants and swap in as world changes

  • Blow holes in walls - open doors
    • Add subtree
  • Different atomic regions
    • Swap in A B C 1 2 3 A B C D 1 2 3

3D Objects in BSP Trees

 Same idea, but render “outside” of object, not “inside”.  Can just drop in to existing BSP tree at the bottom as a child of the atomic region it is in  As 3D object moves, it changes where it is in BSP tree