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>
9#include <graphics/texture.h>
10
11namespace unravel
12{
15{
16public:
24
26 auto init(rtti::context& ctx) -> bool;
27
29 auto run(gfx::render_view& rview, const run_params& params) -> gfx::texture::ptr;
30
32 auto run_compute(gfx::render_view& rview, const run_params& params) -> gfx::texture::ptr;
33
34private:
35 void generate_mips(const gfx::texture::ptr& texture);
36
37 struct cs_prog : uniforms_cache
38 {
39 void cache_uniforms()
40 {
41 cache_uniform(program.get(), s_env, "s_env", gfx::uniform_type::Sampler);
42 cache_uniform(program.get(), u_data, "u_data", gfx::uniform_type::Vec4);
43 }
44
47 std::unique_ptr<gpu_program> program;
48 } cs_;
49
50};
51
52} // namespace unravel
Performs GGX prefiltering on six 2D face textures to produce a filtered cubemap.
auto run(gfx::render_view &rview, const run_params &params) -> gfx::texture::ptr
Execute prefilter. Returns the filtered cubemap (output_cube or created internally).
auto run_compute(gfx::render_view &rview, 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.