#line 1 "unknown"

#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\FilmGrain.fx"
#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShadeUI.fxh"
#line 8 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\FilmGrain.fx"
#line 10
uniform float Intensity <      ui_type = "slider"; 
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "How visible the grain is. Higher is more visible.";
> = 0.50;
uniform float Variance <      ui_type = "slider"; 
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "Controls the variance of the Gaussian noise. Lower values look smoother.";
> = 0.40;
uniform float Mean <      ui_type = "slider"; 
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "Affects the brightness of the noise.";
> = 0.5;
#line 23
uniform int SignalToNoiseRatio <        ui_type = "slider"; 
ui_min = 0; ui_max = 16;
ui_label = "Signal-to-Noise Ratio";
ui_tooltip = "Higher Signal-to-Noise Ratio values give less grain to brighter pixels. 0 disables this feature.";
> = 6;
#line 29
uniform float Timer < source = "timer"; >;
#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShade.fxh"
#line 50
namespace ReShade
{
#line 61
static const float AspectRatio = 2274 * (1.0 / 1357);
static const float2 PixelSize = float2((1.0 / 2274), (1.0 / 1357));
static const float2 ScreenSize = float2(2274, 1357);
#line 67
texture BackBufferTex : COLOR;
texture DepthBufferTex : DEPTH;
#line 70
sampler BackBuffer { Texture = BackBufferTex; };
sampler DepthBuffer { Texture = DepthBufferTex; };
#line 74
float GetLinearizedDepth(float2 texcoord)
{
#line 79
texcoord.x /=  1;
texcoord.y /=  1;
#line 84
texcoord.x -=  0 / 2.000000001;
#line 89
texcoord.y +=  0 / 2.000000001;
#line 91
float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x *  1;
#line 100
const float N = 1.0;
depth /= 1000.0 - depth * (1000.0 - N);
#line 103
return depth;
}
}
#line 108
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
#line 31 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\FilmGrain.fx"
#line 33
float3 FilmGrainPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
#line 38
float inv_luma = dot(color, float3(-1.0/3.0, -1.0/3.0, -1.0/3.0)) + 1.0; 
#line 44
const float PI = 3.1415927;
#line 47
float t = Timer * 0.0022337;
#line 50
float seed = dot(texcoord, float2(12.9898, 78.233));
float sine = sin(seed);
float cosine = cos(seed);
float uniform_noise1 = frac(sine * 43758.5453 + t); 
float uniform_noise2 = frac(cosine * 53758.5453 - t); 
#line 57
float stn = SignalToNoiseRatio != 0 ? pow(abs(inv_luma), (float)SignalToNoiseRatio) : 1.0; 
float variance = (Variance*Variance) * stn;
float mean = Mean;
#line 62
uniform_noise1 = (uniform_noise1 < 0.0001) ? 0.0001 : uniform_noise1; 
#line 64
float r = sqrt(-log(uniform_noise1));
r = (uniform_noise1 < 0.0001) ? PI : r; 
float theta = (2.0 * PI) * uniform_noise2;
#line 68
float gauss_noise1 = variance * r * cos(theta) + mean;
#line 76
float grain = lerp(1.0 + Intensity,  1.0 - Intensity, gauss_noise1);
#line 81
color = color * grain;
#line 94
return color.rgb;
}
#line 97
technique FilmGrain
{
pass
{
VertexShader = PostProcessVS;
PixelShader = FilmGrainPass;
}
}

