|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
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). | |
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.
Definition at line 67 of file ShadowAtlas.hpp.
|
inline |
Claims count tiles of cells x cells cells each.
| why | Set to the reason on a refusal, AtlasRefusal::None otherwise. |
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().
|
inline |
Definition at line 120 of file ShadowAtlas.hpp.
|
inline |
Gives the whole atlas back. Called once per frame, before any claim.
Definition at line 74 of file ShadowAtlas.hpp.
|
inline |
Definition at line 113 of file ShadowAtlas.hpp.
References esengine::MAX_SHADOW_TILES.
|
inline |
Definition at line 117 of file ShadowAtlas.hpp.
|
inline |
Definition at line 114 of file ShadowAtlas.hpp.
|
inline |
Definition at line 116 of file ShadowAtlas.hpp.
Tile index as a fraction of the atlas: (origin.x, origin.y, side, 0).
| textureSize | Physical 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.