Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
SSAOPreRenderOperator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_SSAO_PRE_RENDER_OPERATOR_H_
34#define DVD_SSAO_PRE_RENDER_OPERATOR_H_
35
38
39namespace Divide {
40
42 public:
44 ~SSAOPreRenderOperator() override;
45
46 [[nodiscard]] bool execute(PlayerIndex idx, const CameraSnapshot& cameraSnapshot, const RenderTargetHandle& input, const RenderTargetHandle& output, GFX::CommandBuffer& bufferInOut) override;
47 void reshape(U16 width, U16 height) override;
48
49 [[nodiscard]] F32 radius() const noexcept { return _radius[_genHalfRes ? 1 : 0]; }
50 void radius(F32 val);
51
52 [[nodiscard]] F32 power() const noexcept { return _power[_genHalfRes ? 1 : 0]; }
53 void power(F32 val);
54
55 [[nodiscard]] F32 bias() const noexcept { return _bias[_genHalfRes ? 1 : 0]; }
56 void bias(F32 val);
57
58 [[nodiscard]] bool genHalfRes() const noexcept { return _genHalfRes; }
59 void genHalfRes(bool state);
60
61 [[nodiscard]] bool blurResults() const noexcept { return _blur[_genHalfRes ? 1 : 0]; }
62 void blurResults(bool state) noexcept;
63
64 [[nodiscard]] F32 blurThreshold() const noexcept { return _blurThreshold[_genHalfRes ? 1 : 0]; }
65 void blurThreshold(F32 val);
66
67 [[nodiscard]] F32 blurSharpness() const noexcept { return _blurSharpness[_genHalfRes ? 1 : 0]; }
68 void blurSharpness(F32 val);
69
70 [[nodiscard]] I32 blurKernelSize() const noexcept { return _kernelSize[_genHalfRes ? 1 : 0]; }
71 void blurKernelSize(I32 val);
72
73 [[nodiscard]] F32 maxRange() const noexcept { return _maxRange[_genHalfRes ? 1 : 0]; }
74 void maxRange(F32 val);
75
76 [[nodiscard]] F32 fadeStart() const noexcept { return _fadeStart[_genHalfRes ? 1 : 0]; }
77 void fadeStart(F32 val);
78
79 [[nodiscard]] U8 sampleCount() const noexcept;
80
81 [[nodiscard]] bool ready() const noexcept override;
82
83 protected:
84 void onToggle(const bool state) override { PreRenderOperator::onToggle(state); _stateChanged = true; }
85 void prepare(PlayerIndex idx, GFX::CommandBuffer& bufferInOut) override;
86
87 private:
90 Handle<ShaderProgram> _ssaoGenerateShader = INVALID_HANDLE<ShaderProgram>;
91 Handle<ShaderProgram> _ssaoGenerateHalfResShader = INVALID_HANDLE<ShaderProgram>;
92 Handle<ShaderProgram> _ssaoBlurShaderHorizontal = INVALID_HANDLE<ShaderProgram>;
93 Handle<ShaderProgram> _ssaoBlurShaderVertical = INVALID_HANDLE<ShaderProgram>;
94 Handle<ShaderProgram> _ssaoPassThroughShader = INVALID_HANDLE<ShaderProgram>;
95 Handle<ShaderProgram> _ssaoDownSampleShader = INVALID_HANDLE<ShaderProgram>;
96 Handle<ShaderProgram> _ssaoUpSampleShader = INVALID_HANDLE<ShaderProgram>;
104
105 Handle<Texture> _noiseTexture = INVALID_HANDLE<Texture>;
111 F32 _radius[2] = { 0.0f, 0.0f };
112 F32 _bias[2] = { 0.0f, 0.0f };
113 F32 _power[2] = { 0.0f, 0.0f };
114 F32 _maxRange[2] = { 1.f, 1.f };
115 F32 _fadeStart[2] = { 1.f, 1.f };
116 F32 _blurThreshold[2] = { 0.05f, 0.05f };
117 F32 _blurSharpness[2] = { 40.f, 40.f };
118 I32 _kernelSize[2] = { 3, 3 };
119 U8 _kernelSampleCount[2] = { 0u, 0u };
120 bool _blur[2] = { false, false };
121 bool _stateChanged = false;
122 bool _genHalfRes = false;
123};
124
125} // namespace Divide
126
127#endif //DVD_SSAO_PRE_RENDER_OPERATOR_H_
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
virtual void onToggle(bool state)
void prepare(PlayerIndex idx, GFX::CommandBuffer &bufferInOut) override
Handle< ShaderProgram > _ssaoUpSampleShader
Handle< ShaderProgram > _ssaoBlurShaderVertical
void reshape(U16 width, U16 height) override
Handle< ShaderProgram > _ssaoGenerateHalfResShader
void onToggle(const bool state) override
Handle< ShaderProgram > _ssaoGenerateShader
bool ready() const noexcept override
Handle< ShaderProgram > _ssaoDownSampleShader
Handle< ShaderProgram > _ssaoPassThroughShader
Handle< ShaderProgram > _ssaoBlurShaderHorizontal
bool execute(PlayerIndex idx, const CameraSnapshot &cameraSnapshot, const RenderTargetHandle &input, const RenderTargetHandle &output, GFX::CommandBuffer &bufferInOut) override
Return true if we rendered into "output".
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int32_t I32
uint8_t U8
Project & parent
Definition: DefaultScene.h:41
uint16_t U16