Hymn to Beauty
C++ 3D Engine
PostProcessing.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <glm/glm.hpp>
4#include "../LowLevelRenderer/Interface/Texture.hpp"
5
6namespace Video {
7class LowLevelRenderer;
8class Shader;
9class ShaderProgram;
10class GraphicsPipeline;
11class RenderSurface;
12class Filter;
13class CommandBuffer;
14class Sampler;
15class Buffer;
16
19 public:
22 bool tonemapping = true;
23 float gamma = 2.2f;
24
25 struct FXAA {
26 bool enabled = false;
28
29 struct Dither {
30 bool enabled = false;
32
33 struct Bloom {
34 bool enabled = false;
35 float intensity = 1.0f;
36 float threshold = 1.0f;
37 float scatter = 0.7f;
39 };
40
42
45 explicit PostProcessing(LowLevelRenderer* lowLevelRenderer);
46
49
51
55 void Configure(const Configuration& configuration, Texture* outputTexture);
56
58
65 void ApplyPostProcessing(CommandBuffer& commandBuffer, Texture* inputTexture, Texture::Format format);
66
67 private:
68 PostProcessing(const PostProcessing& other) = delete;
69
70 void CreateBloomResources();
71 void FreeBloomResources();
72 void GenerateBloomTexture(CommandBuffer& commandBuffer, Texture* inputTexture);
73
74 LowLevelRenderer* lowLevelRenderer;
75
76 Configuration configuration;
77 glm::uvec2 screenSize;
78 Shader* vertexShader;
79
80 Texture* outputTexture = nullptr;
81
82 Texture* dummyTexture;
83
84 const Sampler* sampler;
85
86 // Bloom.
87 struct BloomData {
88 Texture* textures[2];
89 };
90 BloomData* bloomPasses;
91 uint32_t bloomPassCount;
92 Shader* bloomThresholdShader;
93 ShaderProgram* bloomThresholdShaderProgram;
94 GraphicsPipeline* bloomThresholdPipeline;
95 Shader* bloomDownscaleShader;
96 ShaderProgram* bloomDownscaleShaderProgram;
97 GraphicsPipeline* bloomDownscalePipeline;
98 Shader* bloomUpscaleShader;
99 ShaderProgram* bloomUpscaleShaderProgram;
100 GraphicsPipeline* bloomUpscalePipeline;
101 Shader* bloomBlurShader;
102 ShaderProgram* bloomBlurShaderProgram;
103 GraphicsPipeline* bloomBlurPipeline;
104
105 // Uber.
106 Shader* uberShader;
107 ShaderProgram* uberShaderProgram;
108 GraphicsPipeline* uberPipeline;
109 Buffer* uberUniformBuffer;
110
111 struct UberUniforms {
112 float gamma;
113 float bloomIntensity;
114 float time;
115 uint32_t ditherEnable;
116 uint32_t tonemapping;
117 };
118
119 // FXAA + dither.
120 Shader* fxaaShader;
121 ShaderProgram* fxaaShaderProgram;
122 GraphicsPipeline* fxaaPipeline;
123 Buffer* fxaaUniformBuffer;
124
125 struct FXAAUniforms {
126 glm::vec2 screenSize;
127 float time;
128 uint32_t ditherEnable;
129 };
130};
131
132} // namespace Video
A buffer into which rendering commands are recorded.
Definition: CommandBuffer.hpp:24
Low level renderer abstracting the underlaying graphics API (OpenGL or Vulkan).
Definition: LowLevelRenderer.hpp:27
Applies post-processing effects to the rendered image.
Definition: PostProcessing.hpp:18
void Configure(const Configuration &configuration, Texture *outputTexture)
Configure the post-processing.
Definition: PostProcessing.cpp:99
PostProcessing(LowLevelRenderer *lowLevelRenderer)
Create new post-processing handler.
Definition: PostProcessing.cpp:22
~PostProcessing()
Destructor.
Definition: PostProcessing.cpp:69
void ApplyPostProcessing(CommandBuffer &commandBuffer, Texture *inputTexture, Texture::Format format)
Apply post-processing effects.
Definition: PostProcessing.cpp:131
Determines how a texture should be sampled.
Definition: Sampler.hpp:6
Compiles and handles a shader. Shaders should be linked together into a ShaderProgram.
Definition: Shader.hpp:8
A texture.
Definition: Texture.hpp:8
Format
The format of the texture.
Definition: Texture.hpp:18
Definition: Editor.hpp:18
Definition: PostProcessing.hpp:33
float threshold
Definition: PostProcessing.hpp:36
float scatter
Definition: PostProcessing.hpp:37
float intensity
Definition: PostProcessing.hpp:35
bool enabled
Definition: PostProcessing.hpp:34
Definition: PostProcessing.hpp:29
bool enabled
Definition: PostProcessing.hpp:30
Definition: PostProcessing.hpp:25
bool enabled
Definition: PostProcessing.hpp:26
Post-processing configuration.
Definition: PostProcessing.hpp:21
struct Video::PostProcessing::Configuration::Bloom bloom
bool tonemapping
Definition: PostProcessing.hpp:22
struct Video::PostProcessing::Configuration::FXAA fxaa
float gamma
Definition: PostProcessing.hpp:23
struct Video::PostProcessing::Configuration::Dither dither