Files Class List
LightingGridHierarchy Class Reference

Detailed Description

An implementation of the Lighting Grid Hierarchy method.

Can Yuksel and Cem Yuksel. 2017. Lighting Grid Hierarchy for Self-illuminating Explosions. ACM Transactions on Graphics (Proceedings of SIGGRAPH 2017) 36, 4, Article 110 (July 2017). http://www.cemyuksel.com/research/lgh/

This class builds the Lighting Grid Hierarchy and uses it for lighting.

#include <cyLightingGrid.h>

Public Member Functions

 LightingGridHierarchy ()
 
virtual ~LightingGridHierarchy ()
 
int GetNumLevels () const
 
float GetCellSize () const
 
const Point3fGetLightPos (int level, int i) const
 
const int GetLightIndex (int level, int i) const
 
const ColorGetLightIntens (int level, int ix) const
 
const Point3fGetLightPosDev (int level, int ix) const
 
void Clear ()
 
bool Build (const Point3f *lightPos, const Color *lightIntensities, int numLights, int minLevelLights, float cellSize, int highestLevel)
 
bool Build (const Point3f *lightPos, const Color *lightIntensities, int numLights, int minLevelLights, float autoFitScale=1.01f)
 
template<typename LightingFunction >
void Light (const Point3f &pos, float alpha, LightingFunction lightingFunction)
 
template<typename LightingFunction >
void Light (const Point3f &pos, float alpha, int stochasticShadowSamples, LightingFunction lightingFunction)
 

Constructor & Destructor Documentation

§ LightingGridHierarchy()

Constructor.

§ ~LightingGridHierarchy()

virtual ~LightingGridHierarchy ( )
virtual

Destructor.

Member Function Documentation

§ GetNumLevels()

int GetNumLevels ( ) const

Returns the number of levels in the hierarchy.

§ GetCellSize()

float GetCellSize ( ) const

Returns the size of a cell in the lowest (finest) level of the hierarchy.

§ GetLightPos()

const Point3f& GetLightPos ( int  level,
int  i 
) const

Returns the i^th light position at the given level. Note that this is not the position of the light with index i.

§ GetLightIndex()

const int GetLightIndex ( int  level,
int  i 
) const

Returns the i^th light index at the given level.

§ GetLightIntens()

const Color& GetLightIntens ( int  level,
int  ix 
) const

Returns the intensity of the light with index ix at the given level.

§ GetLightPosDev()

const Point3f& GetLightPosDev ( int  level,
int  ix 
) const

Returns the position variation of the light with index ix at the given level.

§ Clear()

void Clear ( )

Deletes all data.

§ Build() [1/2]

bool Build ( const Point3f lightPos,
const Color lightIntensities,
int  numLights,
int  minLevelLights,
float  cellSize,
int  highestLevel 
)

Builds the Lighting Grid Hierarchy for the given point light positions and intensities using the given parameters. This method builds the hierarchy using the given cellSize as the size of the lowest (finest) level grid cells.

Parameters
lightPosLight positions.
lightIntensitiesLight intensities.
numLightsNumber of lights.
minLevelLightsThe minimum number of lights permitted for the highest (coarsest) level of the hierarchy. The build stops if a higher (coarser) level would have fewer lights.
cellSizeThe size of a grid cell in the lowest (finest) level of the hierarchy.
highestLevelThe highest level permitted, where level 0 contains the original lights.

§ Build() [2/2]

bool Build ( const Point3f lightPos,
const Color lightIntensities,
int  numLights,
int  minLevelLights,
float  autoFitScale = 1.01f 
)

Builds the Lighting Grid Hierarchy for the given point light positions and intensities using the given parameters. This method automatically determines the grid cell size based on the bounding box of the light positions.

Parameters
lightPosLight positions.
lightIntensitiesLight intensities.
numLightsNumber of lights.
minLevelLightsThe minimum number of lights permitted for the highest (coarsest) level of the hierarchy. The build stops if a higher (coarser) level would have fewer lights.
autoFitScaleExtends the bounding box of the light positions using the given scale. This value must be 1 or greater. A value slightly greater than 1 often provides a good fit for the grid.

§ Light() [1/2]

void Light ( const Point3f pos,
float  alpha,
LightingFunction  lightingFunction 
)

Computes the illumination at the given position using the given accuracy parameter alpha.

Parameters
posThe position where the lighting will be evaluated.
alphaThe accuracy parameter. It should be 1 or greater. Larger values produce more accurate results with substantially more computation.
lightingFunctionThis function is called for each light used for lighting computation. It should be in the form void LightingFunction(int level, int light_id, const Point3f &light_position, const Color &light_intensity).

§ Light() [2/2]

void Light ( const Point3f pos,
float  alpha,
int  stochasticShadowSamples,
LightingFunction  lightingFunction 
)

Computes the illumination at the given position using the given accuracy parameter alpha. This method provides stochastic sampling by randomly changing the given light position when calling the lighting function.

Parameters
posThe position where the lighting will be evaluated.
alphaThe accuracy parameter. It should be 1 or greater. Larger values produce more accurate results with substantially more computation.
stochasticShadowSamplesWhen this parameter is zero, the given lightingFunction is called once per light, using the position of the light. Otherwise, it is called as many times as this parameter specifies, using random positions around each light position.
lightingFunctionThis function is called for each light used for lighting computation. It should be in the form void LightingFunction(int level, int light_id, const Point3f &light_position, const Color &light_intensity).