video_out: HDR support (#2381)

* Initial HDR support

* fix for crashes when debug tools used
This commit is contained in:
psucien 2025-02-09 15:54:54 +01:00 committed by GitHub
parent fb0871dbc8
commit 8f2883a388
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 186 additions and 16 deletions

View file

@ -10,16 +10,23 @@ layout (binding = 0) uniform sampler2D texSampler;
layout(push_constant) uniform settings {
float gamma;
bool hdr;
} pp;
const float cutoff = 0.0031308, a = 1.055, b = 0.055, d = 12.92;
vec3 gamma(vec3 rgb)
{
return mix(a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b, d * rgb / pp.gamma, lessThan(rgb, vec3(cutoff)));
vec3 gamma(vec3 rgb) {
return mix(
a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b,
d * rgb / pp.gamma,
lessThan(rgb, vec3(cutoff))
);
}
void main()
{
void main() {
vec4 color_linear = texture(texSampler, uv);
color = vec4(gamma(color_linear.rgb), color_linear.a);
if (pp.hdr) {
color = color_linear;
} else {
color = vec4(gamma(color_linear.rgb), color_linear.a);
}
}