Unravel Engine C++ Reference
Loading...
Searching...
No Matches
fxaa_pass.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace unravel
8{
9
11{
12public:
13 // Optional extra parameters could be added here if you want
14 // to tweak FXAA settings or pass other data in the future.
20
21 // Initialize the pass (load shaders, create GPU program).
22 auto init(rtti::context& ctx) -> bool;
23
24 // Run the pass on the given input frame buffer.
25 auto run(gfx::render_view& rview, const run_params& params) -> gfx::frame_buffer::ptr;
26
27private:
28 auto create_or_update_output_fb(const gfx::frame_buffer::ptr& input, const gfx::frame_buffer::ptr& output)
30 // Encapsulate the GPU program + any uniforms we might need.
31 struct fxaa_program : uniforms_cache
32 {
33 // Cache the uniforms.
34 // For FXAA we really only need to set up the sampler uniform (s_input).
35 void cache_uniforms()
36 {
37 // 'u_viewTexel' is built-in. We do NOT need to manually cache it.
38 // We just need the sampler2D "s_input".
39 cache_uniform(program.get(), s_input, "s_input", gfx::uniform_type::Sampler);
40 }
41
43 std::unique_ptr<gpu_program> program;
44 } fxaa_program_;
45
47};
48
49} // namespace unravel
auto init(rtti::context &ctx) -> bool
Definition fxaa_pass.cpp:12
auto run(gfx::render_view &rview, const run_params &params) -> gfx::frame_buffer::ptr
Definition fxaa_pass.cpp:77
std::shared_ptr< uniform > uniform_ptr
Definition program.h:19
gfx::frame_buffer::ptr output
Definition fxaa_pass.h:18
gfx::frame_buffer::ptr input
Definition fxaa_pass.h:17
Structure for caching uniforms.
void cache_uniform(gpu_program *program, gfx::program::uniform_ptr &uniform, const hpp::string_view &name, gfx::uniform_type type, uint16_t num=1)
Caches a uniform in the GPU program.