An omnidirectional punctual light, where light is radiating in all directions from a single point in space. Implements distance attenuation.
More...
#include <PointLight.hpp>
|
| PointLight ()=default |
|
| PointLight (const glm::vec3 &worldPosition, const glm::vec3 &color, float radius) |
|
void | draw (LightRenderer &renderer) override |
|
void | update (double fullTime, double frameTime) override |
|
void | setScene (const BoundingBox &sceneBox) override |
|
glm::vec3 | sample (const glm::vec3 &position, float &dist, float &attenuation) const override |
|
bool | decode (const KeyValues ¶ms) |
|
KeyValues | encode () const override |
|
const glm::vec3 & | position () const |
|
float | radius () const |
|
float | farPlane () const |
|
const std::array< glm::mat4, 6 > & | vpFaces () |
|
| Light () |
|
| Light (const glm::vec3 &color) |
|
void | addAnimation (const std::shared_ptr< Animation > &anim) |
|
virtual void | draw (LightRenderer &renderer)=0 |
|
virtual void | update (double fullTime, double frameTime)=0 |
|
virtual void | setScene (const BoundingBox &sceneBox)=0 |
|
virtual glm::vec3 | sample (const glm::vec3 &position, float &dist, float &attenuation) const =0 |
|
virtual KeyValues | encode () const |
|
bool | castsShadow () const |
|
void | setCastShadow (bool shouldCast) |
|
const glm::vec3 & | intensity () const |
|
void | setIntensity (const glm::vec3 &color) |
|
const glm::mat4 & | vp () const |
|
const glm::mat4 & | model () const |
|
const ShadowMap::Region & | shadowMap () const |
|
void | registerShadowMap (const Texture *map, ShadowMode mode, size_t layer=0, const glm::vec2 &minUV=glm::vec2(0.0f), const glm::vec2 &maxUV=glm::vec2(1.0f)) |
|
bool | animated () const |
|
virtual | ~Light ()=default |
|
| Light (const Light &)=delete |
|
Light & | operator= (const Light &)=delete |
|
| Light (Light &&)=default |
|
Light & | operator= (Light &&)=delete |
|
|
std::array< glm::mat4, 6 > | _vps |
| Light VP matrices for each face.
|
|
Animated< glm::vec3 > | _lightPosition { glm::vec3(0.0f) } |
| Light position.
|
|
float | _radius = 1.0f |
| The attenuation radius.
|
|
float | _farPlane = 1.0f |
| The projection matrices far plane.
|
|
|
static std::shared_ptr< Light > | decode (const KeyValues ¶ms) |
|
bool | decodeBase (const KeyValues ¶ms) |
|
std::vector< std::shared_ptr< Animation > > | _animations |
| Animations list (will be applied in order).
|
|
ShadowMap::Region | _shadowMapInfos |
| Region of the (optional) shadow map containing this light information.
|
|
BoundingBox | _sceneBox |
| The scene bounding box, to fit the shadow map.
|
|
glm::mat4 | _vp |
| VP matrix for shadow casting.
|
|
glm::mat4 | _model |
| Model matrix of the mesh containing the light-covered region.
|
|
glm::vec3 | _color |
| Colored intensity.
|
|
bool | _castShadows |
| Is the light casting shadows (and thus use a shadow map)..
|
|
An omnidirectional punctual light, where light is radiating in all directions from a single point in space. Implements distance attenuation.
It can be associated with a shadow cubemap with six orthogonal projections, and is rendered as a sphere in deferred rendering.
- See also
- GPU::Frag::Point_light, GPU::Frag::Light_shadow_linear, GPU::Frag::Light_debug
Inherits Light.
◆ PointLight() [1/2]
PointLight::PointLight |
( |
| ) |
|
|
default |
◆ PointLight() [2/2]
PointLight::PointLight |
( |
const glm::vec3 & |
worldPosition, |
|
|
const glm::vec3 & |
color, |
|
|
float |
radius |
|
) |
| |
Constructor.
- Parameters
-
worldPosition | the light position in world space |
color | the colored intensity of the light |
radius | the distance at which the light is completely attenuated |
◆ decode()
bool PointLight::decode |
( |
const KeyValues & |
params | ) |
|
Setup a point light parameters from a list of key-value tuples. The following keywords will be searched for:
position: X,Y,Z
radius: radius
intensity: R,G,B
shadows: bool
animations:
- animationtype: ...
- ...
- Parameters
-
params | the parameters tuple |
- Returns
- decoding status
◆ draw()
Process the light using a specific renderer.
- See also
- LightRenderer for the expected interface details.
- Parameters
-
renderer | the light-specific renderer |
Implements Light.
◆ encode()
Generate a key-values representation of the light. See decode for the keywords and layout.
- Returns
- a tuple representing the light
Reimplemented from Light.
◆ farPlane()
float PointLight::farPlane |
( |
| ) |
const |
|
inline |
Get the light far plane used to render the cube shadow map with distances in world space.
- Returns
- the far plane distance
◆ position()
const glm::vec3 & PointLight::position |
( |
| ) |
const |
|
inline |
Get the light position in world space.
- Returns
- the position
◆ radius()
float PointLight::radius |
( |
| ) |
const |
|
inline |
Get the light influence radius. No emitted light propagates further than this distance from the light position.
- Returns
- the radius
◆ sample()
glm::vec3 PointLight::sample |
( |
const glm::vec3 & |
position, |
|
|
float & |
dist, |
|
|
float & |
attenuation |
|
) |
| const |
|
overridevirtual |
Sample a direction from a reference point to the light.
- Parameters
-
position | the 3D point |
dist | will contain the distance from the light to the point |
attenuation | will contain the light attenuation factor |
- Returns
- a direction from the point to the light
Implements Light.
◆ setScene()
void PointLight::setScene |
( |
const BoundingBox & |
sceneBox | ) |
|
|
overridevirtual |
Update the scene bounding box used for internal setup (shadow map,...).
- Parameters
-
sceneBox | the new bounding box |
Implements Light.
◆ update()
void PointLight::update |
( |
double |
fullTime, |
|
|
double |
frameTime |
|
) |
| |
|
overridevirtual |
Apply the animations for a frame duration.
- Parameters
-
fullTime | the time since the launch of the application |
frameTime | the time elapsed since the last frame |
Implements Light.
◆ vpFaces()
const std::array< glm::mat4, 6 > & PointLight::vpFaces |
( |
| ) |
|
|
inline |
Get 6 view-projection matrices that cover the full 360° environment, with proper near/far planes for the current environment.
- Returns
- the matrices list.
The documentation for this class was generated from the following files:
- src/engine/scene/lights/PointLight.hpp
- src/engine/scene/lights/PointLight.cpp