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
14namespace RavEngine{
15
16enum class PostProcessTextureInput : uint8_t{
17 Unused,
18 EngineColor,
19 UserDefined
20};
21
22enum class PostProcessOutput : uint8_t{
23 EngineColor,
24 UserDefined
25};
26
27constexpr static uint8_t nPostProcessTextureInputs = 8;
28constexpr static uint8_t nPostProcessSamplerInputs = nPostProcessTextureInputs + 1;
29
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
39 Array<PostProcessTextureInput, nPostProcessTextureInputs> inputconfiguration = { PostProcessTextureInput::EngineColor };
40 PostProcessOutput outputConfiguration = PostProcessOutput::EngineColor;
41 bool clearOutputBeforeRendering = false;
42};
43
45 glm::ivec4 dim;
46};
47
49 const RGL::TextureFormat outputFormat;
50};
51
53 ScreenEffectBase(const std::string_view name, const ScreenEffectConfig& config, const ScreenEffectInternalConfig& internalConfig);
54
55 const auto GetPipeline() const {
56 return pipeline;
57 }
58private:
59 RGLRenderPipelinePtr pipeline;
60};
61
62template<typename T>
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
73 RGL::TextureView outputBinding;
74 const auto GetEffect() const{
75 return effect;
76 }
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;
87private:
88 Ref<T> effect;
89};
90
91template<typename T>
93 Vector<Ref<T>> passes;
94 bool enabled = true;
95 virtual void Preamble(dim_t<int> targetSize){}
96};
97
98}
99#endif
Definition Span.hpp:11
Definition concurrentqueue.h:747
uint8 uint8_t
Definition fwd.hpp:103
Definition Animation.hpp:6
Definition Texture.hpp:43
Definition ScreenEffect.hpp:44
Definition ScreenEffect.hpp:38
Definition ScreenEffect.hpp:52
Definition ScreenEffect.hpp:30
Definition ScreenEffect.hpp:48
Definition ScreenEffect.hpp:63
Definition ScreenEffect.hpp:92
Definition qualifier.hpp:35