Skip to content

raisin::SkyAtmosphereSystem ​

class · #include <rayrai/SkyAtmosphereSystem.hpp>

Owner of the Hillaire sky-atmosphere LUT pipeline (transmittance, multi-scattering, sky-view, aerial-perspective volume).

Extracted from RayraiWindow as part of the 1.1 decomposition. Holds the GL handles for the four LUT textures and their FBOs; renders them on demand. Static LUTs (transmittance + multi-scattering) only re-render when markStaticLutsDirty() has been called or first allocation.

GL ownership: the destructor releases all owned GL handles via release(). Copy disabled per Rule of 5; this class manages raw GL resources that would be double-freed under shallow copy.

Constructors & destructor ​

SkyAtmosphereSystem ​

cpp
SkyAtmosphereSystem() = default
cpp
SkyAtmosphereSystem(const SkyAtmosphereSystem &) = delete
cpp
SkyAtmosphereSystem(SkyAtmosphereSystem &&) = delete

~SkyAtmosphereSystem ​

cpp
~SkyAtmosphereSystem()

Public member functions ​

operator= ​

cpp
SkyAtmosphereSystem &operator=(const SkyAtmosphereSystem &) = delete
cpp
SkyAtmosphereSystem &operator=(SkyAtmosphereSystem &&) = delete

ensureResources ​

cpp
bool ensureResources()

Lazily allocate FBOs + textures for the four LUTs.

Returns true on success; throws if a required framebuffer is incomplete.

release ​

cpp
void release()

Release all owned GL handles. Safe to call multiple times.

render ​

cpp
void render(
    Shader &transmittanceShader,
    Shader &multiScatShader,
    Shader &skyViewShader,
    Shader *apShader,
    unsigned int fullScreenVao,
    const glm::vec3 &sunDirectionHillaire,
    float cameraHeightKm,
    const glm::mat4 &invViewMat,
    const glm::mat4 &invProjMat,
    bool aerialPerspectiveRequired)

Render the sky-atmosphere LUTs. Snapshots and restores the caller's framebuffer + viewport binding so the calling pass is unaffected.

Returns without GL work when no LUT is dirty and the sun direction, camera height (and, for the aerial-perspective volume, camera matrices) match the previous render. Allocates resources on demand.

Parameters

ParameterDescription
transmittanceShadershader to bind for the transmittance LUT pass
multiScatShadershader for the multi-scatter LUT pass
skyViewShadershader for the sky-view LUT pass
apShadershader for the aerial-perspective volume pass; nullable when disabled
fullScreenVaoVAO with a full-screen triangle (gl_VertexID-driven)
sunDirectionHillairedirection TO the sun in world space (Hillaire convention)
cameraHeightKmaltitude of the camera above ground in km
invViewMatinverse of the scene camera's view matrix
invProjMatinverse of the scene camera's projection matrix
aerialPerspectiveRequiredwhether the aerial-perspective volume is sampled this frame

markStaticLutsDirty ​

cpp
void markStaticLutsDirty()

Force the static LUTs (transmittance, multi-scattering) to be recomputed on the next render. Call when atmosphere parameters change. The sky-view and aerial-perspective LUTs are invalidated too.

transmittanceLut ​

cpp
unsigned int transmittanceLut() const

LUT texture handle accessors. Zero means not yet allocated.

Returns Transmittance LUT (256x64).

multiScatLut ​

cpp
unsigned int multiScatLut() const

Returns Multi-scattering LUT (32x32).

skyViewLut ​

cpp
unsigned int skyViewLut() const

Returns Sky-view LUT (192x108).

aerialPerspectiveLut ​

cpp
unsigned int aerialPerspectiveLut() const

Returns Aerial-perspective volume (32x32x32 RGBA16F).

Static member functions ​

uploadEarthAtmosphereUniforms static ​

cpp
static void uploadEarthAtmosphereUniforms(Shader &sh)

Bind the standard Hillaire Earth atmosphere parameters as uniforms on sh. Exposed so the final consumer (skybox / post) can upload the same parameters with one helper.

Parameters

ParameterDescription
shShader to receive the uniforms.

RaiSim — physics for robotics and AI.