LightsprintSDK 2021.08.08
rr::RRObjectIllumination Class Reference

#include <RRIllumination.h>

Inheritance diagram for rr::RRObjectIllumination:
rr::RRUniformlyAllocatedNonCopyable rr::RRUniformlyAllocated

Public Member Functions

 RRObjectIllumination ()
 
 ~RRObjectIllumination ()
 
RRBuffer *& getLayer (unsigned layerNumber)
 
RRBuffergetLayer (unsigned layerNumber) 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)
 

Public Attributes

RRVec3 envMapWorldCenter
 
RRReal envMapWorldRadius
 
RRVec3 cachedCenter
 
unsigned short cachedGatherSize
 
unsigned short cachedNumTriangles
 
unsigned * cachedTriangleNumbers
 

Protected Attributes

class LayersMap * layersMap
 

Additional Inherited Members

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

Detailed Description

Data structure with object's illumination and more.

This is collection of various buffers that may contain lightmaps, bent normals, reflection cube maps, ambient occlusion. This collection belongs to one object in your scene.

Buffers are created by you and deleted by destructor (unless you delete them manually).

RRSolver::updateXxx() functions store calculated illumination in buffers. They usually preserve buffer properties you selected while creating buffer: BufferType, BufferFormat and scale. So you are free to select between per-pixel and per-vertex lighting etc.

Renderer renders illumination from these buffers.

Constructor & Destructor Documentation

◆ RRObjectIllumination()

rr::RRObjectIllumination::RRObjectIllumination ( )

◆ ~RRObjectIllumination()

rr::RRObjectIllumination::~RRObjectIllumination ( )

Member Function Documentation

◆ getLayer() [1/2]

RRBuffer *& rr::RRObjectIllumination::getLayer ( unsigned  layerNumber)

Returns illumination buffer from given layer.

Illumination can be stored in various types of buffers

  • vertex colors (vertex buffer)
  • lightmap (2d texture)
  • reflection map (cube texture).

At the beginning, all layers are empty, buffers are nullptr. To initialize layer, do one of

  • do nothing (keep them nullptr) for no illumination
  • allocate buffers automatically by allocateBuffersForRealtimeGI()
  • allocate buffers manually by getLayer() = RRBuffer::create(). For cubemap, reasonable initialization is RRBuffer::create(BT_CUBE_TEXTURE,16,16,6,BF_RGBA,true,nullptr). Note that BF_RGBF would preserves intensities above 1 better, but very old GPUs don't support float filtering and GF7100 even switches to sw render (extremely slow). BF_RGBA usually looks ok and it doesn't have any compatibility problems. Size doesn't have to be power of two.

To update buffers in layer, do one of

  • manually by updateLightmap() or updateLightmaps()
  • manually by updateEnvironmentMap()
  • automatically by calling renderer with updateLightIndirect=true

Multiple layers (e.g. one layer per light source) can be mixed by renderer.

Assigned buffers will be deleted automatically in ~RRObjectIllumination.

Parameters
layerNumberIndex of illumination buffer you would like to get. Arbitrary unsigned number.
Returns
Illumination buffer for given layerNumber. If it doesn't exist yet, it is created.

◆ getLayer() [2/2]

RRBuffer * rr::RRObjectIllumination::getLayer ( unsigned  layerNumber) const

Member Data Documentation

◆ envMapWorldCenter

RRVec3 rr::RRObjectIllumination::envMapWorldCenter

World coordinate of object center.

To be updated by you when object moves. You can use RRObject::updateIlluminationEnvMapCenter() to update it.

◆ envMapWorldRadius

RRReal rr::RRObjectIllumination::envMapWorldRadius

World radius of object's bounding sphere.

To be updated by you when object changes/scales. You can use RRObject::updateIlluminationEnvMapCenter() to update it. When rr_gl::RRSolverGL::updateEnvironmentMap() renders into envmap in envmap layer, this is used as a camera near setting, to prevent rendering what's inside object.

◆ cachedCenter

RRVec3 rr::RRObjectIllumination::cachedCenter

◆ cachedGatherSize

unsigned short rr::RRObjectIllumination::cachedGatherSize

◆ cachedNumTriangles

unsigned short rr::RRObjectIllumination::cachedNumTriangles

◆ cachedTriangleNumbers

unsigned* rr::RRObjectIllumination::cachedTriangleNumbers

◆ layersMap

class LayersMap* rr::RRObjectIllumination::layersMap
protected

Container with all layers.