|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
A 2D light contributing to Lit-shaded materials. More...
#include <Light.hpp>
Public Attributes | |
| i32 | type {0} |
| Light kind: 0 = Point, 1 = Directional, 2 = Ambient (see LightType). | |
| glm::vec4 | color {1.0f, 1.0f, 1.0f, 1.0f} |
| Light color, multiplied by intensity. RGBA for editor color-picker consistency with every other engine color (Sprite/Shape/Text); the alpha is unused (a light's strength is intensity, which can exceed 1 for HDR). | |
| f32 | intensity {1.0f} |
| Light strength multiplier. | |
| f32 | radius {200.0f} |
| Point/Spot falloff radius in world units (ignored by Directional/Ambient). | |
| f32 | innerRadius {0.0f} |
| How far the light stays at full strength before it starts falling off, in world units. 0 (the default) falls off from the light itself; a value at or past radius is a hard-edged disc. Ignored by Directional/Ambient, which have no distance to fall off over. | |
| f32 | falloff {1.0f} |
| The shape of the falloff between innerRadius and radius, as the power the linear ramp is raised to. 1 (the default) IS linear; above it the light pools near its centre, below it it reaches further and ends abruptly. Ignored by Directional/Ambient. | |
| bool | inverseSquare {false} |
| Falls off as the inverse square of the distance, in metres, as a real light does (glTF's and three.js's point lights): intensity is then what reaches a surface one metre away, and radius is only where it is let go — the last of it eased to nothing over the far end — so a lamp pools under itself rather than washing a room evenly. Off, the light ramps from innerRadius to radius by falloff. Point and Spot only. | |
| f32 | shadowStrength {1.0f} |
| How much of this light a shadow takes away, 0..1. 1 (the default) is the whole of it; 0.7 leaves a shadow that is dark rather than black, which is what a 2D scene with bounce light in it looks like. Applies to both kinds of shadow this light casts. | |
| i32 | layerMin {-128} |
| The lowest sprite layer this light reaches. A sprite on a layer below it is not lit by this light, which is what keeps a lamp inside a room from lighting the roof drawn over it (a layer above the lamp's layerMax). The default, with layerMax, is every layer. Ambient lights reach every layer whatever these say: they are the scene's own sky, not a lamp somebody stands beside. Only sprites carry a layer to test; a mesh, a tilemap, a particle or a skeleton is lit as it always was. | |
| i32 | layerMax {127} |
| The highest sprite layer this light reaches. See layerMin. | |
| resource::TextureHandle | cookie |
| A texture whose ALPHA is this light's shape — a lantern's glow, a window's shaft. Drawn at the light's own place, turned by its Transform, and multiplied into what the light gives a pixel; the colour is not read, because a light's colour is the light's. Four shaped lights fit a frame, and past that a light lights without a shape. | |
| glm::vec2 | cookieSize {0.0f, 0.0f} |
| How big cookie is drawn, in world units. 0 on an axis covers the light's own reach on it — a square of 2 × radius — which is what a cookie drawn for this light almost always wants: a shape smaller than the reach cuts the light off, and one larger is trimmed by the falloff. | |
| f32 | innerAngle {30.0f} |
| Spot inner cone angle in degrees (full angle; fully lit inside). | |
| f32 | outerAngle {45.0f} |
| Spot outer cone angle in degrees (full angle; fades to dark by here). | |
| f32 | shadowSoftness {0.0f} |
| Shadow penumbra softness = the light source's half-extent in world units; 0 is a hard edge (default). It widens a penumbra the way a bigger source does, and the edge sharpens as a caster nears what it falls on. Read by the 2D shadow pass, which draws the shadow once per sample across a source that has width, and by a mesh shadow map only where the light HAS a position (Point/Spot). | |
| f32 | sourceAngle {0.53f} |
| How wide a Directional light's source is, as the angle it subtends — the full angular diameter in degrees. A length cannot say it: the source is infinitely far away, so only an angle carries a penumbra. The default is the real sun's 0.53; 0 is a hard edge. Ignored by the types that have a position and a size. | |
| f32 | shadowDistance {0.0f} |
| Directional-light shadow reach in world units: how far its shadows are carried from whatever cast them. 0 = a Directional light casts no 2D shadow (default). Ignored by Point/Spot, whose shadows reach as far as their own radius. | |
| bool | meshShadows {false} |
| Casts a shadow map over 3D meshes. Every type but Ambient can: a sun's map is cascades over the view, a Spot's its cone, a Point's a cube. Separate from shadowDistance, which shadows ShadowCaster2D edges in the plane — one light can do both. Lights that stand somewhere claim tiles first. | |
| f32 | shadowExtent {0.0f} |
| Half-extent of the shadow map's world coverage: one map of this radius, centred on the middle of the meshes that cast shadows, and not moving with the camera. 0 = cascades fitted to what the camera can see. Larger trades sharpness for reach. | |
| f32 | cascadeSplit {0.75f} |
| f32 | shadowBias {1.5f} |
| f32 | shadowSlopeFloor {0.15f} |
| bool | followEnvironmentSun {false} |
| Be the sun of the frame's environment. The direction and strength come from the panorama, turned with it; color and intensity scale what it gives and the Transform's aim is not read. The environment then lights with its sky alone, since the sun is this light's to cast. A panorama without a sun leaves the light out of the frame, and says so. | |
| bool | aimFollowedSun {false} |
| With followEnvironmentSun, aim this light by its own Transform instead of by where the panorama's sun is. The panorama still gives the light its colour and strength and still loses its sun in the lighting; only the direction is the scene's. What a time of day needs: a sun that crosses the sky over a panorama that was photographed with it in one place. | |
| resource::EnvironmentHandle | environment |
| What this Ambient light IS, when it is more than one colour: a baked panorama's irradiance and reflection. Without one the light stays the flat term it has always been — the same lighting, at order zero. color and intensity scale it. Ignored by the other types; the first Ambient light that carries one is the frame's environment. | |
| f32 | environmentRotation {0.0f} |
| Turn the environment about +Y, in degrees. One number turns all three of it — sky, diffuse irradiance and specular reflection — because moving a reflection to the other side of a model means all three or none. Here rather than in the .esenv so one bake is reusable. | |
| bool | drawEnvironment {false} |
| Draw environment as the background as well as reflecting it. Off by default, so a scene that adopts an environment for its lighting does not also acquire a sky it did not ask for. Ignored without one — and the camera still decides whether the background is drawn at all. | |
| f32 | reflectionScale {1.0f} |
| What baked reflection probes show, scaled. A probe was baked under one sky, so it goes on showing that sky: a weather that darkens the scene turns this down so a rainy street does not mirror a sunny one. 1 = as baked. Read from the frame's Ambient light. | |
| f32 | diffuseScale {1.0f} |
| What the light this Ambient light's environment gives a surface (its diffuse half, the sky's irradiance) is multiplied by, apart from what a surface reflects of it: a scene can be lit warmer or brighter than its sky looks. 1 = as the sky gives it. A flat or Hemisphere ambient light has nothing to reflect apart from its Color, so this is its environment's alone. | |
| glm::vec4 | diffuseTint {1.0f, 1.0f, 1.0f, 1.0f} |
| The colour diffuseScale's light is tinted by, authored as color is. White = as the sky gives it. | |
| f32 | reflectionSaturation {1.0f} |
| How much colour baked reflections keep: 1 as baked, 0 grey. An overcast sky drains colour from what it lights, and from what a probe mirrors. | |
| glm::vec4 | bakedTint {1.0f, 1.0f, 1.0f, 1.0f} |
| What baked INDIRECT light (a lightmap, a probe volume) is multiplied by. A bake holds the light of one moment, and a lightmapped surface takes all of its indirect light from it, so a scene that moves through a day or a weather scales and tints the bake here — the way it scales this light. 1 = as baked. Read from the frame's Ambient light. | |
| bool | hemisphere {false} |
| Make this Ambient light two colours: color from above, groundColor from below, blended by which way a surface faces. Off is the flat term it has always been. A sky and the ground it bounces off, without baking a panorama; ignored where environment is set, whose irradiance already says that. | |
| glm::vec4 | groundColor {0.35f, 0.3f, 0.25f, 1.0f} |
| What a surface facing straight down receives with hemisphere on. Scaled by intensity, and authored the way color is. | |
| bool | enabled {true} |
| Disabled lights are skipped during collection. | |
A 2D light contributing to Lit-shaded materials.
| bool esengine::ecs::Light::aimFollowedSun {false} |
With followEnvironmentSun, aim this light by its own Transform instead of by where the panorama's sun is. The panorama still gives the light its colour and strength and still loses its sun in the lighting; only the direction is the scene's. What a time of day needs: a sun that crosses the sky over a panorama that was photographed with it in one place.
Definition at line 214 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| glm::vec4 esengine::ecs::Light::bakedTint {1.0f, 1.0f, 1.0f, 1.0f} |
What baked INDIRECT light (a lightmap, a probe volume) is multiplied by. A bake holds the light of one moment, and a lightmapped surface takes all of its indirect light from it, so a scene that moves through a day or a weather scales and tints the bake here — the way it scales this light. 1 = as baked. Read from the frame's Ambient light.
Definition at line 276 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::cascadeSplit {0.75f} |
Definition at line 188 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| glm::vec4 esengine::ecs::Light::color {1.0f, 1.0f, 1.0f, 1.0f} |
Light color, multiplied by intensity. RGBA for editor color-picker consistency with every other engine color (Sprite/Shape/Text); the alpha is unused (a light's strength is intensity, which can exceed 1 for HDR).
Definition at line 63 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| resource::TextureHandle esengine::ecs::Light::cookie |
A texture whose ALPHA is this light's shape — a lantern's glow, a window's shaft. Drawn at the light's own place, turned by its Transform, and multiplied into what the light gives a pixel; the colour is not read, because a light's colour is the light's. Four shaped lights fit a frame, and past that a light lights without a shape.
Definition at line 129 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| glm::vec2 esengine::ecs::Light::cookieSize {0.0f, 0.0f} |
How big cookie is drawn, in world units. 0 on an axis covers the light's own reach on it — a square of 2 × radius — which is what a cookie drawn for this light almost always wants: a shape smaller than the reach cuts the light off, and one larger is trimmed by the falloff.
Definition at line 137 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::diffuseScale {1.0f} |
What the light this Ambient light's environment gives a surface (its diffuse half, the sky's irradiance) is multiplied by, apart from what a surface reflects of it: a scene can be lit warmer or brighter than its sky looks. 1 = as the sky gives it. A flat or Hemisphere ambient light has nothing to reflect apart from its Color, so this is its environment's alone.
Definition at line 256 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| glm::vec4 esengine::ecs::Light::diffuseTint {1.0f, 1.0f, 1.0f, 1.0f} |
The colour diffuseScale's light is tinted by, authored as color is. White = as the sky gives it.
Definition at line 261 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| bool esengine::ecs::Light::drawEnvironment {false} |
Draw environment as the background as well as reflecting it. Off by default, so a scene that adopts an environment for its lighting does not also acquire a sky it did not ask for. Ignored without one — and the camera still decides whether the background is drawn at all.
Definition at line 239 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| bool esengine::ecs::Light::enabled {true} |
Disabled lights are skipped during collection.
Definition at line 294 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| resource::EnvironmentHandle esengine::ecs::Light::environment |
What this Ambient light IS, when it is more than one colour: a baked panorama's irradiance and reflection. Without one the light stays the flat term it has always been — the same lighting, at order zero. color and intensity scale it. Ignored by the other types; the first Ambient light that carries one is the frame's environment.
Definition at line 223 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::environmentRotation {0.0f} |
Turn the environment about +Y, in degrees. One number turns all three of it — sky, diffuse irradiance and specular reflection — because moving a reflection to the other side of a model means all three or none. Here rather than in the .esenv so one bake is reusable.
Definition at line 231 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::falloff {1.0f} |
The shape of the falloff between innerRadius and radius, as the power the linear ramp is raised to. 1 (the default) IS linear; above it the light pools near its centre, below it it reaches further and ends abruptly. Ignored by Directional/Ambient.
Definition at line 88 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| bool esengine::ecs::Light::followEnvironmentSun {false} |
Be the sun of the frame's environment. The direction and strength come from the panorama, turned with it; color and intensity scale what it gives and the Transform's aim is not read. The environment then lights with its sky alone, since the sun is this light's to cast. A panorama without a sun leaves the light out of the frame, and says so.
Definition at line 205 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| glm::vec4 esengine::ecs::Light::groundColor {0.35f, 0.3f, 0.25f, 1.0f} |
What a surface facing straight down receives with hemisphere on. Scaled by intensity, and authored the way color is.
Definition at line 290 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| bool esengine::ecs::Light::hemisphere {false} |
Make this Ambient light two colours: color from above, groundColor from below, blended by which way a surface faces. Off is the flat term it has always been. A sky and the ground it bounces off, without baking a panorama; ignored where environment is set, whose irradiance already says that.
Definition at line 284 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::innerAngle {30.0f} |
Spot inner cone angle in degrees (full angle; fully lit inside).
Definition at line 141 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::innerRadius {0.0f} |
How far the light stays at full strength before it starts falling off, in world units. 0 (the default) falls off from the light itself; a value at or past radius is a hard-edged disc. Ignored by Directional/Ambient, which have no distance to fall off over.
Definition at line 80 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::intensity {1.0f} |
Light strength multiplier.
Definition at line 67 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| bool esengine::ecs::Light::inverseSquare {false} |
Falls off as the inverse square of the distance, in metres, as a real light does (glTF's and three.js's point lights): intensity is then what reaches a surface one metre away, and radius is only where it is let go — the last of it eased to nothing over the far end — so a lamp pools under itself rather than washing a room evenly. Off, the light ramps from innerRadius to radius by falloff. Point and Spot only.
Definition at line 97 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| i32 esengine::ecs::Light::layerMax {127} |
The highest sprite layer this light reaches. See layerMin.
Definition at line 120 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| i32 esengine::ecs::Light::layerMin {-128} |
The lowest sprite layer this light reaches. A sprite on a layer below it is not lit by this light, which is what keeps a lamp inside a room from lighting the roof drawn over it (a layer above the lamp's layerMax). The default, with layerMax, is every layer. Ambient lights reach every layer whatever these say: they are the scene's own sky, not a lamp somebody stands beside. Only sprites carry a layer to test; a mesh, a tilemap, a particle or a skeleton is lit as it always was.
Definition at line 115 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| bool esengine::ecs::Light::meshShadows {false} |
Casts a shadow map over 3D meshes. Every type but Ambient can: a sun's map is cascades over the view, a Spot's its cone, a Point's a cube. Separate from shadowDistance, which shadows ShadowCaster2D edges in the plane — one light can do both. Lights that stand somewhere claim tiles first.
Definition at line 177 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::outerAngle {45.0f} |
Spot outer cone angle in degrees (full angle; fades to dark by here).
Definition at line 145 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::radius {200.0f} |
Point/Spot falloff radius in world units (ignored by Directional/Ambient).
Definition at line 72 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::reflectionSaturation {1.0f} |
How much colour baked reflections keep: 1 as baked, 0 grey. An overcast sky drains colour from what it lights, and from what a probe mirrors.
Definition at line 267 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::reflectionScale {1.0f} |
What baked reflection probes show, scaled. A probe was baked under one sky, so it goes on showing that sky: a weather that darkens the scene turns this down so a rainy street does not mirror a sunny one. 1 = as baked. Read from the frame's Ambient light.
Definition at line 247 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::shadowBias {1.5f} |
Definition at line 192 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::shadowDistance {0.0f} |
Directional-light shadow reach in world units: how far its shadows are carried from whatever cast them. 0 = a Directional light casts no 2D shadow (default). Ignored by Point/Spot, whose shadows reach as far as their own radius.
Definition at line 169 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::shadowExtent {0.0f} |
Half-extent of the shadow map's world coverage: one map of this radius, centred on the middle of the meshes that cast shadows, and not moving with the camera. 0 = cascades fitted to what the camera can see. Larger trades sharpness for reach.
Definition at line 184 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::shadowSlopeFloor {0.15f} |
Definition at line 196 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::shadowSoftness {0.0f} |
Shadow penumbra softness = the light source's half-extent in world units; 0 is a hard edge (default). It widens a penumbra the way a bigger source does, and the edge sharpens as a caster nears what it falls on. Read by the 2D shadow pass, which draws the shadow once per sample across a source that has width, and by a mesh shadow map only where the light HAS a position (Point/Spot).
Definition at line 154 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::shadowStrength {1.0f} |
How much of this light a shadow takes away, 0..1. 1 (the default) is the whole of it; 0.7 leaves a shadow that is dark rather than black, which is what a 2D scene with bounce light in it looks like. Applies to both kinds of shadow this light casts.
Definition at line 106 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| f32 esengine::ecs::Light::sourceAngle {0.53f} |
How wide a Directional light's source is, as the angle it subtends — the full angular diameter in degrees. A length cannot say it: the source is infinitely far away, so only an angle carries a penumbra. The default is the real sun's 0.53; 0 is a hard edge. Ignored by the types that have a position and a size.
Definition at line 162 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().
| i32 esengine::ecs::Light::type {0} |
Light kind: 0 = Point, 1 = Directional, 2 = Ambient (see LightType).
Definition at line 57 of file Light.hpp.
Referenced by lightApplyJS(), and lightToJS().