forked from dexyfex/CodeWalker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPPFinalPassPS.hlsl
More file actions
41 lines (29 loc) · 935 Bytes
/
PPFinalPassPS.hlsl
File metadata and controls
41 lines (29 loc) · 935 Bytes
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
struct VS_Output
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
Texture2D<float4> tex : register( t0 );
StructuredBuffer<float> lum : register( t1 );
Texture2D<float4> bloom : register( t2 );
SamplerState PointSampler : register (s0);
SamplerState LinearSampler : register (s1);
static const float MIDDLE_GRAY = 0.72f;
static const float LUM_WHITE = 1.5f;
cbuffer cbPS : register( b0 )
{
float4 g_param;
};
float4 main(VS_Output input) : SV_TARGET
{
float4 vColor = tex.Sample(PointSampler, input.Tex);
float fLum = min(max(lum[0]*g_param.x, 0.2), 10); //limit amplification...
float3 vBloom = bloom.Sample(LinearSampler, input.Tex).rgb;
// Tone mapping
vColor.rgb *= MIDDLE_GRAY / (fLum + 0.001f);
vColor.rgb *= (1.0f + vColor.rgb/LUM_WHITE);
vColor.rgb /= (1.0f + vColor.rgb);
vColor.rgb += 0.6f * vBloom;
vColor.a = 1.0f;
return vColor;
}