summaryrefslogtreecommitdiffstats
path: root/Shaders/PostProcess/EpipolarLightScattering/private/UpdateAverageLuminance.fx
blob: 411d4aafcd49a71edfb55283edbfba30375096b4 (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"

#if LIGHT_ADAPTATION
cbuffer cbMiscDynamicParams
{
    MiscDynamicParams g_MiscParams;
}
#endif

Texture2D<float2>  g_tex2DLowResLuminance;

void UpdateAverageLuminancePS( FullScreenTriangleVSOutput VSOut, 
                               // We must declare vertex shader output even though we 
                               // do not use it, because otherwise the shader will not
                               // run on NVidia GLES
                               out float4 f4Luminance : SV_Target)
{
#if LIGHT_ADAPTATION
    const float fAdaptationRate = 1.0;
    float fNewLuminanceWeight = 1.0 - exp( - fAdaptationRate * g_MiscParams.fElapsedTime );
#else
    float fNewLuminanceWeight = 1.0;
#endif
    float2 LogLum_W = g_tex2DLowResLuminance.Load( int3(0,0,LOW_RES_LUMINANCE_MIPS-1) );
    float LogLum = LogLum_W.x / max(LogLum_W.y, 1e-6);
    fNewLuminanceWeight *= saturate(LogLum_W.y / 1e-3);

    f4Luminance = float4( exp(LogLum), 0.0, 0.0, fNewLuminanceWeight );
}