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

The two halves of an image-based light, as the importer baked them. More...

#include <Environment.hpp>

Public Member Functions

bool hasSpecular () const

Public Attributes

std::array< glm::vec3, 9 > irradiance {}
resource::TextureHandle specular
resource::TextureHandle sky
 The panorama the sky is drawn from: equirectangular, row 0 up, RGBM under maxRange. Invalid draws the sky from the atlas' mip 0 instead.
f32 faceSize = 0.0f
u32 mipCount = 0
f32 maxRange = 0.0f
u32 columns = 1
 How many octahedral pyramids stand side by side in the atlas.
bool hasSun = false
 The sun the importer found in the panorama: the one compact source a directional light can stand in for. The irradiance above still carries it, so a scene without such a light is lit as the photograph was; one with a light following it takes skyIrradiance instead, or the sun counts twice.
glm::vec3 sunDirection {0.0f, 1.0f, 0.0f}
glm::vec3 sunColor {0.0f}
std::array< glm::vec3, 9 > skyIrradiance {}

Detailed Description

The two halves of an image-based light, as the importer baked them.

The diffuse half is nine spherical-harmonic coefficients, already convolved and divided by pi, so evaluating them at a normal gives the value that multiplies albedo — where the flat ambient term sits. The specular half is an octahedral atlas, mip i for roughness i/(mipCount-1).

Definition at line 25 of file Environment.hpp.

Member Function Documentation

◆ hasSpecular()

bool esengine::Environment::hasSpecular ( ) const
inline

Definition at line 60 of file Environment.hpp.

References faceSize, mipCount, and specular.

Member Data Documentation

◆ columns

u32 esengine::Environment::columns = 1

How many octahedral pyramids stand side by side in the atlas.

One for a sky imported from a panorama. A scene's BAKE writes several — column 0 the sky it was baked under, the rest a reflection probe each — so one bound texture serves them all.

Definition at line 45 of file Environment.hpp.

◆ faceSize

f32 esengine::Environment::faceSize = 0.0f

Edge length of mip 0's octahedral face, in texels.

Definition at line 36 of file Environment.hpp.

Referenced by hasSpecular().

◆ hasSun

bool esengine::Environment::hasSun = false

The sun the importer found in the panorama: the one compact source a directional light can stand in for. The irradiance above still carries it, so a scene without such a light is lit as the photograph was; one with a light following it takes skyIrradiance instead, or the sun counts twice.

Definition at line 51 of file Environment.hpp.

Referenced by esengine::environment_setSun().

◆ irradiance

std::array<glm::vec3, 9> esengine::Environment::irradiance {}

Definition at line 27 of file Environment.hpp.

◆ maxRange

f32 esengine::Environment::maxRange = 0.0f

RGBM decode range: (rgb*a)^2 * maxRange is the stored radiance.

Definition at line 39 of file Environment.hpp.

◆ mipCount

u32 esengine::Environment::mipCount = 0

Definition at line 37 of file Environment.hpp.

Referenced by hasSpecular().

◆ sky

resource::TextureHandle esengine::Environment::sky

The panorama the sky is drawn from: equirectangular, row 0 up, RGBM under maxRange. Invalid draws the sky from the atlas' mip 0 instead.

Definition at line 33 of file Environment.hpp.

◆ skyIrradiance

std::array<glm::vec3, 9> esengine::Environment::skyIrradiance {}

The same nine coefficients with the sun's texels replaced by the sky around it.

Definition at line 58 of file Environment.hpp.

Referenced by esengine::environment_setSun().

◆ specular

resource::TextureHandle esengine::Environment::specular

Definition at line 29 of file Environment.hpp.

Referenced by hasSpecular().

◆ sunColor

glm::vec3 esengine::Environment::sunColor {0.0f}

The sun's irradiance over pi per channel — what a surface facing it adds to albedo, the unit the coefficients are in and a light's colour times intensity is.

Definition at line 56 of file Environment.hpp.

Referenced by esengine::environment_setSun().

◆ sunDirection

glm::vec3 esengine::Environment::sunDirection {0.0f, 1.0f, 0.0f}

Toward the sun, in the panorama's own frame (before any environment rotation).

Definition at line 53 of file Environment.hpp.

Referenced by esengine::environment_setSun().


The documentation for this class was generated from the following file: