shaders: Fix output scaling of heatmap
This commit is contained in:
parent
5b805dda00
commit
ba467640a8
2 changed files with 38 additions and 25 deletions
|
@ -66,6 +66,13 @@ vec3 pqToNits(vec3 pq) {
|
|||
// on SDR though... 100 may be a better fit for most content
|
||||
// to match typical sRGB mastering.
|
||||
const float c_scRGBLightScale = 80.0f;
|
||||
vec3 scrgbToNits(vec3 scRGB) {
|
||||
return scRGB * c_scRGBLightScale;
|
||||
}
|
||||
|
||||
vec3 nitsToScRGB(vec3 nits) {
|
||||
return nits / c_scRGBLightScale;
|
||||
}
|
||||
|
||||
// nits -> linear (nits / scale)
|
||||
vec3 nitsToLinear(vec3 nits) {
|
||||
|
|
|
@ -46,43 +46,49 @@ vec4 sampleLayer(sampler2D layerSampler, uint layerIdx, vec2 uv, bool unnormaliz
|
|||
if (get_layer_colorspace(layerIdx) == colorspace_pq) {
|
||||
color.rgb = pqToNits(color.rgb);
|
||||
|
||||
if (checkDebugFlag(compositedebug_Heatmap))
|
||||
color.rgb = hdr_heatmap(color.rgb, true, true, true);
|
||||
|
||||
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||
color.rgb = hdr_heatmap(color.rgb, true, true, c_st2084Output);
|
||||
} else {
|
||||
if (!c_st2084Output) {
|
||||
// HDR10 ST2048 is rec2020.
|
||||
color.rgb = convert_primaries(color.rgb, rec2020_to_xyz, xyz_to_rec709);
|
||||
color.rgb = nitsToLinear(color.rgb);
|
||||
}
|
||||
}
|
||||
} else if (get_layer_colorspace(layerIdx) == colorspace_scRGB) {
|
||||
if (checkDebugFlag(compositedebug_Heatmap))
|
||||
color.rgb = hdr_heatmap(color.rgb * c_scRGBLightScale, false, true, true);
|
||||
color.rgb = scrgbToNits(color.rgb);
|
||||
|
||||
if (c_st2084Output) {
|
||||
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
||||
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||
color.rgb = hdr_heatmap(color.rgb, false, true, c_st2084Output);
|
||||
} else {
|
||||
if (!c_st2084Output) {
|
||||
// scRGB is rec709.
|
||||
color.rgb = nitsToLinear(color.rgb);
|
||||
}
|
||||
}
|
||||
} else if (get_layer_colorspace(layerIdx) == colorspace_sRGB) {
|
||||
color.rgb = srgbToLinear(color.rgb);
|
||||
|
||||
if (checkDebugFlag(compositedebug_Heatmap))
|
||||
color.rgb = hdr_heatmap(color.rgb, false, false, false);
|
||||
|
||||
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||
color.rgb = hdr_heatmap(color.rgb, false, false, c_st2084Output);
|
||||
} else {
|
||||
if (c_st2084Output) {
|
||||
color.rgb = linearToNits(color.rgb);
|
||||
if (!c_forceWideGammut)
|
||||
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
||||
}
|
||||
}
|
||||
} else if (get_layer_colorspace(layerIdx) == colorspace_linear) {
|
||||
if (checkDebugFlag(compositedebug_Heatmap))
|
||||
color.rgb = hdr_heatmap(color.rgb, false, false, false);
|
||||
|
||||
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||
color.rgb = hdr_heatmap(color.rgb, false, false, c_st2084Output);
|
||||
} else {
|
||||
if (c_st2084Output) {
|
||||
color.rgb = linearToNits(color.rgb);
|
||||
if (!c_forceWideGammut)
|
||||
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
||||
}
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue