RavEngine
Loading...
Searching...
No Matches
ScreenEffect.hpp
1
#pragma once
2
#if !RVE_SERVER
3
#include <string_view>
4
#include <RGL/Pipeline.hpp>
5
#include "Ref.hpp"
6
#include "DataStructures.hpp"
7
#include "mathtypes.hpp"
8
#include "Texture.hpp"
9
#include <RGL/Span.hpp>
10
#include <RGL/RGL.hpp>
11
#include <RGL/Types.hpp>
12
#include <RGL/Texture.hpp>
13
14
namespace
RavEngine
{
15
16
enum class
PostProcessTextureInput :
uint8_t
{
17
Unused,
18
EngineColor,
19
UserDefined
20
};
21
22
enum class
PostProcessOutput :
uint8_t
{
23
EngineColor,
24
UserDefined
25
};
26
27
constexpr
static
uint8_t
nPostProcessTextureInputs = 8;
28
constexpr
static
uint8_t
nPostProcessSamplerInputs = nPostProcessTextureInputs + 1;
29
30
struct
ScreenEffectConfig
{
31
std::vector<RGL::PipelineLayoutDescriptor::LayoutBindingDesc> bindings;
32
uint8_t pushConstantSize = 0;
// only 128 bytes of total push constant space are allowed
33
RGL::BlendFactor
34
sourceColorBlendFactor = RGL::BlendFactor::One,
35
destinationColorBlendFactor = RGL::BlendFactor::Zero;
36
};
37
38
struct
PostProcessInstanceConfig
{
39
Array<PostProcessTextureInput, nPostProcessTextureInputs>
inputconfiguration = { PostProcessTextureInput::EngineColor };
40
PostProcessOutput outputConfiguration = PostProcessOutput::EngineColor;
41
bool
clearOutputBeforeRendering =
false
;
42
};
43
44
struct
BasePushConstantUBO
{
45
glm::ivec4
dim;
46
};
47
48
struct
ScreenEffectInternalConfig
{
49
const
RGL::TextureFormat outputFormat;
50
};
51
52
struct
ScreenEffectBase
{
53
ScreenEffectBase
(
const
std::string_view name,
const
ScreenEffectConfig
& config,
const
ScreenEffectInternalConfig
&
internalConfig
);
54
55
const
auto
GetPipeline()
const
{
56
return
pipeline;
57
}
58
private
:
59
RGLRenderPipelinePtr pipeline;
60
};
61
62
template
<
typename
T>
63
struct
ScreenEffectPassInstance
{
64
ScreenEffectPassInstance
(
Ref<T>
effect,
const
PostProcessInstanceConfig
& config ) : effect(effect), inputConfiguration(config.inputconfiguration), outputConfiguration(config.outputConfiguration), clearOutputBeforeRendering(config.clearOutputBeforeRendering) {};
65
~ScreenEffectPassInstance
() =
default
;
66
67
virtual
const
RGL::untyped_span
GetPushConstantData()
const
{
68
return
{
nullptr
,0};
// return nullptr if you do not have additional push constants
69
}
70
71
Array<RGL::TextureView,nPostProcessTextureInputs>
inputBindings;
72
Array<RGLSamplerPtr, nPostProcessSamplerInputs>
inputSamplerBindings;
73
RGL::TextureView
outputBinding;
74
const
auto
GetEffect()
const
{
75
return
effect;
76
}
77
using
InputConfigurationType
=
Array<PostProcessTextureInput,nPostProcessTextureInputs>
;
78
InputConfigurationType
inputConfiguration;
79
PostProcessOutput outputConfiguration;
80
const
auto
& GetinputConfiguration()
const
{
81
return
inputConfiguration;
82
}
83
virtual
dim_t<int>
GetUserDefinedOutputSize()
const
{
// called if using a custom output texture
84
return
{ 0,0 };
85
}
86
bool
clearOutputBeforeRendering =
false
;
87
private
:
88
Ref<T>
effect;
89
};
90
91
template
<
typename
T>
92
struct
ScreenEffect
{
93
Vector<Ref<T>
> passes;
94
bool
enabled =
true
;
95
virtual
void
Preamble(
dim_t<int>
targetSize
){}
96
};
97
98
}
99
#endif
RGL::untyped_span
Definition
Span.hpp:11
moodycamel::ConcurrentQueue
Definition
concurrentqueue.h:747
glm::uint8_t
uint8 uint8_t
Definition
fwd.hpp:103
RavEngine
Definition
Animation.hpp:6
RGL::TextureView
Definition
Texture.hpp:43
RavEngine::BasePushConstantUBO
Definition
ScreenEffect.hpp:44
RavEngine::PostProcessInstanceConfig
Definition
ScreenEffect.hpp:38
RavEngine::ScreenEffectBase
Definition
ScreenEffect.hpp:52
RavEngine::ScreenEffectConfig
Definition
ScreenEffect.hpp:30
RavEngine::ScreenEffectInternalConfig
Definition
ScreenEffect.hpp:48
RavEngine::ScreenEffectPassInstance
Definition
ScreenEffect.hpp:63
RavEngine::ScreenEffect
Definition
ScreenEffect.hpp:92
glm::vec
Definition
qualifier.hpp:35
RavEngine
include
RavEngine
ScreenEffect.hpp
Generated by
1.9.8