To get the same look with SDR and HDR
Last time, try to render the R10G10B10A2 format on an HDR display, For now, we have confirmed that the display is brighter than R8G8B8A8.
Now we would like to try to see how we can adjust it to bring the SDR and HDR looks closer together.
First, we will simply write PixelShader so that we can set the scaling in linear color.
struct PSInput {
float4 position : SV_POSITION;
float4 color : COLOR;
};
static const float3x3 Rec709ToRec2020Matrix = {
1.2249, -0.0420, -0.0197,
-0.0184, 1.2045, -0.0158,
-0.0051, -0.0249, 1.2796
};
// Conversion from sRGB to linear color
float3 SRGBToLinear(float3 color) {
return (color <= 0.04045) ? (color / 12.92) : pow((color + 0.055) / 1.055, 2.4);
}
// PQ Correction Function (ST 2084, Simplified)
float3 PQCorrect(float3 color) {
// PQ curve constants (Simplified version)
float m1 = 0.1593;
float m2 = 78.8438;
float c1 = 0.8359;
float c2 = 18.8516;
float c3 = 18.6875;
// PQ Curve Encoding Formula
return pow(max((c1 + c2 * pow(color, m1)) / (1.0 + c3 * pow(color, m1)), 0.0), m2);
}
float4 PSMain(PSInput input) : SV_TARGET {
// Scale
float scale = 0.01;
// Converts sRGB to linear
float3 linearColor = SRGBToLinear(input.color.rgb) * scale;
// Convert Linear Color to Rec. 2020
float3 rec2020Color = mul(Rec709ToRec2020Matrix, linearColor);
// PQ Curve Correction (Rec. 2020)
float3 finalColor = PQCorrect(rec2020Color);
return float4(finalColor, input.color.a);
}
Is the PQ curve correction like the gamma correction in SDR? In linear color space, when I applied SCALE, it matched roughly at 0.01x.
This is what I displayed as it is in R8G8B8A8.
Here is the one multiplied by a scale of 0.01 for linear color with R10G10B10A2.
Simply put, 100 times brighter?
Oh, by the way, in my last screenshot, the HDR was skipping colors, so this time I pressed theWindows+Gkey to capture it.
The PQ curve is not linear, but nonlinear to human vision, in order to handle a wide dynamic range (up to10,000 nits).
Since SDR is about 100 nits, is it correct that it can represent something 100 times brighter?
Note that originally, I would have used tone mapping to adjust the scale, but it was a bit confusing, so I decided to use a simple linear scale.
By the way, this display is HDR600, so it can express only 6 times brighter.
I am not sure if this is the correct result because I haven’t studied it enough yet. I will continue when I have a deeper understanding.