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

The frame's probe volumes, and the trilinear read through them. More...

#include <ProbeStore.hpp>

Classes

struct  Volume
 One volume: a world box, and the grid solved inside it. More...

Public Member Functions

void clear ()
void noteDraw (bool perPixel) const
 Counts a draw that read a volume this frame, per pixel or per object: what the stats say a frame paid.
u32 perPixelDraws () const
u32 perObjectDraws () const
void forgetAtlas ()
 Drops the atlas's layout, so the next layoutAtlas places everything again and says it changed. For a frame that stops reading the atlas (it was released) and may start again.
void add (const glm::vec3 &min, const glm::vec3 &max, const ProbeVolume *grid)
 Takes a volume, or ignores one no point can be inside. A grid whose coefficients do not match its resolution is not half-usable.
bool empty () const
u32 count () const
u64 revision () const
 What the frame's probe volumes say, as a number that changes whenever it does (see core/Revision.hpp): asked after the collect, it moves only when this frame's set differs from the one it last answered for.
bool sample (const glm::vec3 &p, ProbeConstants &out, bool perPixel=false) const
 The irradiance at p, read trilinearly. False = no volume holds it.
bool sampleBox (const glm::vec3 &centre, const glm::vec3 &half, ProbeConstants &out, bool perPixel=false) const
 The volume a whole object stands in, by its world box rather than its origin.
bool layoutAtlas (u32 maxSide)
 Places every volume's grid in the atlas. True when the atlas's texels changed and want uploading.
u32 atlasWidth () const
u32 atlasHeight () const
u32 atlasDepth () const
u64 atlasBytes () const
 What the atlas takes on the GPU: four half floats a texel, no mips. What a sparse grid saves is here.
u32 pageWidth () const
 Texels across one page: the x distance from a coefficient's texel to the next one's.
u32 brickCount () const
 Bricks the atlas holds, across every grid placed.
glm::ivec3 slotOrigin (i32 index) const
 Where brick slot index's first texel sits in page 0.
void fillAtlas (std::vector< u16 > &out) const
 The atlas's texels, RGBA half floats, slice after slice: a coefficient's rgb and the sky's visibility in a (0 for a grid baked without it), and in the indirection page a brick's first texel in xyz and its span in w.
void setAtlasTexture (u32 id)
 The atlas texture this frame's per-pixel runs point into; 0 = none, and every draw reads per object.
u32 atlasTexture () const

Static Public Member Functions

static glm::ivec3 bricksFor (const glm::ivec3 &resolution)
 Bricks along each axis of a grid: enough cells for every probe interval, one on a flat axis.

Static Public Attributes

static constexpr i32 kBrickCells = ProbeVolume::kBrickCells
static constexpr i32 kBrickTexels = ProbeVolume::kBrickSide
static constexpr i32 kAtlasPages = 10
 Pages across the atlas: the nine coefficients', then the indirection's.
static constexpr u32 kReadsPerLookup = 1 + 9
 Texture reads one per-pixel lookup costs: the indirection cell, then a filtered read per coefficient.

Detailed Description

The frame's probe volumes, and the trilinear read through them.

Definition at line 41 of file ProbeStore.hpp.

Member Function Documentation

◆ add()

void esengine::ProbeStore::add ( const glm::vec3 & min,
const glm::vec3 & max,
const ProbeVolume * grid )
inline

Takes a volume, or ignores one no point can be inside. A grid whose coefficients do not match its resolution is not half-usable.

Definition at line 93 of file ProbeStore.hpp.

References esengine::ProbeVolume::isValid().

◆ atlasBytes()

u64 esengine::ProbeStore::atlasBytes ( ) const
inline

What the atlas takes on the GPU: four half floats a texel, no mips. What a sparse grid saves is here.

Definition at line 284 of file ProbeStore.hpp.

Referenced by esengine::renderer_getProbeAtlasBytes().

◆ atlasDepth()

u32 esengine::ProbeStore::atlasDepth ( ) const
inline

Definition at line 282 of file ProbeStore.hpp.

◆ atlasHeight()

u32 esengine::ProbeStore::atlasHeight ( ) const
inline

Definition at line 281 of file ProbeStore.hpp.

◆ atlasTexture()

