Unravel Engine C++ Reference
Loading...
Searching...
No Matches
bloom_component.h
Go to the documentation of this file.
1#pragma once
2
3#include <base/basetypes.hpp>
6#include <cmath>
7
8namespace unravel
9{
10
11class bloom_component : public component_crtp<bloom_component>
12{
13public:
14 bool enabled = true;
16
18 static void merge_into(bloom_pass::settings& result,
19 const bloom_pass::settings& from,
20 float contribution,
21 bool is_first)
22 {
23 if(is_first)
24 {
25 result = from;
26 return;
27 }
28
29 auto lerp_color = [](math::color& dst, const math::color& src, float t) -> void {
30 dst.value.x = std::lerp(dst.value.x, src.value.x, t);
31 dst.value.y = std::lerp(dst.value.y, src.value.y, t);
32 dst.value.z = std::lerp(dst.value.z, src.value.z, t);
33 dst.value.w = std::lerp(dst.value.w, src.value.w, t);
34 };
35
36 result.threshold = std::lerp(result.threshold, from.threshold, contribution);
37 result.soft_knee = std::lerp(result.soft_knee, from.soft_knee, contribution);
38 result.clamp = std::lerp(result.clamp, from.clamp, contribution);
39 result.intensity = std::lerp(result.intensity, from.intensity, contribution);
40 result.mip_count = static_cast<int>(std::lround(std::lerp(float(result.mip_count), float(from.mip_count), contribution)));
41
42 lerp_color(result.mip0_tint, from.mip0_tint, contribution);
43 lerp_color(result.mip1_tint, from.mip1_tint, contribution);
44 lerp_color(result.mip2_tint, from.mip2_tint, contribution);
45 lerp_color(result.mip3_tint, from.mip3_tint, contribution);
46 lerp_color(result.mip4_tint, from.mip4_tint, contribution);
47 lerp_color(result.mip5_tint, from.mip5_tint, contribution);
48
49 result.dirt_intensity = std::lerp(result.dirt_intensity, from.dirt_intensity, contribution);
50 }
51};
52
53} // namespace unravel
static void merge_into(bloom_pass::settings &result, const bloom_pass::settings &from, float contribution, bool is_first)
Merges this component's settings into result. For first contribution, copies; otherwise lerps.
vec4 value
Definition color.h:80
CRTP (Curiously Recurring Template Pattern) base structure for components.
float contribution