Skip to content

Class Environment

ClassList > Environment

Environment object providing skybox and Image-Based Lighting.More...

  • #include <Environment.h>

Inherits the following classes: ObjectID, Transform3D

Public Types inherited from ObjectID

See ObjectID

Type Name
enum GOType
Enumeration of scene object types.

Public Types inherited from Transform

See Transform

Type Name
enum TransType
Flags for enabling/disabling transform components.

Public Attributes

Type Name
Texture envir_IBL_diff
Diffuse irradiance cubemap (precomputed convolution)
Texture envir_IBL_spec
Specular prefiltered cubemap (precomputed roughness mipmaps)
glm::vec3 envir_color = glm::vec3(1.0f)
Tint color for skybox (linear space)
float envir_gamma = 2.2f
Gamma correction for skybox display.
RenderShader envir_shader
Shader for rendering skybox.
Sprite envir_sprite
Visual gizmo for editor viewport.
EnvironmentType envir_type = EnvironmentType::NONE\_ENVIR
Active environment type.
bool use_envir = false
Enable environment rendering and IBL.

Public Attributes inherited from ObjectID

See ObjectID

Type Name
bool is_rendered = true
Included in rendering pipeline.
bool is_viewport = true
Visible in viewport (editor-only)
std::string o_name
Display name in editor UI .
GOType o_type = NONE\_GO
Runtime type identifier.

Public Attributes inherited from Transform3D

See Transform3D

Type Name
glm::mat4 o_InvTransform = { 1.0f }
Cached inverse world transform matrix.
glm::mat4 o_Transform = { 1.0f }
Cached world transform matrix.
glm::vec3 o_dir_right = { 1.0f, 0.0f, 0.0f }
Right direction vector (X+)
glm::vec3 o_dir_up = { 0.0f, 1.0f, 0.0f }
Up direction vector (Y+)
glm::vec3 o_position = { 0.0f }
World position.
glm::vec3 o_rot = { 0.0f }
Euler rotation angles (radians): pitch, yaw, roll.
glm::vec3 o_scale = { 1.0f }
Local scale (non-uniform allowed)

Public Attributes inherited from Transform

See Transform

Type Name
bool is_TransF_changed = true
Transform matrix needs recomputation.
bool is_Uniform_changed = true
Uniform (non-scaled) transform needs recomputation.
bool is_invTransF_changed = true
Inverse transform needs recomputation.
bool is_invUniform_changed = true
Inverse uniform transform needs recomputation.
bool use_position = { true }
Enable position component in transform computation.
bool use_rotation = { true }
Enable rotation component in transform computation.
bool use_scale = { true }
Enable scale component in transform computation.

Public Functions

Type Name
void BindEnvironTexture () const
Binds IBL textures to shader slots.
void BindFrameBuffer () const
Binds environment framebuffer for rendering.
void ChangeEnvirTexture (const std::string & texpath) const
Changes environment texture.
void ChangeEnvirType (EnvironmentType type) const
Changes environment type.
Environment ()
Constructs a default environment with no texture.
Environment (const std::string & texpath)
Constructs an environment from HDR texture file.
virtual void * GetShader () override
Returns pointer to skybox shader.
virtual void * GetTransform () override
Returns pointer to transform.
void RenderEnvirSpr (const Context & ctx)
Renders environment sprite gizmo in viewport.
void RenderEnvironment (const Context & ctx)
Renders environment skybox to active framebuffer.
void SwapFrameBuffer (FBType type)
Swaps environment framebuffer attachments.
void UnbindEnvironTexture () const
Unbinds IBL textures.
void UnbindFrameBuffer () const
Unbinds environment framebuffer.

Public Functions inherited from ObjectID

See ObjectID

Type Name
virtual void * GetMaterial ()
Returns pointer to object's material, if applicable.
virtual void * GetShader ()
Returns pointer to object's shader, if applicable.
virtual void * GetTransform ()
Returns pointer to object's transform, if applicable.
ObjectID ()
Constructs an ObjectID with default values.
void SetVisible (bool v, bool r)
Sets visibility flags for viewport and rendering.
~ObjectID ()
Destroys the ObjectID .

