Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualHodgman

Posted 16 January 2013 - 07:17 AM

I'm definatly taking the approach of CPU depth rasterizer rather than the 1-bit per pixel approach. Not sure how they map that to the objects being rendered

Bare with me --

In this old thread from 2003, treething mentions that you can speed up depth rasterization by, instead of interpolating depth across a triangle using the values from the 3 vertices, you can just find the furthest of the 3 vertices and use it's depth as a constant across the whole triangle. This increases false-positives (where something is really hidden, but the OC says it's not occluded) in cases where your triangles are at steep angles, but saves you a few instructions.

 

For occludees (the things you're testing for occlusion), you could also rasterize them as triangles (e.g. if performing something similar to hardware occlusion queries -- counting how many pixels would have been filled), but instead of picking the max depth per-triangle, for these you pick the min-depth per triangle to make sure you don't end up with false-negatives.

 

In that article that I linked, they're taking this idea to the extreme -- if every triangle has a constant depth value, then you can pre-sort the triangles from front to back, using max-z for occluders and min-z for occludees. You then loop through the sorted list, processing the triangles from front to back.

Occluders write a 1 to every pixel that they cover, whereas occludees test all their pixels to see if any are a 0 (as soon as a 0 is found, they early exit and mark the object as being visible).

In this system, you don't need to render depth at all. Whenever you're testing an occludee triangle, your "render target" contains a boolean mask of which parts of the scene are covered by geometry that is closer to the camera than the occludee is! All you need to know is whether the occludee is fully covered by this mask or not.

 

At the end of this process, your render-target will likely be completely full of 1's and is of no use -- the occludee testing work is interleaved with the rasterizing of occluders, so that just the right amount of occluders have been drawn so far whenever something is tested.


#1Hodgman

Posted 16 January 2013 - 07:10 AM

I'm definatly taking the approach of CPU depth rasterizer rather than the 1-bit per pixel approach. Not sure how they map that to the objects being rendered

Bare with me --

In this old thread from 2003, someone mentions that you can speed up depth rasterization by, instead of interpolating depth across a triangle using the values from the 3 vertices, you can just find the furthest of the 3 vertices and use it's depth as a constant across the whole triangle. This increases false-positives (where something is really hidden, but the OC says it's not occluded) in cases where your triangles are at steep angles, but saves you a few instructions.

 

For occludees (the things you're testing for occlusion), you could also rasterize them as triangles, but instead of picking the max depth per-triangle, for these you pick the min-depth per triangle.

 

In that article that I linked, they're taking this idea to the extreme -- if every triangle has a constant depth value, then you can pre-sort the triangles from front to back, using max-z for occluders and min-z for occludees. You then loop through the sorted list, processing the triangles from front to back.

Occluders write a 1 to every pixel that they cover, whereas occludees test all their pixels to see if any are a 0 (as soon as a 0 is found, they early exit and mark the object as being visible).

In this system, you don't need to render depth at all. Whenever you're testing an occludee triangle, your "render target" contains a boolean mask of which parts of the scene are covered by geometry that is closer to the camera than the occludee is! All you need to know is whether the occludee is fully covered by this mask or not.

 

At the end of this process, your render-target will likely be completely full of 1's and is of no use -- the occlusion testing work is interleaved with the rasterizing of occluders, so that just the right amount of occluders have been drawn so far whenever something is tested.


PARTNERS