Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Probe Class Reference

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
 
Probeoperator= (const Probe &)=delete
 
 Probe (const Probe &)=delete
 
Probeoperator= (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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ ProbeState

enum class Probe::ProbeState
strongprivate

Probe update state machine.

Enumerator
DRAW_FACES 

Drawing a cubemap face with the environment.

CONVOLVE_RADIANCE 

Convolving the cubemap to generate radiance for a given roughness level.

GENERATE_IRRADIANCE 

Integrate irradiance in a compute shader.

Constructor & Destructor Documentation

◆ Probe() [1/3]

Probe::Probe ( LightProbe probe,
std::shared_ptr< Renderer renderer,
uint  size,
uint  mips,
const glm::vec2 &  clippingPlanes 
)

Constructor

Parameters
probethe probe in the scene
rendererthe renderer to use to fill the cubemap
sizethe dimensions of the cubemap
mipsthe number of mip levels of the cubemap
clippingPlanesthe near/far planes to use when rendering each face
Warning
If the renderer is using the output of the probe, be careful to not use the probe content in the last rendering step.

◆ Probe() [2/3]

Probe::Probe ( const Probe )
delete

Copy constructor (disabled).

◆ Probe() [3/3]

Probe::Probe ( Probe &&  )
delete

Move constructor (disabled).

◆ ~Probe()

Probe::~Probe ( )
default

Destructor

Member Function Documentation

◆ convolveRadiance()

void Probe::convolveRadiance ( float  clamp,
uint  layer 
)
private

Perform BRDF pre-integration of the probe radiance for increasing roughness and store them in the mip levels.

Parameters
clampmaximum intensity value, useful to avoid ringing artifacts
layerfirst layer to process (in 1, mip count - 1)

◆ estimateIrradiance()

void Probe::estimateIrradiance ( float  clamp)
private

Estimate the SH representation of the cubemap irradiance. The estimation is done on the GPU.

Parameters
clampmaximum intensity value, useful to avoid temporal instabilities

◆ extractIrradianceSHCoeffs()

void Probe::extractIrradianceSHCoeffs ( const Texture cubemap,
float  clamp,
std::vector< glm::vec3 > &  shCoeffs 
)
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.

Parameters
cubemapthe cubemap to extract SH coefficients from
clampmaximum intensity value, useful to avoid temporal instabilities
shCoeffswill contain the irradiance SH representation

◆ operator=() [1/2]

Probe & Probe::operator= ( const Probe )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Probe & Probe::operator= ( Probe &&  )
delete

Move assignment operator (disabled).

Returns
a reference to the object assigned to

◆ totalBudget()

uint Probe::totalBudget ( ) const
Returns
the total number of steps to completely update the probe data

◆ update()

void Probe::update ( uint  budget)

Update the content of the probe and the corresponding radiance and irradiance.

Parameters
budgetthe 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.

The documentation for this class was generated from the following files: