Skip to main content

pack_fog_mask

Function pack_fog_mask 

Source
pub fn pack_fog_mask(
    grid_index: u32,
    origin_cell: [i32; 2],
    width: u32,
    height: u32,
    decks: &[[i32; 2]],
    active_deck: usize,
    memory_dim: f32,
    memory_desaturate: f32,
    cells: &[u8],
) -> Vec<u32>
Expand description

FW.3 — pack a fog mask into fog_mask storage-buffer words.

  • grid_index — the per-grid camera slot the shader gates on (FOG_GRID).
  • origin_cell — grid-local cell of the buffer’s (0, 0).
  • width / height — buffer size in cells.
  • decks(z_top, z_bottom) inclusive bands. Truncated to FOG_MAX_DECKS (with a debug_assert + one-time warn): the shader only scans that many, so a taller deck stack would silently drop its top floors — the truncation is now loud.
  • active_deck — the observer’s deck; every rendered voxel is classified against this layer regardless of its own z (so stairs and sub-floor seen through a hole read on the deck you stand on). Clamped to the deck count.
  • cells — deck-major, row-major mask bytes (d*w*h + y*w + x).

Returns FOG_HEADER_WORDS + ceil(cells.len()/4) words.