Unravel Engine C++ Reference
Loading...
Searching...
No Matches
ssr_component.h
Go to the documentation of this file.
1#pragma once
2
3#include <base/basetypes.hpp>
6
7namespace unravel
8{
9
10class ssr_component : public component_crtp<ssr_component>
11{
12public:
14 bool enabled = true;
15
18
21 const ssr_pass::ssr_settings& from,
22 float contribution,
23 bool is_first)
24 {
25 if(is_first)
26 {
27 result = from;
28 return;
29 }
30
31 auto& r = result.fidelityfx;
32 const auto& f = from.fidelityfx;
33
34 r.max_steps = int(std::lerp(float(r.max_steps), float(f.max_steps), contribution));
35 r.max_rays = int(std::lerp(float(r.max_rays), float(f.max_rays), contribution));
36 r.depth_tolerance = std::lerp(r.depth_tolerance, f.depth_tolerance, contribution);
37 r.brightness = std::lerp(r.brightness, f.brightness, contribution);
38 r.facing_reflections_fading = std::lerp(r.facing_reflections_fading, f.facing_reflections_fading, contribution);
39 r.roughness_depth_tolerance = std::lerp(r.roughness_depth_tolerance, f.roughness_depth_tolerance, contribution);
40 r.fade_in_start = std::lerp(r.fade_in_start, f.fade_in_start, contribution);
41 r.fade_in_end = std::lerp(r.fade_in_end, f.fade_in_end, contribution);
42 r.resolution = contribution >= 0.5f ? f.resolution : r.resolution;
43
44 r.enable_cone_tracing = contribution >= 0.5f ? f.enable_cone_tracing : r.enable_cone_tracing;
45 r.cone_tracing.cone_angle_bias = std::lerp(r.cone_tracing.cone_angle_bias, f.cone_tracing.cone_angle_bias, contribution);
46 r.cone_tracing.max_mip_level = contribution >= 0.5f ? f.cone_tracing.max_mip_level : r.cone_tracing.max_mip_level;
47 r.cone_tracing.blur_base_sigma = std::lerp(r.cone_tracing.blur_base_sigma, f.cone_tracing.blur_base_sigma, contribution);
48 r.cone_tracing.roughness_multiplier = std::lerp(r.cone_tracing.roughness_multiplier, f.cone_tracing.roughness_multiplier, contribution);
49
50 r.enable_temporal_accumulation = contribution >= 0.5f ? f.enable_temporal_accumulation : r.enable_temporal_accumulation;
51 r.temporal.history_strength = std::lerp(r.temporal.history_strength, f.temporal.history_strength, contribution);
52 r.temporal.depth_threshold = std::lerp(r.temporal.depth_threshold, f.temporal.depth_threshold, contribution);
53 r.temporal.roughness_sensitivity = std::lerp(r.temporal.roughness_sensitivity, f.temporal.roughness_sensitivity, contribution);
54 r.temporal.motion_scale_pixels = std::lerp(r.temporal.motion_scale_pixels, f.temporal.motion_scale_pixels, contribution);
55 r.temporal.normal_dot_threshold = std::lerp(r.temporal.normal_dot_threshold, f.temporal.normal_dot_threshold, contribution);
56 r.temporal.motion_scale_pixels = std::lerp(r.temporal.motion_scale_pixels, f.temporal.motion_scale_pixels, contribution);
57 r.temporal.normal_dot_threshold = std::lerp(r.temporal.normal_dot_threshold, f.temporal.normal_dot_threshold, contribution);
58 r.temporal.max_accum_frames = contribution >= 0.5f ? f.temporal.max_accum_frames : r.temporal.max_accum_frames;
59
60 r.enable_spatial_denoise = contribution >= 0.5f ? f.enable_spatial_denoise : r.enable_spatial_denoise;
61 r.spatial_denoise.depth_sigma = std::lerp(r.spatial_denoise.depth_sigma, f.spatial_denoise.depth_sigma, contribution);
62 r.spatial_denoise.normal_power = std::lerp(r.spatial_denoise.normal_power, f.spatial_denoise.normal_power, contribution);
63 r.spatial_denoise.luma_sigma = std::lerp(r.spatial_denoise.luma_sigma, f.spatial_denoise.luma_sigma, contribution);
64 }
65};
66
67} // namespace unravel
static void merge_into(ssr_pass::ssr_settings &result, const ssr_pass::ssr_settings &from, float contribution, bool is_first)
Merges this component's settings into result. For first contribution, copies; otherwise lerps.
bool enabled
Whether SSR is enabled.
CRTP (Curiously Recurring Template Pattern) base structure for components.
Combined SSR settings.
Definition ssr_pass.h:77
fidelityfx_ssr_settings fidelityfx
FidelityFX SSR settings.
Definition ssr_pass.h:78
float contribution