Toast Engine
Loading...
Searching...
No Matches
shadow_slots.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <cstdint>
8#include <span>
9
10namespace renderer::shadow_slots {
11
13inline constexpr float k_default_retention = 1.5f;
14
16inline constexpr uint32_t k_default_grace_frames = 30;
17
19inline constexpr float k_distance_slack = 1.15f;
20
22inline constexpr float k_resolution_band = 0.1f;
23
24struct Candidate {
25 uint64_t key = 0;
26 float importance = 0.0f;
27 bool visible = false;
28};
29
30struct Slot {
31 uint64_t key = 0;
32 uint32_t hidden_frames = 0;
33 uint32_t resolution = 0;
34};
35
37auto assign(std::span<const Candidate> candidates, std::span<Slot> slots, std::span<int32_t> slot_of) -> uint32_t;
38
39[[nodiscard]]
40auto owns(std::span<const Slot> slots, uint64_t key) -> bool;
41
42[[nodiscard]]
43auto retention() -> float;
44
45[[nodiscard]]
46auto graceFrames() -> uint32_t;
47
48void setRetention(float factor);
49void setGraceFrames(uint32_t frames);
50
52[[nodiscard]]
53auto stableResolution(uint32_t current, float camera_distance, float resolution_scale) -> uint32_t;
54
55}
auto stableResolution(uint32_t current, float camera_distance, float resolution_scale) -> uint32_t
Keeps the current tier until the camera distance leaves its band.
Definition shadow_slots.cpp:129
auto assign(std::span< const Candidate > candidates, std::span< Slot > slots, std::span< int32_t > slot_of) -> uint32_t
slot_of is -1 for losers and the return counts owners displaced
Definition shadow_slots.cpp:25
constexpr float k_distance_slack
Owners keep casting this much past the light shadow distance.
Definition shadow_slots.hpp:19
constexpr float k_default_retention
An owner keeps its slot unless outranked by this factor.
Definition shadow_slots.hpp:13
constexpr uint32_t k_default_grace_frames
Frames an owner still counts as seen after it leaves the view.
Definition shadow_slots.hpp:16
constexpr float k_resolution_band
Relative camera distance band around a resolution tier switch.
Definition shadow_slots.hpp:22
Definition shadow_slots.hpp:24
Definition shadow_slots.hpp:30