Public Functions inherited from UID

See UID

Type Name
int GetObjectID () const
Returns the unique ID of this object.
UID ()
Constructs a UID and assigns a unique ID.
virtual ~UID () = default
Virtual destructor for polymorphic use.

Public Functions inherited from Transform3D

See Transform3D

Type Name
virtual bool ApplyAllTransform () override
Recomputes transform and all parent transforms.
virtual bool ApplyTransform (bool _forced=false) override
Recomputes transform matrix if dirty.
Transform3D * GetChildTransPtr ()
Returns pointer to first child transform.
virtual bool GetInvTransform () override const
Computes inverse transform matrix.
Transform3D * GetParentTransPtr ()
Returns pointer to parent transform.
Transform3D * GetTransformPtr ()
Returns pointer to this transform.
void LookAt (const glm::vec3 & tar, const glm::vec3 & up={0, 0, 1})
Orients transform to look at target position.
void Move (const glm::vec3 & d_pos)
Translates position by offset.
void SetParent (Transform3D * _p_trans, bool _keep_offset=true)
Sets parent transform for hierarchy.
bool SetPos (const glm::vec3 & pos)
Sets world position.
bool SetPos1D (float _1d, GLuint _dim)
Sets single axis of position.
bool SetRot (const glm::vec3 & rot)
Sets rotation via Euler angles.
bool SetRot1D (float _1d, GLuint _dim)
Sets single axis of rotation.
bool SetScale (const glm::vec3 & scale)
Sets local scale.
bool SetScale1D (float _1d, GLuint _dim)
Sets single axis of scale.
bool SetTrans (const glm::mat4 & _trans, bool pos=true, bool rot=true, bool scl=true)
Sets transform from 4x4 matrix.
void Spin (const glm::vec3 & anch, const glm::vec3 & axis, const float & angle)
Rotates around arbitrary axis through anchor point.
void Spin (const glm::vec3 & anch, const glm::vec2 & angle, bool global_up=true)
Rotates around anchor with pitch/yaw.
void Trans (const glm::mat4 & _trans)
Applies transformation matrix to current transform.
Transform3D ()
Constructs a Transform3D with identity values.
virtual void UnsetParent (bool _keep_offset=true) override
Removes parent transform relationship.
virtual int _debug () override const
Debug utility for transform state inspection.
~Transform3D ()
Destroys the Transform3D .

Public Functions inherited from Transform

See Transform

Type Name
virtual bool ApplyAllTransform () = 0
Recomputes transform and all parent transforms.
virtual bool ApplyTransform (bool _forced=false) = 0
Recomputes transform matrix if dirty.
virtual bool GetInvTransform () const = 0
Computes inverse transform matrix.
virtual void UnsetParent (bool _keep_offset=true) = 0
Removes parent transform relationship.
void UseTranformComp (bool _enable, TransType _type)
Enables or disables specific transform components.
virtual int _debug () const = 0
Debug utility for transform state inspection.

Public Static Functions inherited from UID

See UID

Type Name
int GetTotalAllocated ()
Returns total number of UIDs allocated.

Detailed Description

Environment defines the scene's background and ambient lighting via IBL. It supports HDR texture environments (equirectangular or cubemap), solid color backgrounds, and procedural noise. IBL textures (diffuse irradiance and specular prefiltered) are used in the PBR lighting model.

Resource Ownership: * envir_IBL_diff: Diffuse irradiance cubemap (owned by Environment) * envir_IBL_spec: Specular prefiltered cubemap (owned by Environment) * envir_shader: Skybox rendering shader (owned by Environment)

Rendering Pipeline Integration: * Background pass: Renders skybox as fullscreen quad at infinite depth * IBL pass: Samples irradiance and prefiltered maps for ambient lighting * Sprite rendering: Displays environment icon in editor viewport

