LightsprintSDK 2021.08.08
rr::RRLightField Class Referenceabstract

#include <RRIllumination.h>

Inheritance diagram for rr::RRLightField:
rr::RRUniformlyAllocatedNonCopyable rr::RRUniformlyAllocated

Public Member Functions

virtual void captureLighting (class RRSolver *solver, unsigned timeSlot)=0
 
virtual unsigned updateEnvironmentMap (RRObjectIllumination *illumination, unsigned layerEnvironment, RRReal time) const =0
 
virtual ~RRLightField ()
 
virtual bool save (const char *filename) const
 
- Public Member Functions inherited from rr::RRUniformlyAllocated
void * operator new (std::size_t n)
 
void * operator new[] (std::size_t n)
 
void operator delete (void *p, std::size_t n)
 
void operator delete[] (void *p, std::size_t n)
 

Static Public Member Functions

static RRLightFieldcreate (RRVec4 aabbMin, RRVec4 aabbSize, RRReal spacing=1, unsigned envMapSize=8, unsigned numTimeSlots=1)
 
static RRLightFieldload (const char *filename)
 

Additional Inherited Members

- Protected Member Functions inherited from rr::RRUniformlyAllocatedNonCopyable
 RRUniformlyAllocatedNonCopyable ()
 
 ~RRUniformlyAllocatedNonCopyable ()
 

Detailed Description

GI precomputed in space.

Light field contains precomputed indirect part of global illumination. It is designed for scenarios with static lights and dynamic objects - precompute lightmaps for static objects and lightfield for dynamic objects. When rendering dynamic objects in game, use your usual direct lighting together with indirect lighting from lightfield. You can use multiple lightfields for different locations in game level.

Typical use:

Constructor & Destructor Documentation

◆ ~RRLightField()

virtual rr::RRLightField::~RRLightField ( )
inlinevirtual

Member Function Documentation

◆ create()

static RRLightField * rr::RRLightField::create ( RRVec4  aabbMin,
RRVec4  aabbSize,
RRReal  spacing = 1,
unsigned  envMapSize = 8,
unsigned  numTimeSlots = 1 
)
static

Creates light field.

Empty lightfield is created, use captureLighting() to fill it.

Parameters
aabbMinLower corner of axis aligned bounding box of space/time where light field is to be computed. Fourth coordinate is time in your units.
aabbSizeSize of axis aligned bounding box of space/time where light field is to be computed. Fourth coordinate is time in your units.
spacingDistance between sampling points. Smaller = higher quality, but larger structure.
envMapSizeSize of reflection envmaps. 8 or 16 is usually sufficient.
numTimeSlotsNumber of time slots in lightfield. Time slots are used for dynamic lights, you can capture lighting in space for several moments in time. Use 1 slot for static lighting.

◆ captureLighting()

virtual void rr::RRLightField::captureLighting ( class RRSolver solver,
unsigned  timeSlot 
)
pure virtual

Captures lighting in space into lightfield. Call it for all time slots, otherwise content of lightfield will be undefined.

Parameters
solverSolver, source of information about scene and its illumination.
timeSlotLighting in scene will be stored to given slot. Time slot numbers are 0..numTimeSlots-1 where numTimeSlots was specified by create().

◆ updateEnvironmentMap()

virtual unsigned rr::RRLightField::updateEnvironmentMap ( RRObjectIllumination illumination,
unsigned  layerEnvironment,
RRReal  time 
) const
pure virtual

Updates diffuse and/or specular environment maps in object illumination.

Unlike all other buffer update function in Lightsprint SDK, this one changes type/size/format of buffer (to RGB cubemap of size you entered to RRSolver::buildLightField()).

Parameters
illuminationIllumination you want to update.
layerEnvironmentNumber of layer with environment map, it is addressed by illumination->getLayer(layerEnvironment).
timeIllumination at given time is computed. (Lightfield may store dynamic lighting for time period specified at lightfield build.) Use the same time units you used in create().
Returns
Number of maps updated, 0, 1 or 2.

◆ save()

virtual bool rr::RRLightField::save ( const char *  filename) const
inlinevirtual

Saves instance to disk.

Parameters
filenameFile to be created. Mandatory, it is not autogenerated.
Returns
True on success.

◆ load()

static RRLightField * rr::RRLightField::load ( const char *  filename)
static

Loads instance from disk.

Parameters
filenameFile to be loaded. Mandatory, it is not autogenerated.
Returns
Created instance or nullptr at failure.