This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
/
PrepareSwapChainBuffersPS.hlsl
47 lines (37 loc) · 1.76 KB
/
PrepareSwapChainBuffersPS.hlsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//--------------------------------------------------------------------------------------
// PrepareSwapChainBuffersPS.hlsl
//
// Takes the final HDR back buffer with linear values using Rec.709 color primaries and
// outputs two signals, an HDR and SDR signal. The HDR siganl uses Rec.2020 color primaries
// with the ST.2084 curve, whereas the SDR signal uses Rec.709 color primaries which the
// hardware will apply the Rec.709 gamma curve.
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#include "HDRCommon.hlsli"
#include "FullScreenQuad.hlsli"
float4 PaperWhiteNits : register(b0); // Defines how bright white is (in nits), which controls how bright the SDR range in the image will be, e.g. 200 nits
// Very simple HDR to SDR tonemapping, which simply clips values above 1.0f from the HDR scene.
float4 TonemapHDR2SDR(float4 hdrSceneValue)
{
return saturate(hdrSceneValue);
}
struct PSOut
{
float4 HDR10 : SV_Target0; // HDR10 buffer using Rec.2020 color primaries with ST.2084 curve
float4 GameDVR : SV_Target1; // GameDVR buffer using Rec.709 color primaries with sRGB gamma curve
};
// Prepare the HDR swapchain buffer as HDR10. This means the buffer has to contain data which uses
// - Rec.2020 color primaries
// - Quantized using ST.2084 curve
// - 10-bit per channel
PSOut main(Interpolators In)
{
PSOut output;
// Input is linear values using sRGB / Rec.709 color primaries
float4 hdrSceneValues = Texture.Sample(PointSampler, In.TexCoord);
output.HDR10 = ConvertToHDR10(hdrSceneValues, PaperWhiteNits.x);
output.GameDVR = TonemapHDR2SDR(hdrSceneValues);
return output;
}