//Decals
cbuffer viewConstants : register(b2)
{
  float1 time : packoffset(c0);
  float3 vc_pad0_ : packoffset(c0.y);
  float4 screenSize : packoffset(c1);
  float3 debugNonFiniteColor : packoffset(c2);
  float1 vc_pad2_ : packoffset(c2.w);
  float4x4 viewMatrix : packoffset(c3);
  float4x4 projMatrix : packoffset(c7);
  float4x4 viewProjMatrix : packoffset(c11);
  float4x4 crViewProjMatrix : packoffset(c15);
  float4 projectionKxKyKzKw : packoffset(c19);
  float3 cameraPos : packoffset(c20);
  float1 vc_pad8_ : packoffset(c20.w);
  float3 transparentStartAndSlopeAndClamp : packoffset(c21);
  float1 vc_pad9_ : packoffset(c21.w);
  float4 transparentCurve : packoffset(c22);
  float4 exposureMultipliers : packoffset(c23);
  float4 fogParams : packoffset(c24);
  float4 fogForwardScatteringParamsGradientScaleFogEnable : packoffset(c25);
  float4 fogForwardScatteringColorPresence : packoffset(c26);
  float4 fogCoefficients : packoffset(c27);
  float4 fogColorCoefficients : packoffset(c28);
  float4 fogColor : packoffset(c29);
  float4 fogStartDistance : packoffset(c30);
  float4 fogHeightFogCoefficients : packoffset(c31);
  float4 fogMiscParam : packoffset(c32);
  float2 fogEnabledMode : packoffset(c33);
  float2 vc_pad10_ : packoffset(c33.z);
}

cbuffer externalConstants : register(b1)
{
  float3 external_PerAxisAlpha_XYZ : packoffset(c0);
  float1 vc_pad0 : packoffset(c0.w);
  float4 external_viewMatrix1 : packoffset(c1);
  float4 external_viewMatrix2 : packoffset(c2);
  float4 external_viewMatrix3 : packoffset(c3);
  float4 external_viewMatrix4 : packoffset(c4);
  float3 external_Mask_RGB_Switch : packoffset(c5);
  float1 vc_pad5 : packoffset(c5.w);
  float4 external_UVDistortPower_Speed_Tile : packoffset(c6);
  float external_g_emitterTime : packoffset(c7);
  float3 vc_pad7 : packoffset(c7.y);
  float3 external_Diff_01_RGB_Switch : packoffset(c8);
  float1 vc_pad8 : packoffset(c8.w);
  float4 external_ADepthTB_AAngle : packoffset(c9);
}
SamplerState sampler0_s : register(s0);
SamplerState sampler1_s : register(s1);
SamplerState sampler2_s : register(s2);
Texture2D<float4> texture_depthBufferTexture : register(t1);
Texture2D<float4> texture_normalBufferTexture : register(t2);
Texture2D<float4> texture_Mask : register(t3);
Texture2D<float4> texture_Diff_01 : register(t4);
Texture2D<float4> texture_DistortionClouds : register(t5);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  float4 v2 : TEXCOORD1,
  float4 v3 : TEXCOORD2,
  float4 v4 : TEXCOORD3,
  float4 v5 : TEXCOORD4,
  float4 v6 : TEXCOORD5,
  float4 v7 : TEXCOORD6,
  float4 v8 : TEXCOORD7,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6;
  uint4 bitmask;
  r0.xyz = external_viewMatrix2.xyz * v8.yyy;
  r0.xyz = external_viewMatrix1.xyz * v8.xxx + r0.xyz;
  r0.xyz = external_viewMatrix3.xyz * v8.zzz + r0.xyz;
  r0.xyz = external_viewMatrix4.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r0.xyz = r0.xyz / -r0.zzz;
  r1.xy = screenSize.zw * v0.xy;
  r0.w = texture_depthBufferTexture.Sample(sampler0_s, r1.xy).x;
  r1.xyz = texture_normalBufferTexture.Sample(sampler0_s, r1.xy).xyz;
  r1.xyz = r1.xyz * float3(2.000000e+000,2.000000e+000,2.000000e+000) + float3(-1.000000e+000,-1.000000e+000,-1.000000e+000);
  
float4 r26;
r26.xyz = r0.xyz * r0.www;
r26.w = 1.0;

