Unravel Engine C++ Reference
Loading...
Searching...
No Matches
prefilter_pass.h
Go to the documentation of this file.
1// prefilter_pass.h
2#pragma once
3
4#include <bgfx/bgfx.h>
8#include <graphics/texture.h>
9
10namespace unravel
11{
14{
15public:
23
25 auto init(rtti::context& ctx) -> bool;
26
28 auto run(const run_params& params) -> gfx::texture::ptr;
29
31 auto run_compute(const run_params& params) -> gfx::texture::ptr;
32
33private:
34
35 struct cs_prog : uniforms_cache
36 {
37 void cache_uniforms()
38 {
39 cache_uniform(program.get(), s_env, "s_env", gfx::uniform_type::Sampler);
40 cache_uniform(program.get(), u_data, "u_data", gfx::uniform_type::Vec4);
41 }
42
45 std::unique_ptr<gpu_program> program;
46 } cs_;
47
48 gfx::texture::ptr output_cube_;
49};
50
51} // namespace unravel
Performs GGX prefiltering on six 2D face textures to produce a filtered cubemap.
auto run(const run_params &params) -> gfx::texture::ptr
Execute prefilter. Returns the filtered cubemap (output_cube or created internally).
auto run_compute(const run_params &params) -> gfx::texture::ptr
Execute prefilter using compute shader. Returns the filtered cubemap.
auto init(rtti::context &ctx) -> bool
Initialize shaders. Call once after bgfx::init() and asset registration.
std::shared_ptr< uniform > uniform_ptr
Definition program.h:19
std::array< gfx::texture::ptr, 6 > input_faces
gfx::texture::ptr output_cube_prefiltered
Optional destination cubemap (will be created if null).
gfx::texture::ptr output_cube
Optional destination cubemap (will be created if null).
bool apply_prefilter
If false, copies mips from input to output.
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.