// Water PS
Texture2D<float4> t11 : register(t11);

Texture2D<float4> t10 : register(t10);

Texture2D<float4> t7 : register(t7);

Texture2D<float4> t6 : register(t6);

Texture2D<float4> t5 : register(t5);

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 s6_s : register(s6);

SamplerState s5_s : register(s5);

SamplerState s4_s : register(s4);

SamplerState s3_s : register(s3);

SamplerState s1_s : register(s1);

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

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

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

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 : TEXCOORD5,
float4 v6 : TEXCOORD6,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7, r10;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
float4 params = IniParams.Load(0);

  r0.xyz = t4.Sample(s4_s, v3.xy).xyz;
  r0.xyz = r0.xyz * float3(2,2,2) + float3(-1,-1,-2);
  r0.xyz = cb1[6].xxx * r0.xyz + float3(0,0,1);
  r1.xyz = t5.Sample(s5_s, v3.zw).xyz;
  r1.xyz = r1.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.xyz = cb1[6].yyy * r1.xyz + r0.xyz;
  r1.xyz = t6.Sample(s6_s, v4.xy).xyz;
  r1.xyz = r1.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.xyz = cb1[6].zzz * r1.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www + float3(-0,-0,-1);
  r1.zw = float2(0,0);
  r2.xy = cb12[44].xy * v0.xy;
  r2.zw = cb12[43].xy * r2.xy;
  r1.xy = (int2)r2.zw;
  r0.w = t7.Load(r1.xyz).x;
  r0.w = -r0.w * cb0[2].z + cb0[2].x;
  r1.z = cb0[2].w / r0.w;
  r3.xy = r2.xy * cb0[0].xy + cb0[0].zw;
  r2.zw = r3.xy * float2(2,2) + float2(-1,-1);
  r2.zw = r2.zw * r1.zz;
  r1.xy = r2.zw / cb2[5].xy;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = sqrt(r0.w);
  r1.x = dot(v6.xyz, v6.xyz);
  r1.x = rsqrt(r1.x);
  r1.xyz = v6.xyz * r1.xxx;
// corrected value
r10.x = dot(v2.xyz, v2.xyz);
r10.x = rsqrt(r10.x);
r10.xyz = v2.xyz * r10.xxx;
  // r4.xyz = -r1.xyz * r0.www;
