Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::ShadowAtlas Class Reference

A square texture divided into a grid of cells, handed out as square blocks. More...

#include <ShadowAtlas.hpp>

Public Member Functions

 ShadowAtlas (u32 atlasSize, u32 cellSize)
void reset ()
 Gives the whole atlas back. Called once per frame, before any claim.
i32 allocate (u32 count, u32 cells, AtlasRefusal &why)
 Claims count tiles of cells x cells cells each.
void setTileBudget (u32 tiles)
u32 tileBudget () const
u32 tileCount () const
const ShadowTile & tile (u32 index) const
u32 occupiedSize () const
glm::vec4 unitRect (u32 index, u32 textureSize=0) const
 Tile index as a fraction of the atlas: (origin.x, origin.y, side, 0).

Detailed Description

A square texture divided into a grid of cells, handed out as square blocks.

Cell-aligned rather than free-form: a block of n x n cells can only start on a multiple of n, which is what keeps allocation a scan instead of a packing problem, and what makes the order it produces reproducible.

Definition at line 65 of file ShadowAtlas.hpp.

Constructor & Destructor Documentation

◆ ShadowAtlas()

esengine::ShadowAtlas::ShadowAtlas ( u32 atlasSize,
u32 cellSize )
inline

Definition at line 67 of file ShadowAtlas.hpp.

Member Function Documentation

◆ allocate()

i32 esengine::ShadowAtlas::allocate ( u32 count,
u32 cells,
AtlasRefusal & why )
inline

Claims count tiles of cells x cells cells each.

Parameters
whySet to the reason on a refusal, AtlasRefusal::None otherwise.
Returns
The first tile's index, or -1 when the atlas or the tile budget has no room for all of them — all or nothing, so a caller never renders half a cascade set and leaves the rest reading someone else's depths.

The reason is an OUT PARAMETER rather than something a caller may ask for: every refusal here is a light that silently stops casting, and a signature nobody had to read is how that went unrecorded for as long as it did.

Definition at line 91 of file ShadowAtlas.hpp.

References esengine::None, esengine::NoSpace, esengine::TileBudget, and esengine::TooLarge.

Referenced by esengine::claimTiles().

◆ occupiedSize()

u32 esengine::ShadowAtlas::occupiedSize ( ) const
inline

Definition at line 120 of file ShadowAtlas.hpp.

◆ reset()

void esengine::ShadowAtlas::reset ( )
inline

Gives the whole atlas back. Called once per frame, before any claim.

Definition at line 74 of file ShadowAtlas.hpp.

◆ setTileBudget()

void esengine::ShadowAtlas::setTileBudget ( u32 tiles)
inline

Definition at line 113 of file ShadowAtlas.hpp.

References esengine::MAX_SHADOW_TILES.

◆ tile()

const ShadowTile & esengine::ShadowAtlas::tile ( u32 index) const
inline

Definition at line 117 of file ShadowAtlas.hpp.

◆ tileBudget()

u32 esengine::ShadowAtlas::tileBudget ( ) const
inline

Definition at line 114 of file ShadowAtlas.hpp.

◆ tileCount()

u32 esengine::ShadowAtlas::tileCount ( ) const
inline

Definition at line 116 of file ShadowAtlas.hpp.

◆ unitRect()

glm::vec4 esengine::ShadowAtlas::unitRect ( u32 index,
u32 textureSize = 0 ) const
inline

Tile index as a fraction of the atlas: (origin.x, origin.y, side, 0).

Parameters
textureSizePhysical texture side; zero uses the allocation budget.

The origin is the low corner in the convention the atlas is RENDERED in, which is GL's. A backend that samples the other way up turns it over where it samples — see the WGSL twin of shadowFactor3D.

Definition at line 142 of file ShadowAtlas.hpp.

References esengine::ShadowTile::size, esengine::ShadowTile::x, and esengine::ShadowTile::y.


The documentation for this class was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/renderer/store/ShadowAtlas.hpp