Class Light
Light source object supporting point, sun, spot, and area lights.More...
#include <Light.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 |
|---|---|
| float | area_ratio = { 1.0f }Aspect ratio (width/height) of rectangular area light. |
| bool | is_light_changed = { false }Dirty flag indicating light parameters changed since last frame. |
| glm::vec3 | light_color = { 1.0f }RGB color multiplier (linear space) |
| float | light_power = { 1.0f }Luminous intensity (arbitrary units) |
| float | light_radius = { 0.05f }Physical radius for soft shadows. |
| Sprite | light_sprite Visual gizmo for editor viewport. |
| LightType | light_type = { LightType::NONELIGHT }Type of light source. |
| float | spot_cutoff = { 0.9f }Inner cone cosine (full brightness) |
| float | spot_outer_cutoff = { 0.8f }Outer cone cosine (falloff to zero) |
| bool | use_shadow = { true }Enable shadow casting for this light. |
Public Attributes inherited from ObjectID
See ObjectID
| Type | Name |
|---|---|
| bool | is_rendered = trueIncluded in rendering pipeline. |
| bool | is_viewport = trueVisible in viewport (editor-only) |
| std::string | o_name Display name in editor UI . |
| GOType | o_type = NONE\_GORuntime 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 = trueTransform matrix needs recomputation. |
| bool | is_Uniform_changed = trueUniform (non-scaled) transform needs recomputation. |
| bool | is_invTransF_changed = trueInverse transform needs recomputation. |
| bool | is_invUniform_changed = trueInverse 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 Static Attributes
| Type | Name |
|---|---|
| float | area_blur_range = 0.04fBlur kernel size for soft area shadows. |
| float | area_shaodow_far = 25.0fFar plane for area light shadow map. |
| float | area_shaodow_near = 0.1fNear plane for area light shadow map. |
| float | point_blur_range = 0.02fBlur kernel size for soft point shadows. |
| float | point_shaodow_far = 25.0fFar plane for point light shadow map. |
| float | point_shaodow_near = 0.1fNear plane for point light shadow map. |
| float | spot_blur_range = 0.02fBlur kernel size for soft spot shadows. |
| float | spot_shaodow_far = 25.0fFar plane for spot light shadow map. |
| float | spot_shaodow_near = 0.1fNear plane for spot light shadow map. |
| float | sun_shaodow_far = 5.0fFar plane for sun shadow map. |
| float | sun_shaodow_field = 5.0fOrthographic projection field size for sun shadows. |
| float | sun_shaodow_near = -5.0fNear plane for sun shadow map. |
Public Functions
| Type | Name |
|---|---|
| virtual void * | GetShader () override Returns pointer to shadow map shader. |
| virtual void * | GetTransform () override Returns pointer to Transform component. |
| Light () Constructs a light with default values. |
|
| Light (LightType type, float power=10, glm::vec3 color=glm::vec3{ 1, 1, 1 }) Constructs a light with specified type, power, and color. |
|
| void | RenderLightSpr (const Context & ctx) Renders light sprite gizmo in viewport. |
| void | SetColor (const glm::vec3 & _col) Sets light color. |
| void | SetCutoff (float _ang) Sets spot light inner cutoff angle. |
| void | SetOuterCutoff (float _ang) Sets spot light outer cutoff angle. |
| void | SetPower (float _power) Sets light power/intensity. |
| void | SetRadius (float _rad) Sets point light radius. |
| void | SetRatio (float _ratio) Sets area light aspect ratio. |
| void | SetShadow (bool _state) Enables or disables shadow casting. |
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
| Type | Name |
|---|---|
| std::pair< SpriteType, std::string > | ParseLightName (LightType _type) Parses light type to sprite icon and name. |
Public Static Functions inherited from UID
See UID
| Type | Name |
|---|---|
| int | GetTotalAllocated () Returns total number of UIDs allocated. |
Detailed Description
Light provides PBR lighting with configurable type, color, power, and shadow flags. Transform3D determines position/orientation, while type-specific parameters control light shape (radius for point, cutoff for spot, ratio for area).
Note:
Shadow map rendering, projection matrices, and GPU resources are managed by ShadowSystem (src/render/ShadowSystem.h).
Note:
Inheritance: ObjectID for scene identity, Transform3D for spatial transform.
Note:
Thread-safety: Not thread-safe. Access from main thread only.
Public Attributes Documentation
variable area_ratio
Aspect ratio (width/height) of rectangular area light.
float Light::area_ratio;
variable is_light_changed
Dirty flag indicating light parameters changed since last frame.
bool Light::is_light_changed;
variable light_color
RGB color multiplier (linear space)
glm::vec3 Light::light_color;
variable light_power
Luminous intensity (arbitrary units)
float Light::light_power;
variable light_radius
Physical radius for soft shadows.
float Light::light_radius;
variable light_sprite
Visual gizmo for editor viewport.
Sprite Light::light_sprite;
variable light_type
Type of light source.
LightType Light::light_type;
variable spot_cutoff
Inner cone cosine (full brightness)
float Light::spot_cutoff;
variable spot_outer_cutoff
Outer cone cosine (falloff to zero)
float Light::spot_outer_cutoff;
variable use_shadow
Enable shadow casting for this light.
bool Light::use_shadow;
Public Static Attributes Documentation
variable area_blur_range
Blur kernel size for soft area shadows.
float Light::area_blur_range;
variable area_shaodow_far
Far plane for area light shadow map.
float Light::area_shaodow_far;
variable area_shaodow_near
Near plane for area light shadow map.
float Light::area_shaodow_near;
variable point_blur_range
Blur kernel size for soft point shadows.
float Light::point_blur_range;
variable point_shaodow_far
Far plane for point light shadow map.
float Light::point_shaodow_far;
variable point_shaodow_near
Near plane for point light shadow map.
float Light::point_shaodow_near;
variable spot_blur_range
Blur kernel size for soft spot shadows.
float Light::spot_blur_range;
variable spot_shaodow_far
Far plane for spot light shadow map.
float Light::spot_shaodow_far;
variable spot_shaodow_near
Near plane for spot light shadow map.
float Light::spot_shaodow_near;
variable sun_shaodow_far
Far plane for sun shadow map.
float Light::sun_shaodow_far;
variable sun_shaodow_field
Orthographic projection field size for sun shadows.
float Light::sun_shaodow_field;
variable sun_shaodow_near
Near plane for sun shadow map.
float Light::sun_shaodow_near;
Public Functions Documentation
function GetShader
Returns pointer to shadow map shader.
virtual void * Light::GetShader () override
Returns:
Pointer to ChainedShader as void*
Implements ObjectID::GetShader
function GetTransform
Returns pointer to Transform component.
inline virtual void * Light::GetTransform () override
Returns:
Pointer to Transform3D as void* (cast required)
Implements ObjectID::GetTransform
function Light [1/2]
Constructs a light with default values.
Light::Light ()
function Light [2/2]
Constructs a light with specified type, power, and color.
Light::Light (
LightType type,
float power=10,
glm::vec3 color=glm::vec3{ 1, 1, 1 }
)
Parameters:
typeLight type (POINTLIGHT, SUNLIGHT, SPOTLIGHT, AREALIGHT)powerLuminous intensity (default: 10)colorRGB color (default: white)
function RenderLightSpr
Renders light sprite gizmo in viewport.
void Light::RenderLightSpr (
const Context & ctx
)
Parameters:
ctxContext providing camera and viewport state
Note:
Used by editor to display light icons (not part of scene rendering).
function SetColor
Sets light color.
void Light::SetColor (
const glm::vec3 & _col
)
Parameters:
_colNew RGB color in linear space
function SetCutoff
Sets spot light inner cutoff angle.
void Light::SetCutoff (
float _ang
)
Parameters:
_angCosine of inner cone angle
Note:
Only applicable to SPOTLIGHT type.
function SetOuterCutoff
Sets spot light outer cutoff angle.
void Light::SetOuterCutoff (
float _ang
)
Parameters:
_angCosine of outer cone angle (defines falloff region)
Note:
Only applicable to SPOTLIGHT type.
function SetPower
Sets light power/intensity.
void Light::SetPower (
float _power
)
Parameters:
_powerNew luminous intensity
function SetRadius
Sets point light radius.
void Light::SetRadius (
float _rad
)
Parameters:
_radNew radius for soft shadow computation
Note:
Only applicable to POINTLIGHT type.
function SetRatio
Sets area light aspect ratio.
void Light::SetRatio (
float _ratio
)
Parameters:
_ratioWidth/height ratio of rectangular area light
Note:
Only applicable to AREALIGHT type.
function SetShadow
Enables or disables shadow casting.
void Light::SetShadow (
bool _state
)
Parameters:
_stateTrue to enable shadows, false to disable
Public Static Functions Documentation
function ParseLightName
Parses light type to sprite icon and name.
static inline std::pair< SpriteType , std::string > Light::ParseLightName (
LightType _type
)
Parameters:
_typeLight type to parse
Returns:
Pair of (sprite icon type, display name string)
Note:
Used by editor to display light icons in viewport and outliner.
The documentation for this class was generated from the following file src/scene/Light.h