Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Probe.hpp
1#pragma once
2
3#include "resources/Buffer.hpp"
4#include "resources/ResourcesManager.hpp"
5#include "resources/Texture.hpp"
6#include "renderers/Renderer.hpp"
7#include "input/Camera.hpp"
8#include "Common.hpp"
9
10class LightProbe;
11
19class Probe {
20
21public:
22
31 Probe(LightProbe & probe, std::shared_ptr<Renderer> renderer, uint size, uint mips, const glm::vec2 & clippingPlanes);
32
36 void update(uint budget);
37
39 uint totalBudget() const;
40
44 Probe & operator=(const Probe &) = delete;
45
47 Probe(const Probe &) = delete;
48
52 Probe & operator=(Probe &&) = delete;
53
55 Probe(Probe &&) = delete;
56
58 ~Probe() = default;
59
69 static void extractIrradianceSHCoeffs(const Texture & cubemap, float clamp, std::vector<glm::vec3> & shCoeffs);
70
71private:
72
77 void convolveRadiance(float clamp, uint layer);
78
82 void estimateIrradiance(float clamp);
83
84 std::shared_ptr<Renderer> _renderer;
87 std::shared_ptr<Buffer> _shCoeffs;
88
89 std::array<Camera, 6> _cameras;
90 glm::vec3 _position;
93
95 enum class ProbeState {
99 };
100 // Initial state machine status.
102 uint _substepDraw = 0;
104};
Store environment lighting for reflections.
Definition: LightProbe.hpp:12
A probe can be used to capture the appareance of a scene at a given location as a 360° cubemap.
Definition: Probe.hpp:19
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...
Definition: Probe.cpp:116
uint _substepRadiance
If convolving radiance, current level.
Definition: Probe.hpp:103
uint totalBudget() const
Definition: Probe.cpp:202
~Probe()=default
Texture _result
The cubemap content.
Definition: Probe.hpp:85
ProbeState
Probe update state machine.
Definition: Probe.hpp:95
@ CONVOLVE_RADIANCE
Convolving the cubemap to generate radiance for a given roughness level.
@ DRAW_FACES
Drawing a cubemap face with the environment.
@ GENERATE_IRRADIANCE
Integrate irradiance in a compute shader.
std::shared_ptr< Buffer > _shCoeffs
SH representation of the cubemap irradiance.
Definition: Probe.hpp:87
Probe & operator=(Probe &&)=delete
Texture _copy
Downscaled copy of the cubemap content.
Definition: Probe.hpp:86
Probe & operator=(const Probe &)=delete
Probe(Probe &&)=delete
void estimateIrradiance(float clamp)
Definition: Probe.cpp:101
void convolveRadiance(float clamp, uint layer)
Definition: Probe.cpp:80
glm::vec3 _position
The probe location.
Definition: Probe.hpp:90
Program * _irradianceCompute
Irradiance SH projection shader.
Definition: Probe.hpp:92
Probe(const Probe &)=delete
uint _substepDraw
If drawing, current face.
Definition: Probe.hpp:102
std::array< Camera, 6 > _cameras
Camera for each face.
Definition: Probe.hpp:89
void update(uint budget)
Definition: Probe.cpp:31
Program * _radianceCompute
Radiance preconvolution shader.
Definition: Probe.hpp:91
std::shared_ptr< Renderer > _renderer
The renderer to use.
Definition: Probe.hpp:84
ProbeState _currentState
Current update state.
Definition: Probe.hpp:101
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12