69 static glm::ivec3
cellsFor(
const glm::ivec3& res) {
90 if (probes == 0 ||
irradiance.size() !=
static_cast<usize>(probes) * 9)
return false;
91 if (!
sparse())
return true;
92 const glm::ivec3 c =
cells();
104 const glm::ivec3 c =
cells();
106 std::vector<i32> owner(
static_cast<usize>(c.x) *
static_cast<usize>(c.y) *
static_cast<usize>(c.z), -1);
107 for (
usize b = 0; b < list.size(); ++b) {
108 const glm::ivec4 k = list[b];
109 const i32 span = k.w;
110 if (span <= 0 || (span & (span - 1)) != 0)
return false;
111 for (
int a = 0; a < 3; ++a) {
112 if (k[a] < 0 || k[a] >= c[a] || k[a] % span != 0)
return false;
114 for (
i32 z = k.z; z < std::min(k.z + span, c.z); ++z) {
115 for (
i32 y = k.y; y < std::min(k.y + span, c.y); ++y) {
116 for (
i32 x = k.x; x < std::min(k.x + span, c.x); ++x) {
117 i32& o = owner[
static_cast<usize>(x) +
static_cast<usize>(c.x) * (
static_cast<usize>(y) +
static_cast<usize>(c.y) *
static_cast<usize>(z))];
118 if (o >= 0)
return false;
119 o =
static_cast<i32>(b);
124 for (
const i32 o : owner)
if (o < 0)
return false;
Math utilities and GLM configuration for ESEngine.
What a resource's content is, as a number that changes whenever it does.
Core type definitions and utilities for ESEngine.
Irradiance at a grid of points — an Environment sampled, not held.
u64 revision
Changes whenever the coefficients do (a new grid, its sky visibility set): what the frame's probe atl...
static u64 nextRevision()
static constexpr i32 kBrickSide
static constexpr i32 kBrickCells
Cells a brick spans along each axis at its own spacing, and the probes it carries (its far faces too)...
static glm::ivec3 cellsFor(const glm::ivec3 &res)
Finest-brick cells along each axis: enough for every probe interval, one on a flat axis.
u32 probeCount() const
The probes the coefficients hold: the grid's for a dense one, kBrickProbes a brick for a sparse one.
std::vector< glm::ivec4 > bricks
Sparse only: each brick's first finest-brick cell (xyz) and its span in those cells (w)....
std::vector< f32 > skyVisibility
How much of the sky each probe sees: nine coefficients per probe, cosine-convolved like the irradianc...
std::vector< glm::vec3 > irradiance
Nine RGB coefficients per probe: in grid order when dense, brick after brick (each brick's probes x f...
bool hasSkyVisibility() const
bool setBricks(std::vector< glm::ivec4 > list)
Makes the grid sparse with these bricks. False, and the grid left dense, unless they tile it: every s...
static constexpr i32 kBrickProbes
glm::ivec3 resolution
Probes along each axis of the finest grid. One on an axis is a constant along it — which is what an E...
std::vector< i32 > cellBrick
Sparse only: which brick covers each finest-brick cell, x fastest. Built by setBricks.
std::int32_t i32
Signed 32-bit integer.
std::uint64_t u64
Unsigned 64-bit integer.
std::size_t usize
Size type for indexing and sizes.
std::uint32_t u32
Unsigned 32-bit integer.
u64 nextRevision()
A revision no content has had before. Never 0, which reads as "none".