u32 esengine::ProbeStore::atlasTexture ( ) const
inline

◆ atlasWidth()

u32 esengine::ProbeStore::atlasWidth ( ) const
inline

Definition at line 280 of file ProbeStore.hpp.

◆ brickCount()

u32 esengine::ProbeStore::brickCount ( ) const
inline

Bricks the atlas holds, across every grid placed.

Definition at line 290 of file ProbeStore.hpp.

◆ bricksFor()

glm::ivec3 esengine::ProbeStore::bricksFor ( const glm::ivec3 & resolution)
inlinestatic

Bricks along each axis of a grid: enough cells for every probe interval, one on a flat axis.

Definition at line 60 of file ProbeStore.hpp.

References kBrickCells.

Referenced by layoutAtlas().

◆ clear()

void esengine::ProbeStore::clear ( )
inline

Definition at line 66 of file ProbeStore.hpp.

◆ count()

u32 esengine::ProbeStore::count ( ) const
inline

Definition at line 100 of file ProbeStore.hpp.

Referenced by layoutAtlas().

◆ empty()

bool esengine::ProbeStore::empty ( ) const
inline

Definition at line 99 of file ProbeStore.hpp.

◆ fillAtlas()

void esengine::ProbeStore::fillAtlas ( std::vector< u16 > & out) const
inline

The atlas's texels, RGBA half floats, slice after slice: a coefficient's rgb and the sky's visibility in a (0 for a grid baked without it), and in the indirection page a brick's first texel in xyz and its span in w.

A brick's texel t along an axis is the grid's probe brick * kBrickCells + t, clamped to the grid: the texels past a grid's last probe repeat it, and a read never weights them (it stops at the last probe).

Definition at line 309 of file ProbeStore.hpp.

References esengine::ProbeVolume::bricks, esengine::ProbeVolume::hasSkyVisibility(), esengine::ProbeVolume::irradiance, kBrickCells, esengine::ProbeVolume::kBrickProbes, kBrickTexels, esengine::packHalf(), esengine::ProbeVolume::resolution, esengine::ProbeVolume::skyVisibility, slotOrigin(), and esengine::ProbeVolume::sparse().

◆ forgetAtlas()

void esengine::ProbeStore::forgetAtlas ( )
inline

Drops the atlas's layout, so the next layoutAtlas places everything again and says it changed. For a frame that stops reading the atlas (it was released) and may start again.

Definition at line 82 of file ProbeStore.hpp.

◆ layoutAtlas()

bool esengine::ProbeStore::layoutAtlas ( u32 maxSide)
inline

Places every volume's grid in the atlas. True when the atlas's texels changed and want uploading.

