//Water PS inside (related to Icy Water VS2).
// ---- Created with 3Dmigoto v1.2.45 on Tue Nov 08 14:15:48 2016
Texture2D<float4> t11 : register(t11);

Texture2D<float4> t10 : register(t10);

Texture2D<float4> t9 : register(t9);

Texture2D<float4> t8 : register(t8);

Texture2D<float4> t4 : register(t4);

TextureCube<float4> t3 : register(t3);

Texture2D<float4> t1 : register(t1);

SamplerState s11_s : register(s11);

SamplerState s10_s : register(s10);

SamplerState s9_s : register(s9);

SamplerState s8_s : register(s8);

SamplerState s4_s : register(s4);

SamplerState s3_s : register(s3);

SamplerState s1_s : register(s1);

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

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

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

cbuffer cb12 : register(b12)
{
  float4 cb12[45];
}




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


void main( 
  float4 v0 : SV_POSITION0,
  float4 v1 : COLOR0,
  float4 v2 : TEXCOORD0,
  float4 v3 : TEXCOORD1,
  float4 v4 : TEXCOORD2,
  float4 v5 : TEXCOORD3,
  nointerpolation float4 v6 : TEXCOORD4,
  float4 v7 : TEXCOORD5,
float4 v8 : TEXCOORD6,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r10;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = float2(64,128) * v6.xx;
  r1.w = 1 / r0.y;
  r0.xy = v4.zw * r0.xx;
  r0.xy = frac(r0.xy);
  r0.xy = r0.xy * float2(2,2) + float2(-1,-1);
  r0.xy = float2(-0.5,-0.5) + abs(r0.xy);
  r0.xy = float2(0.5,0.5) + -r0.xy;
  r1.yz = float2(0,0);
  r2.xyzw = v4.zwzw + r1.wzzw;
  r0.zw = v4.zw + r1.ww;
  r3.xyzw = t8.Sample(s8_s, r0.zw).xyzw;
  r4.xyzw = t8.Sample(s8_s, r2.zw).xyzw;
  r2.xyzw = t8.Sample(s8_s, r2.xy).xyzw;
  r0.z = 1.00999999 + -r4.z;
  r0.z = sqrt(r0.z);
  r1.zw = float2(64,64) * v5.xy;
  r0.zw = r1.zw * r0.zz;
  r4.xy = r4.xy * float2(2,2) + float2(-1,-1);
  r4.z = -r4.y;
  r5.x = dot(r4.xz, r0.zw);
  r5.y = dot(r4.yx, r0.zw);
  r6.yw = float2(0,0);
  r0.z = 0.00100000005 * cb1[2].w;
  r0.w = r0.z * r4.w;
  r6.z = 10.6400003 * r0.w;
  r4.xy = -r6.zw + r5.xy;
  r4.xy = float2(0.270000011,0.270000011) + r4.xy;
  r4.xy = t9.Sample(s9_s, r4.xy).xy;
  r0.w = 1.00999999 + -r3.z;
  r0.w = sqrt(r0.w);
  r4.zw = r1.zw * r0.ww;
  r3.xy = r3.xy * float2(2,2) + float2(-1,-1);
  r0.w = r0.z * r3.w;
  r5.x = 9.92000008 * r0.w;
  r3.z = -r3.y;
  r7.x = dot(r3.xz, r4.zw);
  r7.y = dot(r3.yx, r4.zw);
  r5.y = 0;
  r3.xy = r7.xy + -r5.xy;
  r3.xy = t9.Sample(s9_s, r3.xy).xy;
  r3.zw = float2(1,1) + -r0.xy;
  r3.xy = r3.zz * r3.xy;
  r3.xy = r0.xx * r4.xy + r3.xy;
  r3.xy = r3.ww * r3.xy;
  r4.xyzw = t8.Sample(s8_s, v4.zw).xyzw;
  r0.w = 1.00999999 + -r4.z;
  r0.w = sqrt(r0.w);
  r5.xy = r1.zw * r0.ww;
  r4.xy = r4.xy * float2(2,2) + float2(-1,-1);
  r0.w = r4.w * r0.z;
  r0.z = r0.z * r2.w;
  r6.x = 8.47999954 * r0.z;
  r1.x = 8 * r0.w;
  r4.z = -r4.y;
  r7.x = dot(r4.xz, r5.xy);
  r7.y = dot(r4.yx, r5.xy);
  r0.zw = r7.xy + -r1.xy;
  r0.zw = t9.Sample(s9_s, r0.zw).xy;
  r1.x = 1.00999999 + -r2.z;
  r2.xy = r2.xy * float2(2,2) + float2(-1,-1);
  r1.x = sqrt(r1.x);
  r1.xy = r1.zw * r1.xx;
  r2.z = -r2.y;
  r4.x = dot(r2.xz, r1.xy);
  r4.y = dot(r2.yx, r1.xy);
  r1.xy = r4.xy + -r6.xy;
  r1.xy = float2(0.620000005,0.620000005) + r1.xy;
  r1.xy = t9.Sample(s9_s, r1.xy).xy;
  r1.xy = r3.zz * r1.xy;
  r1.zw = r3.zw * r3.zw;
  r1.zw = r0.xy * r0.xy + r1.zw;
  r1.zw = sqrt(r1.zw);
  r1.z = r1.w * r1.z;
  r0.xz = r0.xx * r0.zw + r1.xy;
  r0.xy = r0.yy * r0.xz + r3.xy;
  r0.xy = float2(-0.5,-0.5) + r0.xy;
  r0.xy = r0.xy / r1.zz;
  r0.w = -r0.x * r0.x + 1;
  r0.w = -r0.y * r0.y + r0.w;
  r0.z = sqrt(r0.w);
  r1.xyz = t4.Sample(s4_s, v3.xy).xyz;
  r1.xyz = r1.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.xyz = -r1.xyz + r0.xyz;
  r0.w = -8192 + v2.w;
  r1.w = -8192 + cb1[7].x;
  r0.w = r0.w / r1.w;
  r1.w = 1 + -cb12[42].w;
  r0.w = saturate(r0.w * r1.w + cb12[42].w);
  r0.xyz = r0.www * r0.xyz + r1.xyz;
  r0.w = cb1[12].x * r0.w;
  r1.x = dot(r0.xyz, r0.xyz);
  r1.x = rsqrt(r1.x);
  r0.xyz = r1.xxx * r0.xyz;
  r1.xy = cb1[13].xx * r0.xy;
  r1.zw = cb12[44].xy * v0.xy;
  r1.xy = r1.zw * cb1[12].zw + r1.xy;
  r1.xy = cb12[43].xy * r1.xy;
  r1.xy = max(float2(0,0), r1.xy);
  r2.x = cb12[44].z;
  r2.y = cb12[43].y;
  r1.xy = min(r2.xy, r1.xy);
  r3.xyzw = t10.Sample(s10_s, r1.xy).xyzw;
  r1.xyzw = t11.Sample(s11_s, r1.xy).xyzw;
  r3.xyzw = r3.xyzw + -r1.xyzw;
  r1.xyzw = cb1[12].yyyy * r3.xyzw + r1.xyzw;
  r0.w = saturate(r1.w * r0.w);
  r3.x = 0;
  r3.z = 1 + -cb1[7].y;
  r3.xyz = cb1[7].yyy * r0.xyz + r3.xxz;
  //r1.w = dot(v2.xyz, v2.xyz);
  //r1.w = rsqrt(r1.w);
  //r4.xyz = v2.xyz * r1.www;
r1.w = dot(v8.xyz, v8.xyz);
r1.w = rsqrt(r1.w);
r4.xyz = v8.xyz * r1.www;

// corrected value
r10.x = dot(v2.xyz, v2.xyz);
r10.x = rsqrt(r10.x);
r10.xyz = v2.xyz * r10.xxx;
//r3.xyz = -r10.xyz * r0.zzz;

  r1.w = dot(r4.xyz, r3.xyz);
  r1.w = r1.w + r1.w;
  r3.xyz = r3.xyz * -r1.www + r4.xyz;
  r0.z = saturate(dot(-r4.xyz, -r0.xyz));
  r4.xy = cb1[5].ww * r0.xy + v7.xy;
  r0.x = 1 + -r0.z;
  r3.xyz = t3.Sample(s3_s, r3.xyz).xyz;
  r5.xyz = cb1[7].www * r3.xyz;
  r1.xyz = -r3.xyz * cb1[7].www + r1.xyz;
  r0.yzw = r0.www * r1.xyz + r5.xyz;
  r0.yzw = -cb1[2].xyz + r0.yzw;
  r0.yzw = cb1[5].yyy * r0.yzw + cb1[2].xyz;
  r0.yzw = -cb1[0].xyz + r0.yzw;
  r0.yzw = r0.yzw * float3(0.5,0.5,0.5) + cb1[0].xyz;
  r4.z = v7.z;
  r4.w = 1;
  r1.x = dot(cb2[1].xyzw, r4.xyzw);
  r1.y = dot(cb2[3].xyzw, r4.xyzw);
  r3.x = dot(cb2[0].xyzw, r4.xyzw);
  r3.y = r1.y + -r1.x;
  r1.xy = r3.xy / r1.yy;
  r1.xy = cb12[43].xy * r1.xy;
  r1.xy = max(float2(0,0), r1.xy);
  r1.xy = min(r1.xy, r2.xy);
  r1.xyz = t1.Sample(s1_s, r1.xy).xyz;
  r1.xyz = r1.xyz * cb1[7].www + -r0.yzw;
  r1.w = r0.x * r0.x;
  r1.w = r1.w * r1.w;
  r0.x = r1.w * r0.x;
  r1.w = 1 + -cb1[3].x;
  r0.x = r1.w * r0.x + cb1[3].x;
  r0.x = 1 + -r0.x;
  r1.xyz = r0.xxx * r1.xyz;
  r0.x = saturate(-v2.w * 0.00200000009 + 1);
  r0.xyz = r0.xxx * r1.xyz + r0.yzw;
  r0.w = cb0[1].w;
  o0.xyz = saturate(r0.xyz * r0.www);
  o0.w = saturate(0);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.2.45 on Tue Nov 08 14:15:47 2016
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy  
// COLOR                    0   xyzw        1     NONE   float       
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyzw        3     NONE   float   xy  
// TEXCOORD                 2   xyzw        4     NONE   float     zw
// TEXCOORD                 3   xyzw        5     NONE   float   xy  
// TEXCOORD                 4   x           6     NONE   float   x   
// TEXCOORD                 5   xyzw        7     NONE   float   xyz 
//
//
// 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 cb12[45], immediateIndexed
dcl_constantbuffer cb0[2], immediateIndexed
dcl_constantbuffer cb1[14], immediateIndexed
dcl_constantbuffer cb2[4], immediateIndexed
dcl_sampler s1, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s8, mode_default
dcl_sampler s9, mode_default
dcl_sampler s10, mode_default
dcl_sampler s11, mode_default
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texturecube (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t8
dcl_resource_texture2d (float,float,float,float) t9
dcl_resource_texture2d (float,float,float,float) t10
dcl_resource_texture2d (float,float,float,float) t11
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xy
dcl_input_ps linear v4.zw
dcl_input_ps linear v5.xy
dcl_input_ps constant v6.x
dcl_input_ps linear v7.xyz
dcl_output o0.xyzw
dcl_temps 8
mul r0.xy, v6.xxxx, l(64.000000, 128.000000, 0.000000, 0.000000)
div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
mul r0.xy, r0.xxxx, v4.zwzz
frc r0.xy, r0.xyxx
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
add r0.xy, |r0.xyxx|, l(-0.500000, -0.500000, 0.000000, 0.000000)
add r0.xy, -r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mov r1.yz, l(0,0,0,0)
add r2.xyzw, r1.wzzw, v4.zwzw
add r0.zw, r1.wwww, v4.zzzw
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r0.zwzz, t8.xyzw, s8
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r2.zwzz, t8.xyzw, s8
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.xyxx, t8.xyzw, s8
add r0.z, -r4.z, l(1.010000)
sqrt r0.z, r0.z
mul r1.zw, v5.xxxy, l(0.000000, 0.000000, 64.000000, 64.000000)
mul r0.zw, r0.zzzz, r1.zzzw
mad r4.xy, r4.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mov r4.z, -r4.y
dp2 r5.x, r4.xzxx, r0.zwzz
dp2 r5.y, r4.yxyy, r0.zwzz
mov r6.yw, l(0,0,0,0)
mul r0.z, cb1[2].w, l(0.001000)
mul r0.w, r4.w, r0.z
mul r6.z, r0.w, l(10.640000)
add r4.xy, r5.xyxx, -r6.zwzz
add r4.xy, r4.xyxx, l(0.270000, 0.270000, 0.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r4.xy, r4.xyxx, t9.xyzw, s9
add r0.w, -r3.z, l(1.010000)
sqrt r0.w, r0.w
mul r4.zw, r0.wwww, r1.zzzw
mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r0.w, r3.w, r0.z
mul r5.x, r0.w, l(9.920000)
mov r3.z, -r3.y
dp2 r7.x, r3.xzxx, r4.zwzz
dp2 r7.y, r3.yxyy, r4.zwzz
mov r5.y, l(0)
add r3.xy, -r5.xyxx, r7.xyxx
sample_indexable(texture2d)(float,float,float,float) r3.xy, r3.xyxx, t9.xyzw, s9
add r3.zw, -r0.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000)
mul r3.xy, r3.xyxx, r3.zzzz
mad r3.xy, r0.xxxx, r4.xyxx, r3.xyxx
mul r3.xy, r3.xyxx, r3.wwww
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, v4.zwzz, t8.xyzw, s8
add r0.w, -r4.z, l(1.010000)
sqrt r0.w, r0.w
mul r5.xy, r0.wwww, r1.zwzz
mad r4.xy, r4.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r0.w, r0.z, r4.w
mul r0.z, r2.w, r0.z
mul r6.x, r0.z, l(8.480000)
mul r1.x, r0.w, l(8.000000)
mov r4.z, -r4.y
dp2 r7.x, r4.xzxx, r5.xyxx
dp2 r7.y, r4.yxyy, r5.xyxx
add r0.zw, -r1.xxxy, r7.xxxy
sample_indexable(texture2d)(float,float,float,float) r0.zw, r0.zwzz, t9.zwxy, s9
add r1.x, -r2.z, l(1.010000)
mad r2.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
sqrt r1.x, r1.x
mul r1.xy, r1.xxxx, r1.zwzz
mov r2.z, -r2.y
dp2 r4.x, r2.xzxx, r1.xyxx
dp2 r4.y, r2.yxyy, r1.xyxx
add r1.xy, -r6.xyxx, r4.xyxx
add r1.xy, r1.xyxx, l(0.620000, 0.620000, 0.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r1.xy, r1.xyxx, t9.xyzw, s9
mul r1.xy, r1.xyxx, r3.zzzz
mul r1.zw, r3.zzzw, r3.zzzw
mad r1.zw, r0.xxxy, r0.xxxy, r1.zzzw
sqrt r1.zw, r1.zzzw
mul r1.z, r1.z, r1.w
mad r0.xz, r0.xxxx, r0.zzwz, r1.xxyx
mad r0.xy, r0.yyyy, r0.xzxx, r3.xyxx
add r0.xy, r0.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
div r0.xy, r0.xyxx, r1.zzzz
mad r0.w, -r0.x, r0.x, l(1.000000)
mad r0.w, -r0.y, r0.y, r0.w
sqrt r0.z, r0.w
sample_indexable(texture2d)(float,float,float,float) r1.xyz, v3.xyxx, t4.xyzw, s4
mad r1.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
add r0.xyz, r0.xyzx, -r1.xyzx
add r0.w, v2.w, l(-8192.000000)
add r1.w, cb1[7].x, l(-8192.000000)
div r0.w, r0.w, r1.w
add r1.w, -cb12[42].w, l(1.000000)
mad_sat r0.w, r0.w, r1.w, cb12[42].w
mad r0.xyz, r0.wwww, r0.xyzx, r1.xyzx
mul r0.w, r0.w, cb1[12].x
dp3 r1.x, r0.xyzx, r0.xyzx
rsq r1.x, r1.x
mul r0.xyz, r0.xyzx, r1.xxxx
mul r1.xy, r0.xyxx, cb1[13].xxxx
mul r1.zw, v0.xxxy, cb12[44].xxxy
mad r1.xy, r1.zwzz, cb1[12].zwzz, r1.xyxx
mul r1.xy, r1.xyxx, cb12[43].xyxx
max r1.xy, r1.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
mov r2.x, cb12[44].z
mov r2.y, cb12[43].y
min r1.xy, r1.xyxx, r2.xyxx
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r1.xyxx, t10.xyzw, s10
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r1.xyxx, t11.xyzw, s11
add r3.xyzw, -r1.xyzw, r3.xyzw
mad r1.xyzw, cb1[12].yyyy, r3.xyzw, r1.xyzw
mul_sat r0.w, r0.w, r1.w
mov r3.x, l(0)
add r3.z, -cb1[7].y, l(1.000000)
mad r3.xyz, cb1[7].yyyy, r0.xyzx, r3.xxzx
dp3 r1.w, v2.xyzx, v2.xyzx
rsq r1.w, r1.w
mul r4.xyz, r1.wwww, v2.xyzx
dp3 r1.w, r4.xyzx, r3.xyzx
add r1.w, r1.w, r1.w
mad r3.xyz, r3.xyzx, -r1.wwww, r4.xyzx
dp3_sat r0.z, -r4.xyzx, -r0.xyzx
mad r4.xy, cb1[5].wwww, r0.xyxx, v7.xyxx
add r0.x, -r0.z, l(1.000000)
sample_indexable(texturecube)(float,float,float,float) r3.xyz, r3.xyzx, t3.xyzw, s3
mul r5.xyz, r3.xyzx, cb1[7].wwww
mad r1.xyz, -r3.xyzx, cb1[7].wwww, r1.xyzx
mad r0.yzw, r0.wwww, r1.xxyz, r5.xxyz
add r0.yzw, r0.yyzw, -cb1[2].xxyz
mad r0.yzw, cb1[5].yyyy, r0.yyzw, cb1[2].xxyz
add r0.yzw, r0.yyzw, -cb1[0].xxyz
mad r0.yzw, r0.yyzw, l(0.000000, 0.500000, 0.500000, 0.500000), cb1[0].xxyz
mov r4.z, v7.z
mov r4.w, l(1.000000)
dp4 r1.x, cb2[1].xyzw, r4.xyzw
dp4 r1.y, cb2[3].xyzw, r4.xyzw
dp4 r3.x, cb2[0].xyzw, r4.xyzw
add r3.y, -r1.x, r1.y
div r1.xy, r3.xyxx, r1.yyyy
mul r1.xy, r1.xyxx, cb12[43].xyxx
max r1.xy, r1.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
min r1.xy, r2.xyxx, r1.xyxx
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r1.xyxx, t1.xyzw, s1
mad r1.xyz, r1.xyzx, cb1[7].wwww, -r0.yzwy
mul r1.w, r0.x, r0.x
mul r1.w, r1.w, r1.w
mul r0.x, r0.x, r1.w
add r1.w, -cb1[3].x, l(1.000000)
mad r0.x, r1.w, r0.x, cb1[3].x
add r0.x, -r0.x, l(1.000000)
mul r1.xyz, r1.xyzx, r0.xxxx
mad_sat r0.x, -v2.w, l(0.002000), l(1.000000)
mad r0.xyz, r0.xxxx, r1.xyzx, r0.yzwy
mov r0.w, cb0[1].w
mul_sat o0.xyz, r0.wwww, r0.xyzx
mov_sat o0.w, l(0)
ret 
// Approximately 0 instruction slots used

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