// Use corrected coordinate
r4.xyz = -r10.xyz * r0.www;
  r0.w = dot(r4.xyz, cb2[4].xyz);
  r1.w = dot(r4.xyz, r4.xyz);
  r1.w = sqrt(r1.w);
  r2.z = cb2[4].w / r0.w;
  r2.z = 1 + -r2.z;
  r0.w = r2.z * abs(r0.w);
  r1.w = r2.z * r1.w;
  r4.xy = saturate(r1.ww / cb1[10].zz);
  r4.zw = saturate(r0.ww / cb1[10].zz);
  r5.xyzw = float4(-1,-1,-1,-1) + r4.xyzw;
  r5.xyzw = cb1[11].xyzw * r5.xyzw + float4(1,1,1,1);
  r0.xyz = r5.zzz * r0.xyz + float3(0,0,1);
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r0.w = cb1[5].w * r5.y;
  r6.xy = r0.ww * r0.xy + v5.xy;
  r6.z = v5.z;
  r6.w = 1;
  r0.w = dot(cb2[1].xyzw, r6.xyzw);
  r7.z = dot(cb2[3].xyzw, r6.xyzw);
  r7.x = dot(cb2[0].xyzw, r6.xyzw);
  r7.y = r7.z + -r0.w;
  r2.zw = r7.xy / r7.zz;
  r4.xz = r2.zw / cb0[0].xy;
  r2.zw = cb0[0].zw + r2.zw;
  r2.zw = r2.zw * float2(2,2) + float2(-1,-1);
  r4.xz = cb12[43].xy * r4.xz;
  r6.xy = (int2)r4.xz;
  r6.zw = float2(0,0);
  r0.w = t7.Load(r6.xyz).x;
  r0.w = -r0.w * cb0[2].z + cb0[2].x;
  r6.z = cb0[2].w / r0.w;
  r2.zw = r6.zz * r2.zw;
  r6.xy = r2.zw / cb2[5].xy;
  r0.w = dot(r6.xyz, r6.xyz);
  r0.w = sqrt(r0.w);
  r4.xzw = -r1.xyz * r0.www;
  r0.w = dot(r4.xzw, cb2[4].xyz);
  r1.w = cmp(0 < r0.w);
  r2.z = cmp(r0.w < 0);
  r0.w = cb2[4].w / r0.w;
  r0.w = 1 + -r0.w;
  r1.w = (int)-r1.w + (int)r2.z;
  r1.w = (int)r1.w;
  r0.w = r1.w * r0.w;
  r0.w = cmp(r0.w < 0);
  r3.z = 1;
  r3.xyz = r0.www ? r3.xyz : r7.xyz;
  r2.zw = r3.xy / r3.zz;
  r2.zw = cb12[43].xy * r2.zw;
  r2.zw = max(float2(0,0), r2.zw);
  r3.x = cb12[44].z;
  r3.y = cb12[43].y;
  r2.zw = min(r3.xy, r2.zw);
  r4.xzw = t1.Sample(s1_s, r2.zw).xyz;
  r6.xyz = cb1[1].xyz + -cb1[0].xyz;
  r6.xyz = r4.yyy * r6.xyz + cb1[0].xyz;
  r0.w = -r4.y * cb1[10].z + cb1[10].z;
  r0.w = saturate(r0.w / cb1[10].w);
  r0.w = log2(r0.w);
  r0.w = cb1[8].w * r0.w;
  r0.w = exp2(r0.w);
  r0.w = 1 + -r0.w;
  r6.xyz = -r4.xzw * cb1[7].www + r6.xyz;
  r4.xyz = cb1[7].www * r4.xzw;
  r4.xyz = r0.www * r6.xyz + r4.xyz;
  r2.zw = cb1[13].xx * r0.xy;
  r2.xy = r2.xy * cb1[12].zw + r2.zw;
  r2.xy = cb12[43].xy * r2.xy;
  r2.xy = max(float2(0,0), r2.xy);
  r2.xy = min(r2.xy, r3.xy);
  r3.xyzw = t10.Sample(s10_s, r2.xy).xyzw;
  r2.xyzw = t11.Sample(s11_s, r2.xy).xyzw;
  r3.xyzw = r3.xyzw + -r2.xyzw;
  r2.xyzw = cb1[12].yyyy * r3.xyzw + r2.xyzw;
  r3.x = 0;
  r3.z = 1 + -cb1[7].y;
  r3.xyz = cb1[7].yyy * r0.xyz + r3.xxz;
  r0.w = dot(r1.xyz, r3.xyz);
  r0.w = r0.w + r0.w;
  r3.xyz = r3.xyz * -r0.www + r1.xyz;
  r3.xyz = t3.Sample(s3_s, r3.xyz).xyz;
  r2.xyz = -r3.xyz * cb1[7].www + r2.xyz;
  r3.xyz = cb1[7].www * r3.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);
  r1.w = cb1[12].x * r0.w;
  r1.w = saturate(r2.w * r1.w);
  r2.xyz = r1.www * r2.xyz + r3.xyz;
  r2.xyz = -cb1[2].xyz + r2.xyz;
  r2.xyz = cb1[5].yyy * r2.xyz + cb1[2].xyz;
  r2.xyz = r2.xyz + -r4.xyz;
  r1.w = saturate(dot(-r1.xyz, r0.xyz));
  r1.w = 1 + -r1.w;
  r2.w = r1.w * r1.w;
  r2.w = r2.w * r2.w;
  r1.w = r2.w * r1.w;
  r2.w = 1 + -cb1[3].x;
  r1.w = r2.w * r1.w + cb1[3].x;
  r1.w = r1.w * r5.x + -1;
  r0.w = r0.w * r1.w + 1;
  r2.xyz = r0.www * r2.xyz + r4.xyz;
  r0.w = dot(r1.xyz, r0.xyz);
