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 () | |
Constructor. | |
virtual | ~LightingGridHierarchy () |
Destructor. | |
int | GetNumLevels () const |
Returns the number of levels in the hierarchy. | |
float | GetCellSize () const |
Returns the size of a cell in the lowest (finest) level of the hierarchy. | |
const Vec3f & | 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. | |
const int | GetLightIndex (int level, int i) const |
Returns the i^th light index at the given level. | |
const Color & | GetLightIntens (int level, int ix) const |
Returns the intensity of the light with index ix at the given level. | |
const Vec3f & | GetLightPosDev (int level, int ix) const |
Returns the position variation of the light with index ix at the given level. | |
void | Clear () |
Deletes all data. | |
bool | Build (const Vec3f *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. | |
bool | Build (const Vec3f *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. | |
template<typename LightingFunction > | |
void | Light (const Vec3f &pos, float alpha, LightingFunction lightingFunction) |
Computes the illumination at the given position using the given accuracy parameter alpha. | |
template<typename LightingFunction > | |
void | Light (const Vec3f &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. | |
Member Function Documentation
◆ Build() [1/2]
bool Build | ( | const Vec3f * | 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
-
lightPos Light positions. lightIntensities Light intensities. numLights Number of lights. minLevelLights The 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. cellSize The size of a grid cell in the lowest (finest) level of the hierarchy. highestLevel The highest level permitted, where level 0 contains the original lights.
◆ Build() [2/2]
bool Build | ( | const Vec3f * | 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
-
lightPos Light positions. lightIntensities Light intensities. numLights Number of lights. minLevelLights The 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. autoFitScale Extends 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 Vec3f & | pos, |
float | alpha, | ||
LightingFunction | lightingFunction ) |
Computes the illumination at the given position using the given accuracy parameter alpha.
- Parameters
-
pos The position where the lighting will be evaluated. alpha The accuracy parameter. It should be 1 or greater. Larger values produce more accurate results with substantially more computation. lightingFunction This function is called for each light used for lighting computation. It should be in the form void LightingFunction(int level, int light_id, const Vec3f &light_position, const Color &light_intensity).
◆ Light() [2/2]
void Light | ( | const Vec3f & | 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
-
pos The position where the lighting will be evaluated. alpha The accuracy parameter. It should be 1 or greater. Larger values produce more accurate results with substantially more computation. stochasticShadowSamples When 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. lightingFunction This function is called for each light used for lighting computation. It should be in the form void LightingFunction(int level, int light_id, const Vec3f &light_position, const Color &light_intensity).