Euphoria
postproc.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "eu/render/texture.h"
6
7namespace eu::imgui
8{
9 struct PropTable;
10 struct ImguiShaderCache;
11}
12
13namespace eu::render
14{
15struct Texture2d;
16struct Renderer;
17struct Camera;
18struct World;
19struct RenderWorld;
20
25
28{
29 const World* world = nullptr;
30 Size window_size = {.width = 0, .height = 0};
32 const Camera* camera = nullptr;
33 Renderer* renderer = nullptr;
34};
35
39{
40 RenderSource() = default;
41 virtual ~RenderSource() = default;
42
43 RenderSource(const RenderSource&) = delete;
45 void operator=(const RenderSource&) = delete;
46 void operator=(RenderSource&&) = delete;
47
48 virtual void render(const PostProcArg& arg) = 0;
49};
50
65
69{
70 std::string name;
71 std::shared_ptr<RenderSource> source;
72 std::shared_ptr<FrameBuffer> fbo;
74
75 RenderTextureWithShader(std::string n, std::shared_ptr<RenderSource> s, std::shared_ptr<FrameBuffer> f, ShaderPropertyProvider* e);
76
78 void render(const PostProcArg& arg) override;
79
81 void update(const PostProcArg& arg);
82};
83
91{
93 std::shared_ptr<RenderSource> last_source;
94
95 std::vector<std::shared_ptr<RenderTextureWithShader>> targets;
96};
97
98
106
107
108struct EffectStack;
109
113struct Effect
114{
115 Effect() = default;
116 virtual ~Effect() = default;
117
118 Effect(const Effect&) = delete;
119 Effect(Effect&&) = delete;
120 void operator=(const Effect&) = delete;
121 void operator=(Effect&&) = delete;
122
123 virtual void build(const BuildArg& arg) = 0;
124 virtual void update(float dt) = 0;
125 virtual void gui() = 0;
126
127 [[nodiscard]] bool enabled() const;
128
129 protected:
130
131 void set_enabled(bool n);
132
133 private:
134
135 friend struct EffectStack;
136
137 bool is_enabled = false;
138 EffectStack* owner = nullptr;
139};
140
144{
146 [[nodiscard]] float get_factor() const;
147 void set_factor(float f);
148
149 private:
150
151 float factor = 0.0f;
152};
153
156{
158 bool dirty = true;
159 std::optional<Size> window_size;
160 std::vector<std::shared_ptr<Effect>> effects;
162
163 // render world settings
164 // todo(Gustav): is it useful to disable hdr rendering or should that just be removed?
165 // todo(Gustav): move exposure to a better place?
166 bool use_hdr = true;
167 float exposure = 1.0f;
168
169 std::shared_ptr<RenderWorld> render_world;
170
172 void render(const PostProcArg& arg);
173 void update(float dt) const;
176};
177
181
182}
Definition ui.h:8
a size
Definition size.h:11
Arguments for when building a effect stack.
Definition postproc.h:102
CompiledStack * builder
Definition postproc.h:103
The current perspective camera representation.
Definition camera.h:15
A compiled full-screen-effect.
Definition postproc.h:91
std::vector< std::shared_ptr< RenderTextureWithShader > > targets
Definition postproc.h:95
std::shared_ptr< RenderSource > last_source
start with a simple world, but depending on the current effect list, could be more....
Definition postproc.h:93
The facade of the post-proc framework.
Definition postproc.h:156
void render(const PostProcArg &arg)
rebuilds stack if dirty, update all targets, then render the last_source
void gui(imgui::ImguiShaderCache *cache, const imgui::PropTable &prop)
CompiledStack compiled
Definition postproc.h:161
void update(float dt) const
std::shared_ptr< RenderWorld > render_world
Definition postproc.h:169
std::vector< std::shared_ptr< Effect > > effects
Definition postproc.h:160
std::optional< Size > window_size
Definition postproc.h:159
virtual void update(float dt)=0
void operator=(const Effect &)=delete
Effect(Effect &&)=delete
friend struct EffectStack
Definition postproc.h:135
void set_enabled(bool n)
virtual void build(const BuildArg &arg)=0
bool enabled() const
virtual void gui()=0
void operator=(Effect &&)=delete
virtual ~Effect()=default
Effect(const Effect &)=delete
void set_factor(float f)
float get_factor() const
"render to texture" feature
Definition texture.h:103
Arguments for rendering a post-processing effect.
Definition postproc.h:28
const World * world
Definition postproc.h:29
const Camera * camera
Definition postproc.h:32
void operator=(const RenderSource &)=delete
void operator=(RenderSource &&)=delete
RenderSource(RenderSource &&)=delete
virtual ~RenderSource()=default
RenderSource(const RenderSource &)=delete
virtual void render(const PostProcArg &arg)=0
ShaderPropertyProvider * effect
Definition postproc.h:73
std::shared_ptr< FrameBuffer > fbo
Definition postproc.h:72
void render(const PostProcArg &arg) override
render internal fbo to a quad with a shader
void update(const PostProcArg &arg)
call render on linked source and render to fbo
RenderTextureWithShader(std::string n, std::shared_ptr< RenderSource > s, std::shared_ptr< FrameBuffer > f, ShaderPropertyProvider *e)
std::shared_ptr< RenderSource > source
Definition postproc.h:71
A source that "just" renders the world.
The rendering engine.
Definition renderer.h:33
A functor that sends properties/uniforms to the shader.
Definition postproc.h:54
virtual void use_shader(const PostProcArg &a, const FrameBuffer &t)=0
void operator=(ShaderPropertyProvider &&)=delete
void operator=(const ShaderPropertyProvider &)=delete
ShaderPropertyProvider(ShaderPropertyProvider &&)=delete
ShaderPropertyProvider(const ShaderPropertyProvider &)=delete
virtual ~ShaderPropertyProvider()=default
A 2d image texture.
Definition texture.h:74
A list of objects to render.
Definition world.h:201