//modifies reflection
  r0.w = r0.w + r0.w;
  r1.xyz = r0.xyz * -r0.www + r1.xyz;
  r0.x = saturate(dot(r0.xyz, float3(-0.0989999995,-0.0989999995,0.99000001)));
  r0.x = log2(r0.x);
  r0.x = cb1[0].w * r0.x;
  r0.x = exp2(r0.x);
  r0.y = saturate(dot(r1.xyz, cb0[3].xyz));
  r0.y = log2(r0.y);
  r0.y = cb1[5].x * r0.y;
  r0.y = exp2(r0.y);
  r1.xyz = cb0[4].xyz * cb0[3].www;
  r0.yzw = r1.xyz * r0.yyy;
  r1.xyz = r1.xyz * r0.xxx;
  r1.xyz = cb1[7].zzz * r1.xyz;
  r0.xyz = r0.yzw * cb1[1].www + r1.xyz;
  r0.xyz = r0.xyz * r5.www + r2.xyz;
  r1.xyz = v1.xyz + -r0.xyz;
  r0.xyz = v1.www * r1.xyz + r0.xyz;
  r0.w = cb0[1].w;
  o0.xyz = saturate(r0.xyz * r0.www);
  o0.w = saturate(0);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy  
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 2   xyzw        4     NONE   float   xy  
// TEXCOORD                 5   xyzw        5     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[5], immediateIndexed
dcl_constantbuffer cb1[14], immediateIndexed
dcl_constantbuffer cb2[6], immediateIndexed
dcl_sampler s1, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s5, mode_default
dcl_sampler s6, 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) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t7
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 v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xy
dcl_input_ps linear v5.xyz
dcl_output o0.xyzw
dcl_temps 8
sample_indexable(texture2d)(float,float,float,float) r0.xyz, v3.xyxx, t4.xyzw, s4
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -2.000000, 0.000000)
mad r0.xyz, cb1[6].xxxx, r0.xyzx, l(0.000000, 0.000000, 1.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r1.xyz, v3.zwzz, t5.xyzw, s5
mad r1.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mad r0.xyz, cb1[6].yyyy, r1.xyzx, r0.xyzx
sample_indexable(texture2d)(float,float,float,float) r1.xyz, v4.xyxx, t6.xyzw, s6
mad r1.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mad r0.xyz, cb1[6].zzzz, r1.xyzx, r0.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mad r0.xyz, r0.xyzx, r0.wwww, l(-0.000000, -0.000000, -1.000000, 0.000000)
mov r1.zw, l(0,0,0,0)
mul r2.xy, v0.xyxx, cb12[44].xyxx
mul r2.zw, r2.xxxy, cb12[43].xxxy
ftoi r1.xy, r2.zwzz
ld_indexable(texture2d)(float,float,float,float) r0.w, r1.xyzw, t7.yzwx
mad r0.w, -r0.w, cb0[2].z, cb0[2].x
div r1.z, cb0[2].w, r0.w
mad r3.xy, r2.xyxx, cb0[0].xyxx, cb0[0].zwzz
mad r2.zw, r3.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
mul r2.zw, r1.zzzz, r2.zzzw
div r1.xy, r2.zwzz, cb2[5].xyxx
dp3 r0.w, r1.xyzx, r1.xyzx
sqrt r0.w, r0.w
dp3 r1.x, v2.xyzx, v2.xyzx
rsq r1.x, r1.x
mul r1.xyz, r1.xxxx, v2.xyzx
mul r4.xyz, r0.wwww, -r1.xyzx
dp3 r0.w, r4.xyzx, cb2[4].xyzx
dp3 r1.w, r4.xyzx, r4.xyzx
sqrt r1.w, r1.w
div r2.z, cb2[4].w, r0.w
add r2.z, -r2.z, l(1.000000)
mul r0.w, |r0.w|, r2.z
mul r1.w, r1.w, r2.z
div_sat r4.xy, r1.wwww, cb1[10].zzzz
div_sat r4.zw, r0.wwww, cb1[10].zzzz
add r5.xyzw, r4.xyzw, l(-1.000000, -1.000000, -1.000000, -1.000000)
mad r5.xyzw, cb1[11].xyzw, r5.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
mad r0.xyz, r5.zzzz, r0.xyzx, l(0.000000, 0.000000, 1.000000, 0.000000)
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r0.w, r5.y, cb1[5].w
mad r6.xy, r0.wwww, r0.xyxx, v5.xyxx
mov r6.z, v5.z
mov r6.w, l(1.000000)
dp4 r0.w, cb2[1].xyzw, r6.xyzw
dp4 r7.z, cb2[3].xyzw, r6.xyzw
dp4 r7.x, cb2[0].xyzw, r6.xyzw
add r7.y, -r0.w, r7.z
div r2.zw, r7.xxxy, r7.zzzz
div r4.xz, r2.zzwz, cb0[0].xxyx
add r2.zw, r2.zzzw, cb0[0].zzzw
mad r2.zw, r2.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
mul r4.xz, r4.xxzx, cb12[43].xxyx
ftoi r6.xy, r4.xzxx
mov r6.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r0.w, r6.xyzw, t7.yzwx
mad r0.w, -r0.w, cb0[2].z, cb0[2].x
div r6.z, cb0[2].w, r0.w
mul r2.zw, r2.zzzw, r6.zzzz
div r6.xy, r2.zwzz, cb2[5].xyxx
dp3 r0.w, r6.xyzx, r6.xyzx
sqrt r0.w, r0.w
mul r4.xzw, r0.wwww, -r1.xxyz
dp3 r0.w, r4.xzwx, cb2[4].xyzx
lt r1.w, l(0.000000), r0.w
lt r2.z, r0.w, l(0.000000)
div r0.w, cb2[4].w, r0.w
add r0.w, -r0.w, l(1.000000)
iadd r1.w, -r1.w, r2.z
itof r1.w, r1.w
mul r0.w, r0.w, r1.w
lt r0.w, r0.w, l(0.000000)
mov r3.z, l(1.000000)
movc r3.xyz, r0.wwww, r3.xyzx, r7.xyzx
div r2.zw, r3.xxxy, r3.zzzz
mul r2.zw, r2.zzzw, cb12[43].xxxy
max r2.zw, r2.zzzw, l(0.000000, 0.000000, 0.000000, 0.000000)
mov r3.x, cb12[44].z
mov r3.y, cb12[43].y
min r2.zw, r2.zzzw, r3.xxxy
sample_indexable(texture2d)(float,float,float,float) r4.xzw, r2.zwzz, t1.xwyz, s1
add r6.xyz, -cb1[0].xyzx, cb1[1].xyzx
mad r6.xyz, r4.yyyy, r6.xyzx, cb1[0].xyzx
mad r0.w, -r4.y, cb1[10].z, cb1[10].z
div_sat r0.w, r0.w, cb1[10].w
log r0.w, r0.w
mul r0.w, r0.w, cb1[8].w
exp r0.w, r0.w
add r0.w, -r0.w, l(1.000000)
mad r6.xyz, -r4.xzwx, cb1[7].wwww, r6.xyzx
mul r4.xyz, r4.xzwx, cb1[7].wwww
mad r4.xyz, r0.wwww, r6.xyzx, r4.xyzx
mul r2.zw, r0.xxxy, cb1[13].xxxx
mad r2.xy, r2.xyxx, cb1[12].zwzz, r2.zwzz
mul r2.xy, r2.xyxx, cb12[43].xyxx
max r2.xy, r2.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
min r2.xy, r3.xyxx, r2.xyxx
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r2.xyxx, t10.xyzw, s10
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.xyxx, t11.xyzw, s11
add r3.xyzw, -r2.xyzw, r3.xyzw
mad r2.xyzw, cb1[12].yyyy, r3.xyzw, r2.xyzw
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 r0.w, r1.xyzx, r3.xyzx
add r0.w, r0.w, r0.w
mad r3.xyz, r3.xyzx, -r0.wwww, r1.xyzx
sample_indexable(texturecube)(float,float,float,float) r3.xyz, r3.xyzx, t3.xyzw, s3
mad r2.xyz, -r3.xyzx, cb1[7].wwww, r2.xyzx
mul r3.xyz, r3.xyzx, cb1[7].wwww
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
mul r1.w, r0.w, cb1[12].x
mul_sat r1.w, r1.w, r2.w
mad r2.xyz, r1.wwww, r2.xyzx, r3.xyzx
add r2.xyz, r2.xyzx, -cb1[2].xyzx
mad r2.xyz, cb1[5].yyyy, r2.xyzx, cb1[2].xyzx
add r2.xyz, -r4.xyzx, r2.xyzx
dp3_sat r1.w, -r1.xyzx, r0.xyzx
add r1.w, -r1.w, l(1.000000)
mul r2.w, r1.w, r1.w
mul r2.w, r2.w, r2.w
mul r1.w, r1.w, r2.w
add r2.w, -cb1[3].x, l(1.000000)
mad r1.w, r2.w, r1.w, cb1[3].x
mad r1.w, r1.w, r5.x, l(-1.000000)
mad r0.w, r0.w, r1.w, l(1.000000)
mad r2.xyz, r0.wwww, r2.xyzx, r4.xyzx
dp3 r0.w, r1.xyzx, r0.xyzx
add r0.w, r0.w, r0.w
mad r1.xyz, r0.xyzx, -r0.wwww, r1.xyzx
dp3_sat r0.x, r0.xyzx, l(-0.099000, -0.099000, 0.990000, 0.000000)
log r0.x, r0.x
mul r0.x, r0.x, cb1[0].w
exp r0.x, r0.x
dp3_sat r0.y, r1.xyzx, cb0[3].xyzx
log r0.y, r0.y
mul r0.y, r0.y, cb1[5].x
exp r0.y, r0.y
mul r1.xyz, cb0[3].wwww, cb0[4].xyzx
mul r0.yzw, r0.yyyy, r1.xxyz
mul r1.xyz, r0.xxxx, r1.xyzx
mul r1.xyz, r1.xyzx, cb1[7].zzzz
mad r0.xyz, r0.yzwy, cb1[1].wwww, r1.xyzx
mad r0.xyz, r0.xyzx, r5.wwww, r2.xyzx
add r1.xyz, -r0.xyzx, v1.xyzx
mad r0.xyz, v1.wwww, r1.xyzx, r0.xyzx
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

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