Rendu
A lightweight rendering engine for experimentations
|
A spotlight, where light rays in a given cone are radiating from a single point in space. Implements distance attenuation and cone soft transition. More...
#include <SpotLight.hpp>
Public Member Functions | |
SpotLight ()=default | |
SpotLight (const glm::vec3 &worldPosition, const glm::vec3 &worldDirection, const glm::vec3 &color, float innerAngle, float outerAngle, 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 |
const glm::vec3 & | direction () const |
const glm::vec2 & | angles () const |
float | radius () const |
![]() | |
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 |
Private Attributes | |
glm::mat4 | _projectionMatrix = glm::mat4(1.0f) |
Light projection matrix. | |
glm::mat4 | _viewMatrix = glm::mat4(1.0f) |
Light view matrix. | |
Animated< glm::vec3 > | _lightDirection { glm::vec3(1.0f, 0.0f, 0.0f) } |
Light direction. | |
Animated< glm::vec3 > | _lightPosition { glm::vec3(0.0f) } |
Light position. | |
glm::vec2 | _angles = glm::vec2(glm::quarter_pi<float>(), glm::half_pi<float>()) |
The inner and outer cone attenuation angles. | |
float | _radius = 1.0f |
The attenuation radius. | |
Additional Inherited Members | |
![]() | |
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).. | |
A spotlight, where light rays in a given cone are radiating from a single point in space. Implements distance attenuation and cone soft transition.
It can be associated with a shadow 2D map with perspective projection, generated using Variance shadow mapping. It is rendered as a cone in deferred rendering.
Inherits Light.
|
default |
Default constructor.
SpotLight::SpotLight | ( | const glm::vec3 & | worldPosition, |
const glm::vec3 & | worldDirection, | ||
const glm::vec3 & | color, | ||
float | innerAngle, | ||
float | outerAngle, | ||
float | radius | ||
) |
Constructor.
worldPosition | the light position in world space |
worldDirection | the light cone direction in world space |
color | the colored intensity of the light |
innerAngle | the inner angle of the cone attenuation |
outerAngle | the outer angle of the cone attenuation |
radius | the distance at which the light is completely attenuated |
|
inline |
Get the light cone inner and outer angles. Attenuation happens between the two angles.
bool SpotLight::decode | ( | const KeyValues & | params | ) |
Setup a spot light parameters from a list of key-value tuples. The following keywords will be searched for:
direction: dirX,dirY,dirZ position: X,Y,Z radius: radius cone: innerAngle outerAngle intensity: R,G,B shadows: bool animations: - animationtype: ... - ...
params | the parameters tuple |
|
inline |
Get the light principal direction in world space.
|
overridevirtual |
Process the light using a specific renderer.
renderer | the light-specific renderer |
Implements Light.
|
overridevirtual |
Generate a key-values representation of the light. See decode for the keywords and layout.
Reimplemented from Light.
|
inline |
Get the light position in world space.
|
inline |
Get the light influence radius. No emitted light propagates further than this distance from the light position.
|
overridevirtual |
Sample a direction from a reference point to the light.
position | the 3D point |
dist | will contain the distance from the light to the point |
attenuation | will contain the light attenuation factor |
Implements Light.
|
overridevirtual |
Update the scene bounding box used for internal setup (shadow map,...).
sceneBox | the new bounding box |
Implements Light.
|
overridevirtual |
Apply the animations for a frame duration.
fullTime | the time since the launch of the application |
frameTime | the time elapsed since the last frame |
Implements Light.