Note:

Inheritance: ObjectID for scene identity, Transform3D for rotation.

Note:

Thread-safety: Not thread-safe. Access from main thread only.

Note:

Gamma correction: envir_gamma controls skybox brightness adjustment.

Public Attributes Documentation

variable envir_IBL_diff

Diffuse irradiance cubemap (precomputed convolution)

Texture Environment::envir_IBL_diff;


variable envir_IBL_spec

Specular prefiltered cubemap (precomputed roughness mipmaps)

Texture Environment::envir_IBL_spec;


variable envir_color

Tint color for skybox (linear space)

glm::vec3 Environment::envir_color;


variable envir_gamma

Gamma correction for skybox display.

float Environment::envir_gamma;


variable envir_shader

Shader for rendering skybox.

RenderShader Environment::envir_shader;


variable envir_sprite

Visual gizmo for editor viewport.

Sprite Environment::envir_sprite;


variable envir_type

Active environment type.

EnvironmentType Environment::envir_type;


variable use_envir

Enable environment rendering and IBL.

bool Environment::use_envir;


Public Functions Documentation

function BindEnvironTexture

Binds IBL textures to shader slots.

void Environment::BindEnvironTexture () const

Note:

Binds envir_IBL_diff and envir_IBL_spec for lighting shader access.


function BindFrameBuffer

Binds environment framebuffer for rendering.

void Environment::BindFrameBuffer () const

Note:

Used for environment map generation or post-processing.


function ChangeEnvirTexture

Changes environment texture.

void Environment::ChangeEnvirTexture (
    const std::string & texpath
) const

Parameters:

  • texpath Path to new HDR environment map

Note:

Reloads IBL textures from new environment map.


function ChangeEnvirType

Changes environment type.

void Environment::ChangeEnvirType (
    EnvironmentType type
) const

Parameters:

  • type New environment type (TEXTURE_ENVIR, COLOR_ENVIR, etc.)

Note:

Switches rendering mode and IBL availability.


function Environment [1/2]

Constructs a default environment with no texture.

Environment::Environment () 

Note:

Type defaults to NONE_ENVIR (black background).


function Environment [2/2]

Constructs an environment from HDR texture file.

Environment::Environment (
    const std::string & texpath
) 

Parameters:

  • texpath Path to HDR environment map (equirectangular or cubemap)

Note:

Automatically generates IBL textures from input map.


function GetShader

Returns pointer to skybox shader.

inline virtual void * Environment::GetShader () override

Returns:

Pointer to RenderShader as void* (cast required)

Note:

Overrides ObjectID::GetShader() for polymorphic access.

Implements ObjectID::GetShader


function GetTransform

Returns pointer to transform.

inline virtual void * Environment::GetTransform () override

Returns:

Pointer to Transform3D as void* (cast required)

Note:

Overrides ObjectID::GetTransform() for polymorphic access.

Implements ObjectID::GetTransform


function RenderEnvirSpr

Renders environment sprite gizmo in viewport.

void Environment::RenderEnvirSpr (
    const Context & ctx
) 

Parameters:

  • ctx Context providing camera and viewport state

Note:

Used by editor to display environment icon (not part of scene rendering).


function RenderEnvironment

Renders environment skybox to active framebuffer.

void Environment::RenderEnvironment (
    const Context & ctx
) 

Parameters:

  • ctx Context providing camera for view/projection matrices

Note:

Renders fullscreen quad with skybox shader at infinite depth.


function SwapFrameBuffer

Swaps environment framebuffer attachments.

void Environment::SwapFrameBuffer (
    FBType type
) 

Parameters:

  • type Framebuffer type to swap to

Note:

Used for ping-pong rendering during IBL generation.


function UnbindEnvironTexture

Unbinds IBL textures.

void Environment::UnbindEnvironTexture () const


function UnbindFrameBuffer

Unbinds environment framebuffer.

void Environment::UnbindFrameBuffer () const



The documentation for this class was generated from the following file src/scene/Environment.h