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
|
// on SDR though... 100 may be a better fit for most content
|
||||||
// to match typical sRGB mastering.
|
// to match typical sRGB mastering.
|
||||||
const float c_scRGBLightScale = 80.0f;
|
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)
|
// nits -> linear (nits / scale)
|
||||||
vec3 nitsToLinear(vec3 nits) {
|
vec3 nitsToLinear(vec3 nits) {
|
||||||
|
|
|
@ -46,41 +46,47 @@ vec4 sampleLayer(sampler2D layerSampler, uint layerIdx, vec2 uv, bool unnormaliz
|
||||||
if (get_layer_colorspace(layerIdx) == colorspace_pq) {
|
if (get_layer_colorspace(layerIdx) == colorspace_pq) {
|
||||||
color.rgb = pqToNits(color.rgb);
|
color.rgb = pqToNits(color.rgb);
|
||||||
|
|
||||||
if (checkDebugFlag(compositedebug_Heatmap))
|
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||||
color.rgb = hdr_heatmap(color.rgb, true, true, true);
|
color.rgb = hdr_heatmap(color.rgb, true, true, c_st2084Output);
|
||||||
|
} else {
|
||||||
if (!c_st2084Output) {
|
if (!c_st2084Output) {
|
||||||
color.rgb = convert_primaries(color.rgb, rec2020_to_xyz, xyz_to_rec709);
|
// HDR10 ST2048 is rec2020.
|
||||||
color.rgb = nitsToLinear(color.rgb);
|
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) {
|
} else if (get_layer_colorspace(layerIdx) == colorspace_scRGB) {
|
||||||
if (checkDebugFlag(compositedebug_Heatmap))
|
color.rgb = scrgbToNits(color.rgb);
|
||||||
color.rgb = hdr_heatmap(color.rgb * c_scRGBLightScale, false, true, true);
|
|
||||||
|
|
||||||
if (c_st2084Output) {
|
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||||
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
color.rgb = hdr_heatmap(color.rgb, false, true, c_st2084Output);
|
||||||
} else {
|
} else {
|
||||||
color.rgb = nitsToLinear(color.rgb);
|
if (!c_st2084Output) {
|
||||||
|
// scRGB is rec709.
|
||||||
|
color.rgb = nitsToLinear(color.rgb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (get_layer_colorspace(layerIdx) == colorspace_sRGB) {
|
} else if (get_layer_colorspace(layerIdx) == colorspace_sRGB) {
|
||||||
color.rgb = srgbToLinear(color.rgb);
|
color.rgb = srgbToLinear(color.rgb);
|
||||||
|
|
||||||
if (checkDebugFlag(compositedebug_Heatmap))
|
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||||
color.rgb = hdr_heatmap(color.rgb, false, false, false);
|
color.rgb = hdr_heatmap(color.rgb, false, false, c_st2084Output);
|
||||||
|
} else {
|
||||||
if (c_st2084Output) {
|
if (c_st2084Output) {
|
||||||
color.rgb = linearToNits(color.rgb);
|
color.rgb = linearToNits(color.rgb);
|
||||||
if (!c_forceWideGammut)
|
if (!c_forceWideGammut)
|
||||||
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (get_layer_colorspace(layerIdx) == colorspace_linear) {
|
} else if (get_layer_colorspace(layerIdx) == colorspace_linear) {
|
||||||
if (checkDebugFlag(compositedebug_Heatmap))
|
if (checkDebugFlag(compositedebug_Heatmap)) {
|
||||||
color.rgb = hdr_heatmap(color.rgb, false, false, false);
|
color.rgb = hdr_heatmap(color.rgb, false, false, c_st2084Output);
|
||||||
|
} else {
|
||||||
if (c_st2084Output) {
|
if (c_st2084Output) {
|
||||||
color.rgb = linearToNits(color.rgb);
|
color.rgb = linearToNits(color.rgb);
|
||||||
if (!c_forceWideGammut)
|
if (!c_forceWideGammut)
|
||||||
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
color.rgb = convert_primaries(color.rgb, rec709_to_xyz, xyz_to_rec2020);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
|
|
Loading…
Reference in a new issue