Log inGet started
Package

overheadCover.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

overheadCover

The overhead cover map: the highest surface over each point of the ground around the camera, drawn from every rigid opaque mesh the renderer holds, entity-owned and instanced alike, at the detail a texel holds, in a render whose map changed. A render feature that lights the air reads it to know how much of the sky a point sees past what stands over it.

local OverheadCover = require("@builtin::systems.skyVisibility.overheadCover")

OverheadCover.enqueue(ctx)          -- in render(ctx): draws the map at afterLighting when it changed
OverheadCover.target()              -- the map's target guid, bound as `overhead_map`
OverheadCover.release()             -- in teardown: frees the map and its material

The map is 256 by 256 texels of 1 world unit, centred on the anchor of the camera being drawn: its position rounded to whole 32-unit steps. A texel holds the height of the highest surface over it, measured from the anchor's height, in .r and 1 in .g, and 0 in both where nothing stands over it.

The pass states a version and the step (viewStep = 32), so the engine draws the map only in a render whose map changed: a mesh it holds moved, arrived, left or changed, or the camera crossed into another step. Every other render reads the map as it stands, and a still scene costs it nothing. A pass reads it through @builtin::systems.skyVisibility.overhead_openness.

Each mesh draws at the coarsest cut of its cluster hierarchy whose error stays within a texel (the pass's detail), so a dense mesh costs the map about what its outline at 1 unit holds. A mesh a skeleton poses or morph targets blend (a character, a creature) is left out (the pass's rigid): it stands in the air the map shades rather than over it. renderer.feature.drawn().__overhead_cover reads the objects and triangles the map drew on the last frame.