summaryrefslogtreecommitdiffstats
path: root/shaders_inc/UpdateAverageLuminance.fx.h
blob: 69efd1381b25dc63019c0fe7dedbb2c9d2435e3f (plain)
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
"#include \"AtmosphereShadersCommon.fxh\"\n"
"\n"
"#if LIGHT_ADAPTATION\n"
"cbuffer cbMiscDynamicParams\n"
"{\n"
"    MiscDynamicParams g_MiscParams;\n"
"}\n"
"#endif\n"
"\n"
"Texture2D<float2>  g_tex2DLowResLuminance;\n"
"\n"
"void UpdateAverageLuminancePS( FullScreenTriangleVSOutput VSOut, \n"
"                               // We must declare vertex shader output even though we \n"
"                               // do not use it, because otherwise the shader will not\n"
"                               // run on NVidia GLES\n"
"                               out float4 f4Luminance : SV_Target)\n"
"{\n"
"#if LIGHT_ADAPTATION\n"
"    const float fAdaptationRate = 1.0;\n"
"    float fNewLuminanceWeight = 1.0 - exp( - fAdaptationRate * g_MiscParams.fElapsedTime );\n"
"#else\n"
"    float fNewLuminanceWeight = 1.0;\n"
"#endif\n"
"    float2 LogLum_W = g_tex2DLowResLuminance.Load( int3(0,0,LOW_RES_LUMINANCE_MIPS-1) );\n"
"    float LogLum = LogLum_W.x / max(LogLum_W.y, 1e-6);\n"
"    fNewLuminanceWeight *= saturate(LogLum_W.y / 1e-3);\n"
"\n"
"    f4Luminance = float4( exp(LogLum), 0.0, 0.0, fNewLuminanceWeight );\n"
"}\n"