Orrery
A GPU-accelerated N-body gravitational simulator
Toggle main menu visibility
Loading...
Searching...
No Matches
tone_map.hpp
Go to the documentation of this file.
1
#pragma once
2
48
49
#include <array>
50
#include <cstdint>
51
#include <string_view>
52
53
namespace
orrery::viz {
54
56
struct
ToneMapping
{
64
float
exposure
= 1;
65
71
float
white_point
= 4;
72
};
73
79
[[nodiscard]]
float
tone_curve
(
float
radiance,
ToneMapping
mapping)
noexcept
;
80
89
[[nodiscard]] std::uint8_t
encode_srgb
(
float
linear)
noexcept
;
90
92
[[nodiscard]] std::array<std::uint8_t, 3>
to_display
(
float
red,
float
green,
float
blue,
93
ToneMapping
mapping)
noexcept
;
94
101
[[nodiscard]]
constexpr
std::string_view
tone_curve_glsl
() noexcept {
102
return
R
"(vec3 orrery_tone_curve(vec3 radiance, float exposure, float white_point) {
103
vec3 exposed = max(radiance * exposure, vec3(0.0));
104
vec3 mapped = exposed * (1.0 + exposed / (white_point * white_point)) / (1.0 + exposed);
105
return clamp(mapped, 0.0, 1.0);
106
}
107
)";
108
}
109
110
}
// namespace orrery::viz
orrery::viz::ToneMapping
The two numbers that decide how bright the picture is.
Definition
tone_map.hpp:56
orrery::viz::ToneMapping::exposure
float exposure
What the accumulated radiance is multiplied by before the curve.
Definition
tone_map.hpp:64
orrery::viz::ToneMapping::white_point
float white_point
The exposed radiance that maps exactly to white.
Definition
tone_map.hpp:71
orrery::viz::tone_curve
float tone_curve(float radiance, ToneMapping mapping) noexcept
One channel through the curve, clamped to [0, 1].
orrery::viz::to_display
std::array< std::uint8_t, 3 > to_display(float red, float green, float blue, ToneMapping mapping) noexcept
A linear radiance triple through the curve and the encoding, ready to store.
orrery::viz::encode_srgb
std::uint8_t encode_srgb(float linear) noexcept
The sRGB transfer function, from a linear value in [0, 1] to a byte.
orrery::viz::tone_curve_glsl
constexpr std::string_view tone_curve_glsl() noexcept
The same curve as GLSL, for the shader that applies it on the device.
Definition
tone_map.hpp:101
orrery
viz
tone_map.hpp
Generated by
1.17.0