Hidden Surface Removal

This isn’t something you’d be concerned with at a simple level, it would come in to practice for shaders. E.g. you’d do extra computation at the start to make it quicker in usage.

Back Culling

To optimise Hidden Surface removal we can just ignore all faces pointing away from us (i.e. the face normal is pointing in the same direction we are).

Painter’s Algorithm

Naive Hidden Surface removal would sort polygons by depth and then draw them back to front. (e.g draw sky, draw terrain, draw trees) This runs into issue where faces have different depths (e.g. vertices at different depths so the depth is angled)

Screenshot%202014-09-11%2011.30.13.png

BSP Trees

Binary Space Partitioning Trees pick an object as a starting point, and the left branch is things behind the object, and the right branch is things in front. In some cases this involves an object (‘tree’) being split into 2 parts:
e.g. ROOT:

  • tree(a)
  • tree(b)

Screenshot%202014-09-11%2011.30.16.png

BSP is good for static geometry as it only has to be constructed once. Don’t use for real time as it is slow and can take multiple passes to get a ‘good’ (short) tree.

Screenshot%202014-09-11%2011.30.38.png

A first and final pass in constructing a BSP tree.

Depth Buffer

A depth buffer is a real time way of doing depth testing by creating 2d array of pixels and storing the shallowest drawn point at that location. Then when we come across another point to draw we simply query the depth buffer and check if our depth is shallower than the currently drawn point.

e.g image drawing a pixel at [2,2] and depth 5. We then want to draw a point at [2,2] that is at depth 6. we query and confirm that our depth is greater than 5 and so we don’t draw ourselves. Another point at [2,2] has a depth 3. This is shallower than 5 and so we draw this point.
Typically we use a pseudo depth for this.

Screenshot%202014-09-11%2011.30.46.png

Buffer is implemented in the graphics card for speed

Pixel Depth Computation

We LERP IN TWO DIMENSIONS. STOP THE PRESS MOTHER FUCKER. For polygons use nearby vertices (in a square around the point, as explained above in lerping).

Captain Planet Depth Tests (Z-Filling)

By your powers combined I am Captain Planet. We create a BSP tree of static objects, and as we draw the objects we store the data into the z-buffer. For dynamic objects we use the z-buffer as normal (but now static data is already there and tested :))

Transparency

Transparency is a process by which Government or Business expose their internal workings to the public. In Graphics however it is the opposite of the process by which Malcolm takes a subject and communicates it.

Screenshot%202014-09-11%2011.31.19.png

Transparency is where an object lets through some of the light from an object behind it.

Alpha Channel

A fourth component in the color vertex. It lies between 0 and 1. 1 means opaque. 0 Means invisible.

Alpha Blending (Our friend the lerp)

We can blend colors by lerping between them proportional to their transparency. i.e the color 1 0 0 .5 blended with 0 0 1 1 becomes 0.5 0 0.5 .75

Screenshot%202014-09-11%2011.31.40.png

So e.g. drawing a red dot over green involves a final colour based on the above algorithm

There is one problem. Alpha blending only works if we draw the objects in the correct order - e.g. if we draw the object in front first, then using a depth buffer we won’t ever draw the object in back.

Screenshot%202014-09-11%2011.31.45.png

Hence we have to draw polygons back to front for this to work.