Rendu
A lightweight rendering engine for experimentations
|
A probe can be used to capture the appareance of a scene at a given location as a 360° cubemap. More...
#include <Probe.hpp>
Public Member Functions | |
Probe (LightProbe &probe, std::shared_ptr< Renderer > renderer, uint size, uint mips, const glm::vec2 &clippingPlanes) | |
void | update (uint budget) |
uint | totalBudget () const |
Probe & | operator= (const Probe &)=delete |
Probe (const Probe &)=delete | |
Probe & | operator= (Probe &&)=delete |
Probe (Probe &&)=delete | |
~Probe ()=default | |
Static Public Member Functions | |
static void | extractIrradianceSHCoeffs (const Texture &cubemap, float clamp, std::vector< glm::vec3 > &shCoeffs) |
Decompose an existing cubemap irradiance onto the nine first elements of the spherical harmonic basis. More... | |
Private Types | |
enum class | ProbeState { DRAW_FACES , CONVOLVE_RADIANCE , GENERATE_IRRADIANCE } |
Probe update state machine. More... | |
Private Member Functions | |
void | convolveRadiance (float clamp, uint layer) |
void | estimateIrradiance (float clamp) |
Private Attributes | |
std::shared_ptr< Renderer > | _renderer |
The renderer to use. | |
Texture | _result |
The cubemap content. | |
Texture | _copy |
Downscaled copy of the cubemap content. | |
std::shared_ptr< Buffer > | _shCoeffs |
SH representation of the cubemap irradiance. | |
std::array< Camera, 6 > | _cameras |
Camera for each face. | |
glm::vec3 | _position |
The probe location. | |
Program * | _radianceCompute |
Radiance preconvolution shader. | |
Program * | _irradianceCompute |
Irradiance SH projection shader. | |
ProbeState | _currentState = ProbeState::DRAW_FACES |
Current update state. | |
uint | _substepDraw = 0 |
If drawing, current face. | |
uint | _substepRadiance = 1 |
If convolving radiance, current level. | |
A probe can be used to capture the appareance of a scene at a given location as a 360° cubemap.
This is often used to render realistic real-time reflections and global illumination effects. It is recommended to split the rendering, radiance precomputation for GGX shading and irradiance SH decomposition over multiple frames as those steps are costly.
|
strongprivate |
Probe update state machine.
Probe::Probe | ( | LightProbe & | probe, |
std::shared_ptr< Renderer > | renderer, | ||
uint | size, | ||
uint | mips, | ||
const glm::vec2 & | clippingPlanes | ||
) |
Constructor
probe | the probe in the scene |
renderer | the renderer to use to fill the cubemap |
size | the dimensions of the cubemap |
mips | the number of mip levels of the cubemap |
clippingPlanes | the near/far planes to use when rendering each face |
|
delete |
Copy constructor (disabled).
|
delete |
Move constructor (disabled).
|
default |
Destructor
|
private |
Perform BRDF pre-integration of the probe radiance for increasing roughness and store them in the mip levels.
clamp | maximum intensity value, useful to avoid ringing artifacts |
layer | first layer to process (in 1, mip count - 1) |
|
private |
Estimate the SH representation of the cubemap irradiance. The estimation is done on the GPU.
clamp | maximum intensity value, useful to avoid temporal instabilities |
|
static |
Decompose an existing cubemap irradiance onto the nine first elements of the spherical harmonic basis.
Perform approximated convolution as described in Ramamoorthi, Ravi, and Pat Hanrahan. "An efficient representation for irradiance environment maps.", Proceedings of the 28th annual conference on Computer graphics and interactive techniques. ACM, 2001.
cubemap | the cubemap to extract SH coefficients from |
clamp | maximum intensity value, useful to avoid temporal instabilities |
shCoeffs | will contain the irradiance SH representation |
Copy assignment operator (disabled).
Move assignment operator (disabled).
uint Probe::totalBudget | ( | ) | const |
void Probe::update | ( | uint | budget | ) |
Update the content of the probe and the corresponding radiance and irradiance.
budget | the number of internal update steps to perform Each internal step (drawing a part of the environment, generating the convolved radiance, integrating the irradiance) has a given budget. Depending on the allocated budget, the probe will entirely update more or less fast. |