float4 stereo = StereoParams.Load(0);
r26.x -= stereo.x * (-r26.z - stereo.y)/projMatrix._m00; 

  r0.xyz = r26.xyz + -external_viewMatrix4.xyz; // r0.xyz = r0.xyz * r0.www + -external_viewMatrix4.xyz;
 
  r2.x = dot(external_viewMatrix1.xyz, r0.xyz);
  r2.y = dot(external_viewMatrix2.xyz, r0.xyz);
  r2.z = dot(external_viewMatrix3.xyz, r0.xyz);
  r2.w = 1.000000000e+000;
  r0.z = dot(r2.xyzw, v1.xyzw);
  r0.y = dot(r2.xyzw, v2.xyzw);
  r0.x = dot(r2.xyzw, v3.xyzw);
  r0.w = dot(r2.xyzw, v4.xyzw);
  r0.xyz = r0.xyz / r0.www;
  r2.xyz = float3(5.000000e-001,5.000000e-001,5.000000e-001) + -abs(-r0.zyx);
  r2.xyz = r2.xyz < float3(0.000000e+000,0.000000e+000,0.000000e+000);
  r0.w = (int)r2.y | (int)r2.x;
  r0.w = (int)r2.z | (int)r0.w;
  if (r0.w != 0) discard;
  r2.xyz = max(abs(r0.yxy), abs(r0.zzx));
  r2.xyz = float3(1.000000e+000,1.000000e+000,1.000000e+000) / r2.xyz;
  r3.xyz = min(abs(r0.yxy), abs(r0.zzx));
  r2.xyz = r3.xyz * r2.xyz;
  r3.xyz = r2.xyz * r2.xyz;
  r4.xyz = r3.xyz * float3(2.083510e-002,2.083510e-002,2.083510e-002) + float3(-8.513300e-002,-8.513300e-002,-8.513300e-002);
  r4.xyz = r3.xyz * r4.xyz + float3(1.801410e-001,1.801410e-001,1.801410e-001);
  r4.xyz = r3.xyz * r4.xyz + float3(-3.302995e-001,-3.302995e-001,-3.302995e-001);
  r3.xyz = r3.xyz * r4.xyz + float3(9.998660e-001,9.998660e-001,9.998660e-001);
  r4.xyz = r3.xyz * r2.xyz;
  r4.xyz = r4.xyz * float3(-2.000000e+000,-2.000000e+000,-2.000000e+000) + float3(1.570796e+000,1.570796e+000,1.570796e+000);
  r5.xyz = abs(r0.yxy) < abs(r0.zzx);
  r4.xyz = r5.xyz ? r4.xyz : 0;
  r2.xyz = r2.xyz * r3.xyz + r4.xyz;
  r3.xyz = r0.yxy < -r0.yxy;
  r3.xyz = r3.xyz ? float3(-3.141593e+000,-3.141593e+000,-3.141593e+000) : 0;
  r2.xyz = r3.xyz + r2.xyz;
  r3.xyz = min(r0.yxy, r0.zzx);
  r3.xyz = r3.xyz < -r3.xyz;
  r4.xyz = max(r0.yxy, r0.zzx);
  r4.xyz = r4.xyz >= -r4.xyz;
  r3.xyz = r3.xyz ? r4.xyz : 0;
  r2.xyz = r3.xyz ? -r2.xyz : r2.xyz;
  r2.yzw = external_UVDistortPower_Speed_Tile.www * r2.yxz;
  r0.w = dot(r0.yz, r0.yz);
  r0.w = sqrt(r0.w);
  r2.x = external_g_emitterTime * external_UVDistortPower_Speed_Tile.y + r0.w;
  r3.x = external_UVDistortPower_Speed_Tile.z;
  r3.y = 1.591549516e-001;
  r3.zw = r2.xz * r3.xy + v5.xy;
  r4.xyz = texture_DistortionClouds.Sample(sampler2_s, r3.zw).xyw;
  r4.x = r4.x * r4.z;
  r3.zw = r4.xy * float2(2.000000e+000,2.000000e+000) + float2(-1.000000e+000,-1.000000e+000);
  r3.zw = r3.zw * r0.ww;
  r4.xyz = float3(5.000000e-001,5.000000e-001,5.000000e-001) + r0.xyz;
  r3.zw = r3.zw * external_UVDistortPower_Speed_Tile.xx + r4.zy;
  r5.xyz = texture_Diff_01.Sample(sampler1_s, r3.zw).xyz;
  r0.w = saturate(dot(r5.xyz, external_Diff_01_RGB_Switch.xyz));
  r0.w = r0.w * v6.w + -v6.z;
  r0.w = log2(r0.w);
  r0.w = v6.y * r0.w;
  r0.w = exp2(r0.w);
  r0.w = v6.x * r0.w;
  r5.xyz = texture_Mask.Sample(sampler1_s, r4.zy).xyz;
  r1.w = saturate(dot(r5.xyz, external_Mask_RGB_Switch.xyz));
  r0.w = r1.w * r0.w;
  r5.xyz = float3(1.000000e+000,1.000000e+000,1.000000e+000) + -r4.xyz;
  r5.xyz = log2(r5.xyz);
  r5.xyz = external_ADepthTB_AAngle.yyy * r5.xyz;
  r5.xyz = exp2(r5.xyz);
  r6.xyz = log2(r4.xyz);
  r6.xyz = external_ADepthTB_AAngle.xxx * r6.xyz;
  r6.xyz = exp2(r6.xyz);
  r5.xyz = r6.xyz + r5.xyz;
  r5.xyz = float3(1.000000e+000,1.000000e+000,1.000000e+000) + -r5.xyz;
  r1.w = dot(v3.xyz, v3.xyz);
  r1.w = rsqrt(r1.w);
  r6.xyz = v3.xyz * r1.www;
  r1.w = dot(r1.xyz, r6.xyz);
  r1.w = external_ADepthTB_AAngle.z + -abs(-r1.w);
  r3.z = external_ADepthTB_AAngle.w + -external_ADepthTB_AAngle.z;
  r1.w = r1.w / r3.z;
  r1.w = saturate(1.000000000e+000 + r1.w);
  r1.w = r5.x * r1.w;
  r0.w = r1.w * r0.w;
  r0.w = external_PerAxisAlpha_XYZ.z * r0.w;
  r0.z = dot(r0.xz, r0.xz);
  r0.x = dot(r0.xy, r0.xy);
  r0.xy = sqrt(r0.xz);
  r2.x = external_g_emitterTime * external_UVDistortPower_Speed_Tile.y + r0.y;
  r2.xy = r2.xy * r3.xy + v5.xy;
  r6.xyz = texture_DistortionClouds.Sample(sampler2_s, r2.xy).xyw;
  r6.x = r6.x * r6.z;
  r2.xy = r6.xy * float2(2.000000e+000,2.000000e+000) + float2(-1.000000e+000,-1.000000e+000);
  r0.yz = r2.xy * r0.yy;
  r0.yz = r0.yz * external_UVDistortPower_Speed_Tile.xx + r4.zx;
  r6.xyz = texture_Diff_01.Sample(sampler1_s, r0.yz).xyz;
  r0.y = saturate(dot(r6.xyz, external_Diff_01_RGB_Switch.xyz));
  r0.y = r0.y * v6.w + -v6.z;
  r0.y = log2(r0.y);
  r0.y = v6.y * r0.y;
  r0.y = exp2(r0.y);
  r0.y = v6.x * r0.y;
  r6.xyz = texture_Mask.Sample(sampler1_s, r4.zx).xyz;
  r0.z = saturate(dot(r6.xyz, external_Mask_RGB_Switch.xyz));
  r0.y = r0.z * r0.y;
  r0.z = dot(v2.xyz, v2.xyz);
  r0.z = rsqrt(r0.z);
  r6.xyz = v2.xyz * r0.zzz;
  r0.z = dot(r1.xyz, r6.xyz);
  r0.z = external_ADepthTB_AAngle.z + -abs(-r0.z);
  r0.z = r0.z / r3.z;
  r0.z = saturate(1.000000000e+000 + r0.z);
  r0.z = r5.y * r0.z;
  r0.y = r0.y * r0.z;
  r0.y = r0.y * external_PerAxisAlpha_XYZ.y + r0.w;
  r2.z = external_g_emitterTime * external_UVDistortPower_Speed_Tile.y + r0.x;
  r0.zw = r2.zw * r3.xy + v5.xy;
  r2.xyz = texture_DistortionClouds.Sample(sampler2_s, r0.zw).xyw;
  r2.x = r2.x * r2.z;
  r0.zw = r2.xy * float2(2.000000e+000,2.000000e+000) + float2(-1.000000e+000,-1.000000e+000);
  r0.xz = r0.xx * r0.zw;
  r0.xz = r0.xz * external_UVDistortPower_Speed_Tile.xx + r4.xy;
  r2.xyz = texture_Mask.Sample(sampler1_s, r4.xy).xyz;
  r0.w = saturate(dot(r2.xyz, external_Mask_RGB_Switch.xyz));
  r2.xyz = texture_Diff_01.Sample(sampler1_s, r0.xz).xyz;
  r0.x = saturate(dot(r2.xyz, external_Diff_01_RGB_Switch.xyz));
  r0.x = r0.x * v6.w + -v6.z;
  r0.x = log2(r0.x);
  r0.x = v6.y * r0.x;
  r0.x = exp2(r0.x);
  r0.x = v6.x * r0.x;
  r0.x = r0.w * r0.x;
  r0.z = dot(v1.xyz, v1.xyz);
  r0.z = rsqrt(r0.z);
  r2.xyz = v1.xyz * r0.zzz;
  r0.z = dot(r1.xyz, r2.xyz);
  r0.z = external_ADepthTB_AAngle.z + -abs(-r0.z);
  r0.z = r0.z / r3.z;
  r0.z = saturate(1.000000000e+000 + r0.z);
  r0.z = r5.z * r0.z;
  r0.x = r0.x * r0.z;
  r0.x = saturate(r0.x * external_PerAxisAlpha_XYZ.x + r0.y);
  o0.xyz = v7.xyz * r0.xxx;
  o0.w = r0.x;
  return;
}