The atlas is kAtlasPages pages side by side along x, each pageWidth() texels wide: page c holds coefficient c of every brick (rgb, and the sky's visibility in a), at the same place in each page, and the last page holds the indirection cells. Brick slots fill a page x first, then y, then z; each grid's indirection block is stacked down z in the last page. A grid that would push any side past maxSide keeps the per-object read. Two volumes reading the same grid share its bricks.

Definition at line 230 of file ProbeStore.hpp.

References esengine::ProbeVolume::bricks, bricksFor(), count(), esengine::ProbeStore::Volume::grid, esengine::ProbeStore::Volume::indirection, kAtlasPages, kBrickTexels, esengine::ProbeVolume::resolution, esengine::ProbeVolume::revision, and esengine::ProbeVolume::sparse().

◆ noteDraw()

void esengine::ProbeStore::noteDraw ( bool perPixel) const
inline

Counts a draw that read a volume this frame, per pixel or per object: what the stats say a frame paid.

Definition at line 73 of file ProbeStore.hpp.

Referenced by esengine::MeshPlugin::collect().

◆ pageWidth()

u32 esengine::ProbeStore::pageWidth ( ) const
inline

Texels across one page: the x distance from a coefficient's texel to the next one's.

Definition at line 288 of file ProbeStore.hpp.

◆ perObjectDraws()

u32 esengine::ProbeStore::perObjectDraws ( ) const
inline

Definition at line 75 of file ProbeStore.hpp.

Referenced by esengine::renderer_getProbeDraws().

◆ perPixelDraws()

u32 esengine::ProbeStore::perPixelDraws ( ) const
inline

Definition at line 74 of file ProbeStore.hpp.

Referenced by esengine::renderer_getProbeDraws().

◆ revision()

u64 esengine::ProbeStore::revision ( ) const
inline

What the frame's probe volumes say, as a number that changes whenever it does (see core/Revision.hpp): asked after the collect, it moves only when this frame's set differs from the one it last answered for.

Definition at line 106 of file ProbeStore.hpp.

References esengine::hash::fnv1aBytes(), esengine::hash::kFnv64Offset, and esengine::nextRevision().

◆ sample()

bool esengine::ProbeStore::sample ( const glm::vec3 & p,
ProbeConstants & out,
bool perPixel = false ) const
inline

The irradiance at p, read trilinearly. False = no volume holds it.

Probes sit on the box's CORNERS, so a volume's own bounds are covered by its own probes and a read never extrapolates. Where two volumes overlap the SMALLER wins: a room inside a hall was baked to say something the hall's spacing could not.

Definition at line 130 of file ProbeStore.hpp.

References esengine::ProbeStore::Volume::grid, esengine::ProbeVolume::hasSkyVisibility(), esengine::ProbeStore::Volume::indirection, esengine::ProbeConstants::irradiance, esengine::ProbeVolume::irradiance, esengine::ProbeStore::Volume::max, esengine::ProbeStore::Volume::min, esengine::ProbeConstants::reflection, esengine::ProbeVolume::resolution, esengine::ProbeVolume::skyVisibility, and esengine::ProbeVolume::sparse().

Referenced by sampleBox().

◆ sampleBox()

bool esengine::ProbeStore::sampleBox ( const glm::vec3 & centre,
const glm::vec3 & half,
ProbeConstants & out,
bool perPixel = false ) const
inline

The volume a whole object stands in, by its world box rather than its origin.

An imported level's meshes keep their origin where the file put it — often the world's origin, far from the walls they draw — so asking at the origin leaves a shed's walls in no volume at all. The box's centre is asked first; a box whose centre is in none reads the smallest volume it overlaps, at the point of that volume nearest its centre. Per pixel, every pixel then reads the grid where it stands anyway.

Definition at line 205 of file ProbeStore.hpp.

References esengine::ProbeStore::Volume::max, esengine::ProbeStore::Volume::min, and sample().

Referenced by esengine::MeshPlugin::collect().

◆ setAtlasTexture()

void esengine::ProbeStore::setAtlasTexture ( u32 id)
inline

The atlas texture this frame's per-pixel runs point into; 0 = none, and every draw reads per object.

Definition at line 387 of file ProbeStore.hpp.

◆ slotOrigin()

glm::ivec3 esengine::ProbeStore::slotOrigin ( i32 index) const
inline

Where brick slot index's first texel sits in page 0.

Definition at line 297 of file ProbeStore.hpp.

References kBrickTexels.

Referenced by fillAtlas().

Member Data Documentation

◆ kAtlasPages

i32 esengine::ProbeStore::kAtlasPages = 10
staticconstexpr

Pages across the atlas: the nine coefficients', then the indirection's.

Definition at line 57 of file ProbeStore.hpp.

Referenced by layoutAtlas().

◆ kBrickCells

i32 esengine::ProbeStore::kBrickCells = ProbeVolume::kBrickCells
staticconstexpr

Cells a brick spans along each axis, and the texels it is stored in: one more, for the probes on its far faces. The grid's own, so a sparse grid's bricks go into the atlas as they are.

Definition at line 54 of file ProbeStore.hpp.

Referenced by bricksFor(), and fillAtlas().

◆ kBrickTexels

i32 esengine::ProbeStore::kBrickTexels = ProbeVolume::kBrickSide
staticconstexpr

Definition at line 55 of file ProbeStore.hpp.

Referenced by fillAtlas(), layoutAtlas(), and slotOrigin().

◆ kReadsPerLookup

u32 esengine::ProbeStore::kReadsPerLookup = 1 + 9
staticconstexpr

Texture reads one per-pixel lookup costs: the indirection cell, then a filtered read per coefficient.

Definition at line 78 of file ProbeStore.hpp.


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