Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
PBRDemo.hpp
1#pragma once
2
3#include "DeferredRenderer.hpp"
4#include "ForwardRenderer.hpp"
5#include "PostProcessStack.hpp"
6#include "DebugRenderer.hpp"
7
8#include "Application.hpp"
9#include "scene/Scene.hpp"
10#include "renderers/Renderer.hpp"
11#include "renderers/Probe.hpp"
12#include "renderers/shadowmaps/ShadowMap.hpp"
13#include "input/ControllableCamera.hpp"
14#include "system/Query.hpp"
15
16#include "Common.hpp"
17
22class PBRDemo final : public CameraApp {
23
24public:
29 explicit PBRDemo(RenderingConfig & config, Window & window);
30
32 void draw() override;
33
35 void update() override;
36
38 void physics(double fullTime, double frameTime) override;
39
41 void resize() override;
42
43private:
44
46 enum class RendererMode : int {
47 DEFERRED, FORWARD
48 };
49
53 void setScene(const std::shared_ptr<Scene> & scene);
54
59
61 void updateMaps();
62
63 std::vector<std::unique_ptr<ShadowMap>> _shadowMaps;
64 std::vector<std::unique_ptr<Probe>> _probes;
65 std::unique_ptr<DeferredRenderer> _defRenderer;
66 std::unique_ptr<ForwardRenderer> _forRenderer;
67 std::unique_ptr<PostProcessStack> _postprocess;
68 std::shared_ptr<DeferredRenderer> _probesRenderer;
69 std::unique_ptr<DebugRenderer> _debugRenderer;
72
73 std::vector<std::shared_ptr<Scene>> _scenes;
74 std::vector<std::string> _sceneNames;
75
84
85 RendererMode _mode = RendererMode::DEFERRED;
86 ShadowMode _shadowMode = ShadowMode::VARIANCE;
87 size_t _currentScene = 0;
88 const int _frameCount = 2;
89 int _frameID = 0;
90
91 bool _paused = false;
92 bool _showDebug = false;
93};
double frameTime()
Definition: Application.cpp:87
Window & window()
Definition: Application.cpp:95
Application with an interactive camera.
Definition: Application.hpp:89
Represent a GPU query, automatically buffered and retrieved.
Definition: GPUTypes.hpp:412
PBR rendering demonstration and interactions.
Definition: PBRDemo.hpp:22
std::unique_ptr< DeferredRenderer > _defRenderer
Deferred PBR renderer.
Definition: PBRDemo.hpp:65
GPUQuery _rendererTime
Timing for the scene rendering.
Definition: PBRDemo.hpp:80
std::vector< std::string > _sceneNames
The associated scene names.
Definition: PBRDemo.hpp:74
RendererMode
Definition: PBRDemo.hpp:46
std::vector< std::shared_ptr< Scene > > _scenes
The existing scenes.
Definition: PBRDemo.hpp:73
void updateMaps()
Definition: PBRDemo.cpp:95
bool _paused
Pause animations.
Definition: PBRDemo.hpp:91
void createShadowMaps(ShadowMode mode)
Definition: PBRDemo.cpp:283
RendererMode _mode
Active renderer.
Definition: PBRDemo.hpp:85
void setScene(const std::shared_ptr< Scene > &scene)
Definition: PBRDemo.cpp:38
ShadowMode _shadowMode
The shadow rendering technique.
Definition: PBRDemo.hpp:86
Texture _finalRender
Final texture.
Definition: PBRDemo.hpp:70
void resize() override
Definition: PBRDemo.cpp:272
int _frameID
Current frame count (will loop)
Definition: PBRDemo.hpp:89
void physics(double fullTime, double frameTime) override
Definition: PBRDemo.cpp:266
size_t _currentScene
Currently selected scene.
Definition: PBRDemo.hpp:87
GPUQuery _shadowTime
Timing for the shadow mapping.
Definition: PBRDemo.hpp:76
std::unique_ptr< ForwardRenderer > _forRenderer
Forward PBR renderer.
Definition: PBRDemo.hpp:66
void draw() override
Definition: PBRDemo.cpp:121
Query _totalTime
CPU timing for one full frame.
Definition: PBRDemo.hpp:83
GPUQuery _inteTime
Timing for the probe preconvolution.
Definition: PBRDemo.hpp:78
const int _frameCount
Number of frames to update a probe over.
Definition: PBRDemo.hpp:88
std::shared_ptr< DeferredRenderer > _probesRenderer
Renderer for the light probes.
Definition: PBRDemo.hpp:68
Query _copyTimeCPU
CPU timing for the probe irradiance SH coeffs.
Definition: PBRDemo.hpp:82
GPUQuery _postprocessTime
Timing for the postprocessing.
Definition: PBRDemo.hpp:81
Program * _finalProgram
Final display program.
Definition: PBRDemo.hpp:71
void update() override
Definition: PBRDemo.cpp:173
GPUQuery _probesTime
Timing for the probe rendering.
Definition: PBRDemo.hpp:77
GPUQuery _copyTime
Timing for the probe irradiance SH coeffs.
Definition: PBRDemo.hpp:79
std::vector< std::unique_ptr< Probe > > _probes
The environment probes.
Definition: PBRDemo.hpp:64
std::vector< std::unique_ptr< ShadowMap > > _shadowMaps
The lights shadow maps.
Definition: PBRDemo.hpp:63
std::unique_ptr< PostProcessStack > _postprocess
Post-process renderer.
Definition: PBRDemo.hpp:67
std::unique_ptr< DebugRenderer > _debugRenderer
Forward PBR renderer.
Definition: PBRDemo.hpp:69
bool _showDebug
Debug scene objects.
Definition: PBRDemo.hpp:92
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Perform CPU duration measurement between two time points.
Definition: Query.hpp:12
Configuration containing parameters for windows and renderers.
Definition: Config.hpp:113
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
Represent an OS window and its associated rendering context.
Definition: Window.hpp:14
ShadowMode
Available shadow mapping techniques.
Definition: ShadowMap.hpp:14