Unravel Engine C++ Reference
Loading...
Searching...
No Matches
hiz_pass.h
Go to the documentation of this file.
1#pragma once
2
6#include <graphics/texture.h>
8#include <hpp/small_vector.hpp>
9#include <bgfx/bgfx.h>
10
11namespace unravel
12{
13
15{
16public:
23
25 auto init(rtti::context& ctx) -> bool;
26
28 void run(gfx::render_view& rview, const run_params& params);
29
30private:
32 struct hiz_generate_program : uniforms_cache
33 {
34 gpu_program::ptr program;
36 gfx::program::uniform_ptr u_hiz_params;
37
38 void cache_uniforms()
39 {
40 cache_uniform(program.get(), s_depth, "s_depth", gfx::uniform_type::Sampler);
41 cache_uniform(program.get(), u_hiz_params, "u_hiz_params", gfx::uniform_type::Vec4);
42 }
43 };
44
46 struct hiz_downsample_program : uniforms_cache
47 {
48 gpu_program::ptr program;
49 gfx::program::uniform_ptr u_hiz_params;
50
51 void cache_uniforms()
52 {
53 cache_uniform(program.get(), u_hiz_params, "u_hiz_params", gfx::uniform_type::Vec4);
54 }
55 };
56
57 hiz_generate_program hiz_generate_;
58 hiz_downsample_program hiz_downsample_;
59};
60
61} // namespace unravel
Class representing a camera. Contains functionality for manipulating and updating a camera....
Definition camera.h:35
std::shared_ptr< gpu_program > ptr
Definition gpu_program.h:19
void run(gfx::render_view &rview, const run_params &params)
Executes the Hi-Z generation: generates mip chain from depth buffer using compute shaders.
Definition hiz_pass.cpp:35
auto init(rtti::context &ctx) -> bool
Must be called once (after bgfx::init() and after asset_manager is registered in context).
Definition hiz_pass.cpp:10
std::shared_ptr< uniform > uniform_ptr
Definition program.h:19
gfx::texture::ptr depth_buffer
Source depth buffer.
Definition hiz_pass.h:19
const camera * cam
Camera for near/far plane information.
Definition hiz_pass.h:21
gfx::texture::ptr output_hiz
Output Hi-Z texture (must be R32F or R16F format with mips)
Definition hiz_pass.h:20
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.