Skip to main content

cluster_grid

Function cluster_grid 

Source
fn cluster_grid() -> String
Expand description

The WESL the debug scene’s fragment stage runs, spliced at the built-in stage’s fragment hook.

The grid is composited over the lit color in the fragment hook: cell fills stay translucent so the original light pools remain visible, while borders and the directional-light mark are nearly opaque. Two things are drawn, each from the arithmetic the lookup itself runs, so a border is exactly where the lookup switches:

  • the cell fill: a fixed heat ramp from an empty cell’s dark blue to a full cell’s red. Every record in a cell is a bounded light now – the frame’s directional lights live in the lighting uniform, not the grid – so the whole count is what the ramp shows.
  • the borders, black for the cell’s xy bounds and subdued white for its depth slice. Both are measured in pixels, so they neither thicken into bands nearby nor disappear in the distance. A magenta line along the left edge marks a frame that carries a directional light, which every fragment sees whatever its cell.

The cell borders cross the slice borders rather than one hiding the other, so where a cell ends and where a slice ends stay separate readings.