Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
tonemap_pass.hpp
Go to the documentation of this file.
1
6
7
#pragma once
8
9
#include "
../post_process_pass_base.hpp
"
10
#include "
../post_process_settings.hpp
"
11
#include "
../post_process_target.hpp
"
12
#include "../shader_layout.hpp"
13
#include "../vulkan_common.hpp"
14
#include "../vulkan_pipeline.hpp"
15
16
#include <array>
17
#include <chrono>
18
#include <cstdint>
19
#include <glm/glm.hpp>
20
#include <optional>
21
#include <vector>
22
23
namespace
renderer {
24
class
VulkanCore
;
25
26
enum class
TonemapMode : uint8_t {
27
reinhard = 0,
28
aces = 1,
29
};
30
31
class
TonemapPass :
public
IPostProcessPass
{
32
public
:
33
TonemapPass(
const
VulkanCore
& core, vk::Format ldr_format, vk::Extent2D extent);
34
35
[[nodiscard]]
36
auto
name()
const
-> std::string_view
override
{
37
return
"Tonemap"
;
38
}
39
40
auto
record
(vk::CommandBuffer cmd, uint32_t frame_index, vk::ImageView source_view) -> vk::ImageView
override
;
41
42
void
onResize(vk::Extent2D extent)
override
;
43
44
private
:
46
struct
Params {
47
float
exposure = 1.0f;
48
uint32_t mode =
static_cast<
uint32_t
>
(TonemapMode::reinhard);
49
float
gamma = 2.2f;
50
float
contrast = 1.0f;
51
float
saturation = 1.0f;
52
float
vignette = 0.0f;
53
float
grain = 0.0f;
54
float
time = 0.0f;
55
uint32_t auto_exposure = 0;
56
std::array<float, 3> pad0 {};
57
};
58
60
struct
ExposureParams {
61
float
min_log = 0.0f;
62
float
log_range = 1.0f;
63
float
delta_time = 0.0f;
64
float
snap = 0.0f;
65
float
speed_up = 0.0f;
66
float
speed_down = 0.0f;
67
uint32_t width = 0;
68
uint32_t height = 0;
69
};
70
71
void
createResources(
const
VulkanCore
& core);
72
void
createExposureResources(
const
VulkanCore
& core);
73
void
createTarget(
const
VulkanCore
& core, vk::Extent2D extent);
74
76
void
recordExposure(
77
vk::CommandBuffer cmd, uint32_t frame_index, vk::ImageView source_view,
const
PostProcessSettings::Tonemap
& settings
78
);
79
80
const
VulkanCore
* m_core =
nullptr
;
81
vk::Format m_ldr_format = vk::Format::eUndefined;
82
83
PostProcessTarget
m_target;
84
85
ShaderLayout
m_shader_layout;
86
VulkanPipeline
m_pipeline;
87
88
vk::raii::Sampler m_sampler =
nullptr
;
89
std::vector<vk::raii::DescriptorSet> m_descriptor_sets;
90
std::vector<FrameResources> m_params_buffers;
91
92
std::vector<vk::ImageView> m_bound_views;
93
94
ShaderLayout
m_exposure_layout;
95
VulkanPipeline
m_histogram_pipeline;
96
VulkanPipeline
m_adapt_pipeline;
97
98
std::optional<vma::raii::Buffer> m_histogram;
99
101
std::optional<vma::raii::Buffer> m_exposure;
102
103
std::vector<vk::raii::DescriptorSet> m_exposure_sets;
104
std::vector<vk::ImageView> m_exposure_bound_views;
105
106
bool
m_exposure_ready =
false
;
107
bool
m_was_metering =
false
;
108
std::chrono::steady_clock::time_point m_last_meter;
109
};
110
111
}
renderer::IPostProcessPass
Definition
post_process_pass_base.hpp:14
renderer::PostProcessTarget
Definition
post_process_target.hpp:19
renderer::ShaderLayout
Definition
shader_layout.hpp:12
renderer::TonemapPass::record
auto record(vk::CommandBuffer cmd, uint32_t frame_index, vk::ImageView source_view) -> vk::ImageView override
Definition
tonemap_pass.cpp:291
renderer::VulkanCore
Definition
vulkan_core.hpp:48
renderer::VulkanPipeline
Definition
vulkan_pipeline.hpp:19
post_process_pass_base.hpp
post_process_settings.hpp
post_process_target.hpp
renderer::PostProcessSettings::Tonemap
Definition
post_process_settings.hpp:22
engine
src
toast
renderer
passes
tonemap_pass.hpp
Generated by
1.17.0