//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)
{
  float4 external_ADepthTB_AAngle : packoffset(c0);
  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_DistortionSpeed_Tile : packoffset(c6);
  float external_g_emitterTime : packoffset(c7);
  float3 vc_pad7 : packoffset(c7.y);
  float external_UVDistort_Power : packoffset(c8);
  float3 vc_pad8 : packoffset(c8.y);
  float4 external_TextureTile_Offset : packoffset(c9);
  float3 external_Diff_01_RGB_Switch : packoffset(c10);
  float1 vc_pad10 : packoffset(c10.w);
}
SamplerState sampler0_s : register(s0);
SamplerState sampler1_s : register(s1);
SamplerState sampler2_s : register(s2);
Texture2D<float4> texture_depthBufferTexture : register(t1);
Texture2D<float4> texture_Mask : register(t2);
Texture2D<float4> texture_Diff_01 : register(t3);
Texture2D<float4> texture_DistortionClouds : register(t4);
Texture2D<float4> texture_Normal : 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,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1,r2,r3;
  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;
  
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;
 
  r1.x = dot(external_viewMatrix1.xyz, r0.xyz);
  r1.y = dot(external_viewMatrix2.xyz, r0.xyz);
  r1.z = dot(external_viewMatrix3.xyz, r0.xyz);
  r1.w = 1.000000000e+000;
  r0.x = dot(r1.xyzw, v1.xyzw);
  r0.y = dot(r1.xyzw, v2.xyzw);
  r0.z = dot(r1.xyzw, v3.xyzw);
  r0.w = dot(r1.xyzw, v4.xyzw);
  r0.xyz = r0.xyz / r0.www;
  r2.xyz = float3(5.000000e-001,5.000000e-001,5.000000e-001) + -abs(-r0.xyz);
  r0.xyz = float3(5.000000e-001,5.000000e-001,5.000000e-001) + r0.xyz;
  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 = ddy_coarse(r1.zxy);
  r1.xyz = ddx_coarse(r1.yzx);
  r3.xyz = r2.xyz * r1.xyz;
  r1.xyz = r2.zxy * r1.yzx + -r3.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r0.w = dot(v2.xyz, v2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = v2.xyz * r0.www;
  r0.w = saturate(dot(r1.xyz, r2.xyz));
  r0.w = external_ADepthTB_AAngle.z + -r0.w;
  r1.x = external_ADepthTB_AAngle.w + -external_ADepthTB_AAngle.z;
  r0.w = r0.w / r1.x;
  r0.w = saturate(1.000000000e+000 + r0.w);
  r1.xy = external_DistortionSpeed_Tile.zw * r0.xz;
  r1.xy = external_DistortionSpeed_Tile.xy * external_g_emitterTime + r1.xy;
  r1.xy = v5.xy + r1.xy;
  r1.xy = texture_DistortionClouds.Sample(sampler2_s, r1.xy).xy;
  r1.zw = r0.xz * external_TextureTile_Offset.xy + -external_TextureTile_Offset.zw;
  r1.xy = r1.xy * external_UVDistort_Power + r1.zw;
  r2.xyz = texture_Diff_01.Sample(sampler1_s, r1.xy).xyz;
  r1.xyz = texture_Normal.Sample(sampler1_s, r1.xy).xyw;
  r1.w = saturate(dot(r2.xyz, external_Diff_01_RGB_Switch.xyz));
  r2.x = r1.w * v6.w + -v6.z;
  r2.yzw = v7.xyz * r1.www;
  r1.w = log2(r2.x);
  r1.w = v6.y * r1.w;
  r1.w = exp2(r1.w);
  r1.w = v6.x * r1.w;
  r3.xyz = texture_Mask.Sample(sampler1_s, r0.xz).xyz;
  r0.x = saturate(dot(r3.xyz, external_Mask_RGB_Switch.xyz));
  r0.x = r0.x * r1.w;
  r0.z = 1.000000000e+000 + -r0.y;
  r0.y = log2(r0.y);
  r0.y = external_ADepthTB_AAngle.x * r0.y;
  r0.y = exp2(r0.y);
  r0.z = log2(r0.z);
  r0.z = external_ADepthTB_AAngle.y * r0.z;
  r0.z = exp2(r0.z);
  r0.y = r0.y + r0.z;
  r0.y = 1.000000000e+000 + -r0.y;
  r0.x = r0.y * r0.x;
  r2.xyz = r0.yyy * r2.yzw;
  r2.xyz = sqrt(r2.xyz);
  r0.x = r0.x * r0.w;
  r1.x = r1.x * r1.z;
  r0.yz = r1.xy * float2(2.000000e+000,2.000000e+000) + float2(-1.000000e+000,-1.000000e+000);
  r1.xyz = v3.xyz * r0.zzz;
  r1.xyz = v1.xyz * r0.yyy + r1.xyz;
  r0.y = dot(r0.yz, r0.yz);
  r0.y = 1.000000000e+000 + -r0.y;
  r0.y = max(r0.y, 0.000000000e+000);
  r0.y = sqrt(r0.y);
  r0.yzw = v2.xyz * r0.yyy + r1.xyz;
  r1.x = dot(r0.yzw, r0.yzw);
  r1.x = rsqrt(r1.x);
  r0.yzw = r1.xxx * r0.yzw;
  r0.yzw = r0.yzw * float3(5.000000e-001,5.000000e-001,5.000000e-001) + float3(5.000000e-001,5.000000e-001,5.000000e-001);
  o0.xyz = r0.yzw * r0.xxx;
  o0.w = r0.x;
  o1.xyz = r2.xyz * r0.xxx;
  o1.w = r0.x;
  return;
}