// Ice Fog
Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

cbuffer cb2 : register(b2)
{
  float4 cb2[8];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[10];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[123];
}




// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);

#include "matrix.hlsl"

void main( 
  linear centroid float4 v0 : TEXCOORD10,
  linear centroid float4 v1 : TEXCOORD11,
  float4 v2 : TEXCOORD0,
  float4 v3 : TEXCOORD1,
  float4 v4 : TEXCOORD7,
  float4 v5 : SV_Position0,
  uint v6 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = v1.zxy * v0.yzx;
  r0.xyz = v1.yzx * v0.zxy + -r0.xyz;
  r0.xyz = v1.www * r0.xyz;
  r1.xy = -cb0[114].xy + v5.xy;
  r1.xy = r1.xy * cb0[115].zw + float2(-0.5,-0.5);
  r1.xy = v5.ww * r1.xy;
  r1.z = v5.w;
  r1.xyw = float3(2,-2,1) * r1.xyz;
  r2.xyzw = cb0[37].xyzw * v5.yyyy;
  r2.xyzw = v5.xxxx * cb0[36].xyzw + r2.xyzw;
  r2.xyzw = v5.zzzz * cb0[38].xyzw + r2.xyzw;
  r2.xyzw = cb0[39].xyzw + r2.xyzw;
  r2.xyz = r2.xyz / r2.www;
  
  // Common SVPositionToTranslatedWorld fix:
float4 s = StereoParams.Load(0);
matrix TranslatedWorldToClip = MATRIX(cb0, 0);
matrix ClipToTranslatedWorld = MATRIX(cb0, 32);
float4 t = mul(r2.xyz, TranslatedWorldToClip);
t.x -= s.x * (t.w - s.y);
r2.xyz = mul(t, ClipToTranslatedWorld);
  
  r0.w = dot(-r2.xyz, -r2.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = -r2.xyz * r0.www;
  r4.xyz = cb0[120].www * float3(0,0,1) + cb0[120].xyz;
  r0.w = dot(r4.xyz, r4.xyz);
  r0.w = rsqrt(r0.w);
  r4.xyz = r4.xyz * r0.www;
  r0.xyz = r4.yyy * r0.xyz;
  r0.xyz = r4.xxx * v0.xyz + r0.xyz;
  r0.xyz = r4.zzz * v1.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r4.xyz = cb2[4].xyz + cb2[3].xyz;
  r0.w = t0.Sample(s0_s, v2.zw).x;
  r0.w = r0.w * 2 + -1;
  r2.w = t0.Sample(s0_s, v3.xy).y;
  r0.w = r2.w * 2 + r0.w;
  r0.w = -0.5 + r0.w;
  r2.w = saturate(0.00200000009 * v5.w);
  r0.w = r2.w * r0.w;
  r1.xy = r1.xy / r1.ww;
  r1.xy = r1.xy * cb0[52].xy + cb0[52].wz;
  r1.x = t1.SampleLevel(s1_s, r1.xy, 0).x;
  r1.y = r1.x * cb0[51].x + cb0[51].y;
  r1.x = r1.x * cb0[51].z + -cb0[51].w;
  r1.x = 1 / r1.x;
  r1.x = r1.y + r1.x;
  r1.x = -r1.z * 1 + r1.x;
  r1.x = saturate(0.00033333333 * r1.x);
  r0.w = r1.x * r0.w;
  r0.x = dot(r0.xyz, r3.xyz);
  r0.x = max(0, r0.x);
  r0.x = 1 + -r0.x;
  r0.x = max(9.99999997e-007, abs(r0.x));
  r0.x = log2(r0.x);
  r0.x = 0.200000003 * r0.x;
  r0.x = exp2(r0.x);
  r0.x = r0.x * 0.199999988 + 0.800000012;
  r0.x = 1 + -r0.x;
  r0.x = r0.w * r0.x;
  r0.w = saturate(cb2[7].y * r0.x);
  r0.xyz = max(float3(0,0,0), r4.xyz);
  r1.x = cmp(0 < cb0[122].x);
  if (r1.x != 0) {
    r1.xyz = -cb0[56].xyz + r2.xyz;
    r2.xyz = -cb1[8].xyz + r1.xyz;
    r3.xyz = float3(1,1,1) + cb1[9].xyz;
    r2.xyz = cmp(r3.xyz < abs(r2.xyz));
    r1.w = (int)r2.y | (int)r2.x;
    r1.w = (int)r2.z | (int)r1.w;
    r1.x = dot(r1.xyz, float3(0.577000022,0.577000022,0.577000022));
    r1.x = 0.00200000009 * r1.x;
    r1.x = frac(r1.x);
    r1.x = cmp(0.5 < r1.x);
    r2.yzw = r1.xxx ? float3(0,1,1) : float3(1,1,0);
    r2.x = 1;
    r0.xyzw = r1.wwww ? r2.yzwx : r0.xyzw;
    o0.w = r0.w;
  } else {
    o0.w = r0.w;
  }
  o0.xyz = r0.xyz * v4.www + v4.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.2.57 on Fri Apr 28 19:32:43 2017
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                10   xyzw        0     NONE   float   xyz 
// TEXCOORD                11   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float     zw
// TEXCOORD                 1   xyzw        3     NONE   float   xy  
// TEXCOORD                 7   xyzw        4     NONE   float   xyzw
// SV_Position              0   xyzw        5      POS   float   xyzw
// SV_IsFrontFace           0   x           6    FFACE    uint       
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[123], immediateIndexed
dcl_constantbuffer cb1[10], immediateIndexed
dcl_constantbuffer cb2[8], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear centroid v0.xyz
dcl_input_ps linear centroid v1.xyzw
dcl_input_ps linear v2.zw
dcl_input_ps linear v3.xy
dcl_input_ps linear v4.xyzw
dcl_input_ps_siv linear noperspective v5.xyzw, position
dcl_output o0.xyzw
dcl_temps 5
mul r0.xyz, v0.yzxy, v1.zxyz
mad r0.xyz, v1.yzxy, v0.zxyz, -r0.xyzx
mul r0.xyz, r0.xyzx, v1.wwww
add r1.xy, v5.xyxx, -cb0[114].xyxx
mad r1.xy, r1.xyxx, cb0[115].zwzz, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r1.xy, r1.xyxx, v5.wwww
mov r1.z, v5.w
mul r1.xyw, r1.xyxz, l(2.000000, -2.000000, 0.000000, 1.000000)
mul r2.xyzw, v5.yyyy, cb0[37].xyzw
mad r2.xyzw, v5.xxxx, cb0[36].xyzw, r2.xyzw
mad r2.xyzw, v5.zzzz, cb0[38].xyzw, r2.xyzw
add r2.xyzw, r2.xyzw, cb0[39].xyzw
div r2.xyz, r2.xyzx, r2.wwww
dp3 r0.w, -r2.xyzx, -r2.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, -r2.xyzx
mad r4.xyz, cb0[120].wwww, l(0.000000, 0.000000, 1.000000, 0.000000), cb0[120].xyzx
dp3 r0.w, r4.xyzx, r4.xyzx
rsq r0.w, r0.w
mul r4.xyz, r0.wwww, r4.xyzx
mul r0.xyz, r0.xyzx, r4.yyyy
mad r0.xyz, r4.xxxx, v0.xyzx, r0.xyzx
mad r0.xyz, r4.zzzz, v1.xyzx, r0.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
add r4.xyz, cb2[3].xyzx, cb2[4].xyzx
sample_indexable(texture2d)(float,float,float,float) r0.w, v2.zwzz, t0.yzwx, s0
mad r0.w, r0.w, l(2.000000), l(-1.000000)
sample_indexable(texture2d)(float,float,float,float) r2.w, v3.xyxx, t0.xzwy, s0
mad r0.w, r2.w, l(2.000000), r0.w
add r0.w, r0.w, l(-0.500000)
mul_sat r2.w, v5.w, l(0.002000)
mul r0.w, r0.w, r2.w
div r1.xy, r1.xyxx, r1.wwww
mad r1.xy, r1.xyxx, cb0[52].xyxx, cb0[52].wzww
sample_l_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t1.xyzw, s1, l(0.000000)
mad r1.y, r1.x, cb0[51].x, cb0[51].y
mad r1.x, r1.x, cb0[51].z, -cb0[51].w
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
add r1.x, r1.x, r1.y
mad r1.x, -r1.z, l(1.000000), r1.x
mul_sat r1.x, r1.x, l(0.000333333330)
mul r0.w, r0.w, r1.x
dp3 r0.x, r0.xyzx, r3.xyzx
max r0.x, r0.x, l(0.000000)
add r0.x, -r0.x, l(1.000000)
max r0.x, |r0.x|, l(0.000001)
log r0.x, r0.x
mul r0.x, r0.x, l(0.200000)
exp r0.x, r0.x
mad r0.x, r0.x, l(0.199999988), l(0.800000)
add r0.x, -r0.x, l(1.000000)
mul r0.x, r0.x, r0.w
mul_sat r0.w, r0.x, cb2[7].y
max r0.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
lt r1.x, l(0.000000), cb0[122].x
if_nz r1.x
  add r1.xyz, r2.xyzx, -cb0[56].xyzx
  add r2.xyz, r1.xyzx, -cb1[8].xyzx
  add r3.xyz, cb1[9].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  lt r2.xyz, r3.xyzx, |r2.xyzx|
  or r1.w, r2.y, r2.x
  or r1.w, r2.z, r1.w
  dp3 r1.x, r1.xyzx, l(0.577000, 0.577000, 0.577000, 0.000000)
  mul r1.x, r1.x, l(0.002000)
  frc r1.x, r1.x
  lt r1.x, l(0.500000), r1.x
  movc r2.yzw, r1.xxxx, l(0,0,1.000000,1.000000), l(0,1.000000,1.000000,0)
  mov r2.x, l(1.000000)
  movc r0.xyzw, r1.wwww, r2.yzwx, r0.xyzw
  mov o0.w, r0.w
else 
  mov o0.w, r0.w
endif 
mad o0.xyz, r0.xyzx, v4.wwww, v4.xyzx
ret 
// Approximately 0 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
