Class HiZPyramid

java.lang.Object
eu.svjatoslav.aukio.e3d.renderer.raster.HiZPyramid

public final class HiZPyramid extends Object
Hierarchical depth pyramid for whole-block occlusion culling (Hi-Z). Built from the just-painted frame's depth buffer; queried during the NEXT frame's transform to skip blocks that are fully hidden behind what was drawn last frame.

Semantics: each tile stores the MINIMUM w (= 1/z, i.e. the FARTHEST written depth) over its pixels. A block whose nearest possible point (max w over its AABB corners) is farther than a tile's farthest written depth is behind something at every written pixel of that tile — and tiles with any unwritten (sky) pixel hold -infinity and never occlude. That makes the test conservative: it may keep a hidden block, it never culls a visible one — under a static camera. (The first version max-pooled, storing the NEAREST depth per tile; that culled houses visible BETWEEN nearer tree trunks — per-pixel gaps inside a tile are invisible to a max.) Camera motion reuses the stale pyramid, which can cull a newly-visible block wrongly; the block's pixels then contain far background depth, so the next frame's pyramid no longer occludes it — wrong culls self-heal in one frame (sanctioned design concession), and the query margin absorbs small-motion parallax.

Empty tiles (never depth-written) store -infinity and never occlude, so the first frame after startup (or after any pass that leaves the pyramid unbuilt) culls nothing.

Knobs: -Daukio.hiz=false disables culling (build still happens — it is cheap — so flipping the flag needs no warm-up); -Daukio.hiz.margin=0.02 sets the relative w-space safety margin against parallax between frames.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Blocks culled as fully occluded (telemetry).
    Blocks occlusion-tested this process (telemetry).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    buildFrom(float[] depth, int width, int height)
    Rebuilds the pyramid from a freshly painted depth buffer.
    boolean
    occluded(double x1, double y1, double x2, double y2, double nearestW)
    Conservative whole-block occlusion test.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • blocksTested

      public final AtomicLong blocksTested
      Blocks occlusion-tested this process (telemetry).
    • blocksCulled

      public final AtomicLong blocksCulled
      Blocks culled as fully occluded (telemetry).
  • Constructor Details

    • HiZPyramid

      public HiZPyramid()
  • Method Details

    • buildFrom

      public void buildFrom(float[] depth, int width, int height)
      Rebuilds the pyramid from a freshly painted depth buffer.
    • occluded

      public boolean occluded(double x1, double y1, double x2, double y2, double nearestW)
      Conservative whole-block occlusion test.
      Parameters:
      x1 - ..y2 screen-space AABB of the block (will be clamped to the buffer; a fully off-screen box returns false)
      nearestW - the block's nearest possible depth = MAX 1/z over its corners
      Returns:
      true when the block is certainly hidden behind last frame's occluders (within the parallax margin)