1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
4pub struct SmoothstepThreshold {
5 pub low: f32,
6 pub high: f32,
7}
8
9impl SmoothstepThreshold {
10 pub const fn new(low: f32, high: f32) -> Self {
11 Self { low, high }
12 }
13}
14
15#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
16pub struct AlphaRange {
17 pub min: f32,
18 pub max: f32,
19}
20
21impl AlphaRange {
22 pub const fn new(min: f32, max: f32) -> Self {
23 Self { min, max }
24 }
25}
26
27#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
28pub struct BaselineParameters {
29 pub fixed_alpha: f32,
30 pub residual_alpha_range: AlphaRange,
31 pub residual_threshold: SmoothstepThreshold,
32 pub clamp_distance: SmoothstepThreshold,
33 pub depth_disagreement: SmoothstepThreshold,
34 pub normal_disagreement: SmoothstepThreshold,
35 pub neighborhood_distance: SmoothstepThreshold,
36}
37
38#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
39pub struct HazardWeights {
40 pub residual: f32,
41 pub visibility: f32,
42 pub depth: f32,
43 pub normal: f32,
44 pub motion: f32,
45 pub neighborhood: f32,
46 pub thin: f32,
47 pub history_instability: f32,
48 pub grammar: f32,
49}
50
51#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
52pub struct HostProxyThresholds {
53 pub residual: SmoothstepThreshold,
54 pub depth: SmoothstepThreshold,
55 pub normal: SmoothstepThreshold,
56 pub motion: SmoothstepThreshold,
57 pub neighborhood: SmoothstepThreshold,
58 pub local_contrast: SmoothstepThreshold,
59 pub hazard_curve: SmoothstepThreshold,
60 pub thin_hint_mix: f32,
61 pub thin_local_contrast_mix: f32,
62 pub history_instability_residual_mix: f32,
63 pub history_instability_neighborhood_mix: f32,
64}
65
66#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
67pub struct StructuralThresholds {
68 pub disocclusion_like: f32,
69 pub unstable_residual: f32,
70 pub unstable_neighborhood: f32,
71 pub motion_edge: f32,
72 pub thin_edge: f32,
73 pub thin_residual: f32,
74}
75
76#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
77pub enum HazardMergeMode {
78 MaxGate,
79 WeightedAdd,
80}
81
82#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
83pub enum TrustBehavior {
84 GateLike,
85 Graded,
86}
87
88#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
89pub struct HostSupervisionParameters {
90 pub alpha_range: AlphaRange,
91 pub weights: HazardWeights,
92 pub thresholds: HostProxyThresholds,
93 pub structural: StructuralThresholds,
94 pub hazard_merge_mode: HazardMergeMode,
95 pub trust_behavior: TrustBehavior,
96}
97
98pub fn baseline_parameters() -> BaselineParameters {
99 BaselineParameters {
100 fixed_alpha: 0.12,
101 residual_alpha_range: AlphaRange::new(0.12, 0.72),
102 residual_threshold: SmoothstepThreshold::new(0.08, 0.18),
103 clamp_distance: SmoothstepThreshold::new(0.008, 0.10),
104 depth_disagreement: SmoothstepThreshold::new(0.01, 0.08),
105 normal_disagreement: SmoothstepThreshold::new(0.01, 0.16),
106 neighborhood_distance: SmoothstepThreshold::new(0.01, 0.14),
107 }
108}
109
110pub fn host_realistic_parameters() -> HostSupervisionParameters {
111 HostSupervisionParameters {
112 alpha_range: AlphaRange::new(0.08, 0.96),
113 weights: HazardWeights {
114 residual: 0.24,
115 visibility: 0.0,
116 depth: 0.16,
117 normal: 0.11,
118 motion: 0.0,
119 neighborhood: 0.16,
120 thin: 0.09,
121 history_instability: 0.12,
122 grammar: 0.18,
123 },
124 thresholds: HostProxyThresholds {
125 residual: SmoothstepThreshold::new(0.015, 0.22),
126 depth: SmoothstepThreshold::new(0.01, 0.08),
127 normal: SmoothstepThreshold::new(0.01, 0.16),
128 motion: SmoothstepThreshold::new(0.35, 1.90),
129 neighborhood: SmoothstepThreshold::new(0.01, 0.14),
130 local_contrast: SmoothstepThreshold::new(0.02, 0.18),
131 hazard_curve: SmoothstepThreshold::new(0.03, 0.86),
132 thin_hint_mix: 0.45,
133 thin_local_contrast_mix: 0.55,
134 history_instability_residual_mix: 0.58,
135 history_instability_neighborhood_mix: 0.42,
136 },
137 structural: StructuralThresholds {
138 disocclusion_like: 0.68,
139 unstable_residual: 0.34,
140 unstable_neighborhood: 0.20,
141 motion_edge: 0.34,
142 thin_edge: 0.34,
143 thin_residual: 0.14,
144 },
145 hazard_merge_mode: HazardMergeMode::WeightedAdd,
146 trust_behavior: TrustBehavior::Graded,
147 }
148}
149
150pub fn motion_augmented_parameters() -> HostSupervisionParameters {
151 let mut parameters = host_realistic_parameters();
152 parameters.weights.motion = 0.14;
153 parameters.structural.motion_edge = 0.28;
154 parameters
155}
156
157pub fn gated_reference_parameters() -> HostSupervisionParameters {
158 HostSupervisionParameters {
159 alpha_range: AlphaRange::new(0.08, 0.96),
160 weights: HazardWeights {
161 residual: 0.26,
162 visibility: 0.0,
163 depth: 0.18,
164 normal: 0.12,
165 motion: 0.12,
166 neighborhood: 0.14,
167 thin: 0.08,
168 history_instability: 0.10,
169 grammar: 1.0,
170 },
171 thresholds: HostProxyThresholds {
172 residual: SmoothstepThreshold::new(0.015, 0.22),
173 depth: SmoothstepThreshold::new(0.01, 0.08),
174 normal: SmoothstepThreshold::new(0.01, 0.16),
175 motion: SmoothstepThreshold::new(0.5, 3.0),
176 neighborhood: SmoothstepThreshold::new(0.01, 0.14),
177 local_contrast: SmoothstepThreshold::new(0.02, 0.18),
178 hazard_curve: SmoothstepThreshold::new(0.0, 1.0),
179 thin_hint_mix: 0.45,
180 thin_local_contrast_mix: 0.55,
181 history_instability_residual_mix: 0.62,
182 history_instability_neighborhood_mix: 0.38,
183 },
184 structural: StructuralThresholds {
185 disocclusion_like: 0.72,
186 unstable_residual: 0.38,
187 unstable_neighborhood: 0.22,
188 motion_edge: 0.45,
189 thin_edge: 0.40,
190 thin_residual: 0.18,
191 },
192 hazard_merge_mode: HazardMergeMode::MaxGate,
193 trust_behavior: TrustBehavior::GateLike,
194 }
195}
196
197pub fn synthetic_visibility_parameters() -> HostSupervisionParameters {
198 let mut parameters = motion_augmented_parameters();
199 parameters.weights.visibility = 0.22;
200 parameters.weights.residual = 0.18;
201 parameters.weights.depth = 0.12;
202 parameters.weights.normal = 0.08;
203 parameters.weights.neighborhood = 0.10;
204 parameters.weights.thin = 0.08;
205 parameters.weights.history_instability = 0.08;
206 parameters.weights.grammar = 0.14;
207 parameters
208}