LightsprintSDK 2021.08.08
|
#include <RealtimeLight.h>
Public Types | |
enum | AreaType { LINE , CIRCLE , RECTANGLE } |
enum | ShadowTransparency { FULLY_OPAQUE_SHADOWS , ALPHA_KEYED_SHADOWS , RGB_SHADOWS , FRESNEL_SHADOWS } |
Public Member Functions | |
RealtimeLight (rr::RRLight &rrlight) | |
virtual | ~RealtimeLight () |
rr::RRLight & | getRRLight () |
const rr::RRLight & | getRRLight () const |
void | updateAfterRRLightChanges () |
rr::RRCamera * | getCamera () const |
void | setCamera (rr::RRCamera *camera) |
virtual unsigned | getNumShadowmaps (bool color=false) const |
void | configureCSM (const rr::RRCamera *observer, const class rr::RRSolver *solver) |
rr::RRVec3 | getObserverPos () const |
virtual rr::RRCamera & | getShadowmapCamera (unsigned instance, rr::RRCamera &out) const |
void | setShadowmapSize (unsigned newSize) |
Texture * | getShadowmap (unsigned instance, bool color=false) |
void | setNumShadowSamples (unsigned numSamples) |
unsigned | getNumShadowSamples () const |
unsigned | getNumShadowSamples (unsigned instance) const |
void | setRangeDynamically (const rr::RRCollider *collider, const rr::RRObject *object, unsigned numRays=0) |
const Texture * | getProjectedTexture () |
Public Attributes | |
bool | shadowOnly |
AreaType | areaType |
float | areaSize |
ShadowTransparency | shadowTransparencyRequested |
ShadowTransparency | shadowTransparencyActual |
bool | oneSidedShadows |
unsigned * | smallMapCPU |
unsigned | numTriangles |
bool | dirtyShadowmap |
bool | dirtyGI |
bool | dirtyRange |
rr::RRVec3 | positionOfLastDDI |
bool | changesInProjectedTextureAffectGI |
unsigned | numInstancesInArea |
Protected Attributes | |
rr::RRLight & | rrlight |
rr::RRVec3 | csmObserverPos |
rr::RRVec3 | csmObserverDir |
float | csmObserverNear |
rr::RRVec3 | csmSceneSize |
rr::RRCamera * | camera |
bool | deleteCamera |
rr::RRVector< Texture * > | shadowmaps [2] |
unsigned | numSoftShadowSamples |
Runtime extension of RRLight, with structures needed for realtime GI rendering (shadowmaps etc).
Shapes of light source area, relevant only for SPOT.
Specifies how shadows of transparent materials are created (in realtime renderer), whether quickly, or more accurately.
rr_gl::RealtimeLight::RealtimeLight | ( | rr::RRLight & | rrlight | ) |
Extends RRLight, adding properties and functions for realtime rendering.
RRLight must exist at least as long as realtime light. RRLight position/direction is updated each time this->getCamera()->update() is called.
|
virtual |
|
inline |
Returns our RRLight with standard light properties like color. It's legal to edit RRLight properties at any moment as long as you call updateAfterRRLightChanges() later.
|
inline |
Returns our RRLight with standard light properties like color.
void rr_gl::RealtimeLight::updateAfterRRLightChanges | ( | ) |
Propagates changes from RRLight (position,direction etc) to RealtimeLight and its camera. Note that changes in the opposite direction (from camera to RRLight) are propagated automatically.
rr::RRCamera * rr_gl::RealtimeLight::getCamera | ( | ) | const |
Returns camera you can use to control light's position, direction etc. Changes made to this camera are automatically propagated to original RRLight.
void rr_gl::RealtimeLight::setCamera | ( | rr::RRCamera * | camera | ) |
Assigns new camera to this light.
Ownership is not passed. Should not be used in new programs.
|
virtual |
Returns number of shadowmaps (depth maps or color maps).
void rr_gl::RealtimeLight::configureCSM | ( | const rr::RRCamera * | observer, |
const class rr::RRSolver * | solver | ||
) |
Provides light with data necessary for CSM calculations in getShadowmapCamera().
rr::RRVec3 rr_gl::RealtimeLight::getObserverPos | ( | ) | const |
Returns position of observer from previous configureCSM() call.
|
virtual |
Copies camera for n-th shadowmap into out and returns it.
void rr_gl::RealtimeLight::setShadowmapSize | ( | unsigned | newSize | ) |
Sets shadowmap resolution.
This is shortcut for setting rrlight.rtShadowmapSize and dirtyShadowmap. Set higher resolution for hard and sharper shadows, set lower resolution for area and more blurry shadows.
Texture * rr_gl::RealtimeLight::getShadowmap | ( | unsigned | instance, |
bool | color = false |
||
) |
Returns shadowmap (depth or color) for given light instance (element of area light).
void rr_gl::RealtimeLight::setNumShadowSamples | ( | unsigned | numSamples | ) |
Recommends number of shadow samples for given light. Valid numbers 1,2,4,8. In case of dirlight, this is number of samples close to camera.
unsigned rr_gl::RealtimeLight::getNumShadowSamples | ( | ) | const |
Returns recommended number of shadow samples. In case of dirlight, this is number of samples close to camera.
unsigned rr_gl::RealtimeLight::getNumShadowSamples | ( | unsigned | instance | ) | const |
Returns recommended number of shadow samples for given light instance.
void rr_gl::RealtimeLight::setRangeDynamically | ( | const rr::RRCollider * | collider, |
const rr::RRObject * | object, | ||
unsigned | numRays = 0 |
||
) |
Sets near and far to cover scene visible by light, but not much more.
Uses raycasting, performance hit for one light is acceptable even if called once per frame; but it could be too much when called for many lights in every frame.
Does nothing if RRLight::rtShadowmapAutomaticNearFar is not set.
Instead of directly calling setRangeDynamically(), you can set dirtyRange, solver will call setRangeDynamically() automatically before updating shadowmaps. This way you avoid calling setRangeDynamically() twice if different parts of code request update.
collider | Collider to be used for distance testing. |
object | Object to be used for material testing, may be nullptr. |
numRays | How many rays it shoots to measure distances. Higher = more accurate, but slower. 0 for defaults (around 300 for pointlight, 100 for spotlight). |
const Texture * rr_gl::RealtimeLight::getProjectedTexture | ( | ) |
Returns texture projected by spotlight.
bool rr_gl::RealtimeLight::shadowOnly |
Renders only shadows, no illumination. This is useful for simulating indirect shadows. Works only in presence of indirect illumination, shadows are subtracted from indirect illumination. When rendering with multiple lights, works only in first light.
AreaType rr_gl::RealtimeLight::areaType |
Shape of light source area.
Area light is simulated by multiple spot lights. Types of area are implemented in virtual getShadowmapCamera().
float rr_gl::RealtimeLight::areaSize |
Size factor, light source size scales linearly with areaSize.
ShadowTransparency rr_gl::RealtimeLight::shadowTransparencyRequested |
Requested shadow transparency mode. It defaults to the highest quality mode, you can change it freely to reduce quality and increase speed. Renderer is still allowed to use lower(simpler) transparency modes for materials that need it, but not higher. If you set unnecessarily high mode, there's no performance penalty, renderer detects it and uses lower mode (see shadowTransparencyActual).
ShadowTransparency rr_gl::RealtimeLight::shadowTransparencyActual |
Actual shadow transparency mode. For reading only, set by RRSolverGL::updateShadowmaps().
bool rr_gl::RealtimeLight::oneSidedShadows |
Default twosided shadows are nearly always better, this option exists only to make Lightsmark renders like in 2007/8.
unsigned* rr_gl::RealtimeLight::smallMapCPU |
Helper for GI calculation, used by RRSolverGL.
unsigned rr_gl::RealtimeLight::numTriangles |
Helper for GI calculation, used by RRSolverGL.
bool rr_gl::RealtimeLight::dirtyShadowmap |
Whether shadowmap needs update.
Set by RRSolverGL::reportDirectIlluminationChange() or manually, cleared by RRSolverGL::calculate() (unless light or shadow casting is disabled).
bool rr_gl::RealtimeLight::dirtyGI |
Whether GI needs update.
Set by RRSolverGL::reportDirectIlluminationChange() and by getProjectedTexture() (see changesInProjectedTextureAffectGI), cleared by RRSolverGL::calculate().
bool rr_gl::RealtimeLight::dirtyRange |
Whether shadowmap near/far range needs update.
Set by RRSolverGL::reportDirectIlluminationChange(), cleared by RRSolverGL::calculate() or setRangeDynamically(). Range should be wide enough to not clip visible geometry, but not wider, becuase it increases shadow bias and makes distant triangles z-fight. You can set range manually or just set dirtyRange and we will recalculate range automatically.
rr::RRVec3 rr_gl::RealtimeLight::positionOfLastDDI |
Eye position when direct lighting was detected. Only for directional light.
bool rr_gl::RealtimeLight::changesInProjectedTextureAffectGI |
True = each time projected texture content changes, GI is updated. For higher performance, clear it if you know that changes have small effect on GI. Even if cleared, you can still set dirtyGI manually on big changes.
unsigned rr_gl::RealtimeLight::numInstancesInArea |
Number of instances approximating area light. Used only for SPOT, 1 = standard spot, more = area light.
|
protected |
RRLight used at our creation, contains standard light properties like color.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Number of samples in soft shadows, defaults to 4, you may change it to 1,2,8.
Vectors of depth and color shadow maps. Sizes of vectors are updated lazily, only when map is requested and actual number of maps doesn't match.