// water reflexion

cbuffer _Globals : register(b0)
{
  float4x4 g_mCloudsShadowsSpace : packoffset(c0);
  float4 g_vCloudsShadowDesc : packoffset(c4);
  float4 g_vKSettings : packoffset(c5);
  float4x4 g_mPrevObjViewProj : packoffset(c6);
  float4 SmoothOffs : packoffset(c10) = {0.0009765625,0.0009765625,1,1};
  float4x4 LightSpace : packoffset(c11);
  float4 ShadowsDesc : packoffset(c15);
  float4 specColor : packoffset(c16);
  float4 ControlData : packoffset(c17);
  float4 difColor : packoffset(c18);
  float4 ambient : packoffset(c19);
  float4 g_vDefLightDir : packoffset(c20);
  float4 g_vDefLightColor : packoffset(c21);
  float4 g_vDefSpecColor : packoffset(c22);
uint CS_FRONT : packoffset(c23) = 0x00000000;  
uint CS_RIGHT : packoffset(c23) =  = 0x00000001;    
uint CS_BACK : packoffset(c23) = 0x00000002; 
uint CS_LEFT : packoffset(c23) = 0x00000003;
uint CS_TOP : packoffset(c24) = 0x00000004;
uint CS_BOTTOM : packoffset(c24) = 0x00000005;
  float4 g_vAmbientSettings : packoffset(c25);
  float4 g_vScreenDepthRect : packoffset(c26);

  struct
  {
    float4 vDesc;
    float4 vFogLayerPlane;
    float4 vFogLayerColor;
    float4 vFogLayerSettings;
    float4 vFogColor;
    float4 vFogDistance;
  } g_FogDesc : packoffset(c27);

  float4 g_vForestPlaneThreshold : packoffset(c33) = {1300,0.00200000009,0,0};
  float4 LowDeepColor : packoffset(c34) = {0.300000012,0.400000006,0.400000006,0};
  float4 SeaColor : packoffset(c35) = {0.100000001,0.300000012,0.300000012,0};
  float4 DetailScale : packoffset(c36) = {1,1,1,1};
  float4 g_vIceScale : packoffset(c37) = {1,1,1,1};
  float4 g_vSpecSettings : packoffset(c38) = {1,1,1,1};
  float4 g_vSeaCorrection : packoffset(c39);
  float4 g_vSeaDesc : packoffset(c40) = {0.400000006,0.600000024,4,0.980000019};
  float4 g_vSeaHarmonics : packoffset(c41) = {1,1,1,1};
  float4 WaterDesc : packoffset(c42) = {0.400000006,0.600000024,4,0.980000019};
  float4 g_vWaterColor : packoffset(c43) = {1,0,0,0};
  float4 g_vWaterSpecColor : packoffset(c44) = {1,1,1,80};
  float4 Anim : packoffset(c45);
  float4 g_vAsyncTextureSize : packoffset(c46) = {1,1,0,0};
  float4 g_vRTTexSize : packoffset(c47);
  float4 g_vAnisotropy : packoffset(c48);
  float2 TexelOffs[9] : packoffset(c49) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};



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


void main( 
  float2 v0 : COLOR0,
  uint2 v1 : SV_VertexID0,
  uint2 v2 : SV_InstanceID0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float2 o2 : TEXCOORD1,
  out float2 p2 : TEXCOORD2)
{
// Needs manual fix for instruction: 
// unknown dcl_:             dcl_input_sgv v1.x, vertex_id
// Needs manual fix for instruction: 
// unknown dcl_:             dcl_input_sgv v2.x, instance_id
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

              r0.xy = v0.yx * float2(255,255) + float2(0.5,0.5);
              r0.xy = (uint2)r0.xy;
              r0.x = (uint)r0.x << 8;
              r0.x = (int)r0.x + (int)r0.y;
              r0.y = cmp(0x00008000 < (int)r0.x);
              if (r0.y != 0) {
                r0.x = (int)r0.x + 0xffff0000;
              }
              r0.x = (int)r0.x;
              r0.y = (int)cb0[82].x;
              r0.z = cmp((int)v1.x >= (int)r0.y);
              if (r0.z != 0) {
                r1.xyz = (int3)r0.yyy + int3(16,32,48);
                r0.zw = cmp((int2)v1.xx < (int2)r1.xy);
                if (r0.z != 0) {
                  r0.z = (int)v1.x + (int)-r0.y;
                  r0.z = (int)r0.z;
                  r0.z = cb0[82].y * r0.z;
                  r2.y = r0.z * 50 + cb0[82].w;
                  r2.x = cb0[82].z;
                } else {
                  r2.xy = float2(0,0);
                }
                r0.z = cmp((int)v1.x >= (int)r1.x);
                r0.z = r0.w ? r0.z : 0;
                if (r0.z != 0) {
                  r0.z = (int)v1.x + -16;
                  r0.w = (int)r0.z + (int)-r0.y;
                  r0.w = (int)r0.w;
                  r0.w = cb0[82].y * r0.w;
                  r2.x = r0.w * 50 + cb0[82].z;
                  r2.y = cb0[82].w;
                } else {
                  r0.z = v1.x;
                }
                r0.w = cmp((int)r0.z >= (int)r1.z);
                if (r0.w != 0) {
                  r0.z = (int)r0.z + -48;
                  r0.w = (int)r0.z + (int)-r0.y;
                  r0.w = (int)r0.w;
                  r0.w = cb0[82].y * r0.w;
                  r2.y = r0.w * 50 + cb0[82].w;
                  r0.w = cb0[82].y * 800 + cb0[82].z;
                  r2.x = cb0[82].y + r0.w;
                }
                r0.w = cmp((int)r0.z >= (int)r1.y);
                r1.x = cmp((int)r0.z < (int)r1.z);
                r0.w = r0.w ? r1.x : 0;
                if (r0.w != 0) {
                  r0.z = (int)r0.z + -32;
                  r0.y = (int)r0.z + (int)-r0.y;
                  r0.y = (int)r0.y;
                  r0.y = cb0[82].y * r0.y;
                  r2.x = r0.y * 50 + cb0[82].z;
                  r0.y = cb0[82].y * 800 + cb0[82].w;
                  r2.y = cb0[82].y + r0.y;
                }
              } else {
                r0.y = (int)v1.x ^ 257;
                r0.z = max((int)-v1.x, (int)v1.x);
                uiDest.z = (uint)r0.z / 257;
                r0.z = uiDest.z;
                r0.w = -(int)r0.z;
                r0.y = (int)r0.y & 0x80000000;
                r0.y = r0.y ? r0.w : r0.z;
                r1.y = (int)r0.y;
                r0.y = mad((int)r0.y, -257, (int)v1.x);
                r1.x = (int)r0.y;
                r2.xy = float2(50,50) * r1.xy;
              }
              r2.z = cb0[90].z * r0.x;
              r0.xyz = cb0[80].xyzx + r2.xzy;
              r1.x = (uint)v2.x;
              r1.x = cb0[90].w * r1.x;
              r1.x = 0.5 * r1.x;
              r1.x = max(0.100000001, r1.x);
              r0.y = r1.x + r0.y;
              r0.w = 1;
              o0.x = dot(r0.xyzw, cb0[67].xyzw);
              o0.y = dot(r0.xyzw, cb0[68].xyzw);
              o0.z = dot(r0.xyzw, cb0[69].xyzw);
              o0.w = dot(r0.xyzw, cb0[70].xyzw);
              r1.xy = cb0[89].xyxx + r2.xy;
              r1.xy = r1.xy / cb0[90].xyxx;
              r1.zw = cb0[88].xxxy + cb0[87].xxxy;
              o2.xy = r1.xy * r1.zw + cb0[87].xyxx;
              r0.w = g_vAsyncTextureSize.x * r2.y;
              r1.x = -r2.x * 7.81249983e-005 + 1;
              r1.z = 7.81249983e-005 * r0.w;
              r1.w = g_vAsyncTextureSize.y * r1.x;
              p2.xy = g_vAsyncTextureSize.zw + r1.zw;
              o1.xyz = r0.xyz;
              return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.57 on Sun Jun 18 17:07:52 2017
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4x4 g_mCloudsShadowsSpace;    // Offset:    0 Size:    64 [unused]
//   float4 g_vCloudsShadowDesc;        // Offset:   64 Size:    16 [unused]
//   float4 g_vKSettings;               // Offset:   80 Size:    16 [unused]
//   float4x4 g_mPrevObjViewProj;       // Offset:   96 Size:    64 [unused]
//   float4 SmoothOffs;                 // Offset:  160 Size:    16 [unused]
//      = 0x3a800000 0x3a800000 0x3f800000 0x3f800000 
//   float4x4 LightSpace;               // Offset:  176 Size:    64 [unused]
//   float4 ShadowsDesc;                // Offset:  240 Size:    16 [unused]
//   float4 specColor;                  // Offset:  256 Size:    16 [unused]
//   float4 ControlData;                // Offset:  272 Size:    16 [unused]
//   float4 difColor;                   // Offset:  288 Size:    16 [unused]
//   float4 ambient;                    // Offset:  304 Size:    16 [unused]
//   float4 g_vDefLightDir;             // Offset:  320 Size:    16 [unused]
//   float4 g_vDefLightColor;           // Offset:  336 Size:    16 [unused]
//   float4 g_vDefSpecColor;            // Offset:  352 Size:    16 [unused]
//   uint CS_FRONT;                     // Offset:  368 Size:     4 [unused]
//      = 0x00000000 
//   uint CS_RIGHT;                     // Offset:  372 Size:     4 [unused]
//      = 0x00000001 
//   uint CS_BACK;                      // Offset:  376 Size:     4 [unused]
//      = 0x00000002 
//   uint CS_LEFT;                      // Offset:  380 Size:     4 [unused]
//      = 0x00000003 
//   uint CS_TOP;                       // Offset:  384 Size:     4 [unused]
//      = 0x00000004 
//   uint CS_BOTTOM;                    // Offset:  388 Size:     4 [unused]
//      = 0x00000005 
//   float4 g_vAmbientSettings;         // Offset:  400 Size:    16 [unused]
//   float4 g_vScreenDepthRect;         // Offset:  416 Size:    16 [unused]
//   
//   struct
//   {
//       
//       float4 vDesc;                  // Offset:  432
//       float4 vFogLayerPlane;         // Offset:  448
//       float4 vFogLayerColor;         // Offset:  464
//       float4 vFogLayerSettings;      // Offset:  480
//       float4 vFogColor;              // Offset:  496
//       float4 vFogDistance;           // Offset:  512
//
//   } g_FogDesc;                       // Offset:  432 Size:    96 [unused]
//   float4 g_vForestPlaneThreshold;    // Offset:  528 Size:    16 [unused]
//      = 0x44a28000 0x3b03126f 0x00000000 0x00000000 
//   float4 LowDeepColor;               // Offset:  544 Size:    16 [unused]
//      = 0x3e99999a 0x3ecccccd 0x3ecccccd 0x00000000 
//   float4 SeaColor;                   // Offset:  560 Size:    16 [unused]
//      = 0x3dcccccd 0x3e99999a 0x3e99999a 0x00000000 
//   float4 DetailScale;                // Offset:  576 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 g_vIceScale;                // Offset:  592 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 g_vSpecSettings;            // Offset:  608 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 g_vSeaCorrection;           // Offset:  624 Size:    16 [unused]
//   float4 g_vSeaDesc;                 // Offset:  640 Size:    16 [unused]
//      = 0x3ecccccd 0x3f19999a 0x40800000 0x3f7ae148 
//   float4 g_vSeaHarmonics;            // Offset:  656 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 WaterDesc;                  // Offset:  672 Size:    16 [unused]
//      = 0x3ecccccd 0x3f19999a 0x40800000 0x3f7ae148 
//   float4 g_vWaterColor;              // Offset:  688 Size:    16 [unused]
//      = 0x3f800000 0x00000000 0x00000000 0x00000000 
//   float4 g_vWaterSpecColor;          // Offset:  704 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x42a00000 
//   float4 Anim;                       // Offset:  720 Size:    16 [unused]
//   float4 g_vAsyncTextureSize;        // Offset:  736 Size:    16
//      = 0x3f800000 0x3f800000 0x00000000 0x00000000 
//   float4 g_vRTTexSize;               // Offset:  752 Size:    16 [unused]
//   float4 g_vAnisotropy;              // Offset:  768 Size:    16 [unused]
//   float2 TexelOffs[9];               // Offset:  784 Size:   136 [unused]
//      = 0x00000000 0x00000000 0x00000000 0x00000000 
//        0xba800000 0x00000000 0x00000000 0x00000000 
//        0x3a800000 0x00000000 0x00000000 0x00000000 
//        0x00000000 0xba800000 0x00000000 0x00000000 
//        0x00000000 0x3a800000 0x00000000 0x00000000 
//        0xbb000000 0xbb000000 0x00000000 0x00000000 
//        0x3b000000 0xbb000000 0x00000000 0x00000000 
//        0x3b000000 0x3b000000 0x00000000 0x00000000 
//        0xbb000000 0x3b000000 
//   float4 g_avGroundColor[9];         // Offset:  928 Size:   144 [unused]
//   float4x4 g_mWorldViewProjection;   // Offset: 1072 Size:    64
//   float4x4 g_mView;                  // Offset: 1136 Size:    64 [unused]
//   float4x4 g_mWorldView;             // Offset: 1200 Size:    64 [unused]
//   float3 chunkColor;                 // Offset: 1264 Size:    12 [unused]
//   float3 g_deltaCam;                 // Offset: 1280 Size:    12
//   float4 mapSize;                    // Offset: 1296 Size:    16 [unused]
//   float4 skirtInfo;                  // Offset: 1312 Size:    16
//   float4x4 g_textureRotation;        // Offset: 1328 Size:    64 [unused]
//   float3 textureCoordsP1;            // Offset: 1392 Size:    12
//   float3 textureCoordsP2;            // Offset: 1408 Size:    12
//   float3 chunkInSectorCoords;        // Offset: 1424 Size:    12
//   float4 chunkInfo;                  // Offset: 1440 Size:    16
//   float4 g_vSettings;                // Offset: 1456 Size:    16 [unused]
//   float4 g_vPlaneSettings;           // Offset: 1472 Size:    16 [unused]
//   float4 g_vPlaneOffset;             // Offset: 1488 Size:    16 [unused]
//   float3 GrayK;                      // Offset: 1504 Size:    12 [unused]
//      = 0x3eaa7efa 0x3eaa7efa 0x3eaa7efa 
//   float4 g_vForestFarSettings;       // Offset: 1520 Size:    16 [unused]
//   float4 DetailOffset;               // Offset: 1536 Size:    16 [unused]
//   float4 DetailSectorOffset;         // Offset: 1552 Size:    16 [unused]
//   float4 DetailSettings;             // Offset: 1568 Size:    16 [unused]
//   float4 ParalaxSettings;            // Offset: 1584 Size:    16 [unused]
//      = 0x3e19999a 0x3f800000 0x43480000 0x00000000 
//   float4 DetailH[64];                // Offset: 1600 Size:  1024 [unused]
//   float4 DetailRTCoords;             // Offset: 2624 Size:    16 [unused]
//   float4 g_vPRTSettings;             // Offset: 2640 Size:    16 [unused]
//      = 0x00000000 0x00000000 0x42480000 0x3a000000 
//   float4 g_avMask[4];                // Offset: 2656 Size:    64 [unused]
//      = 0x3f800000 0x00000000 0x00000000 0x00000000 
//        0x00000000 0x3f800000 0x00000000 0x00000000 
//        0x00000000 0x00000000 0x3f800000 0x00000000 
//        0x00000000 0x00000000 0x00000000 0x3f800000 
//   float4 g_avPRTMask[4];             // Offset: 2720 Size:    64 [unused]
//      = 0x3f800000 0x00000000 0x00000000 0x00000000 
//        0x00000000 0x3f800000 0x00000000 0x00000000 
//        0x00000000 0x00000000 0x3f800000 0x00000000 
//        0x00000000 0x00000000 0x00000000 0x3f800000 
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// COLOR                    0   xy          0     NONE   float   xy  
// SV_VertexID              0   x           1   VERTID    uint   x   
// SV_InstanceID            0   x           2   INSTID    uint   x   
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyz         1     NONE   float   xyz 
// TEXCOORD                 1   xy          2     NONE   float   xy  
// TEXCOORD                 2     zw        2     NONE   float     zw
//
vs_4_0
dcl_constantbuffer cb0[91], immediateIndexed
dcl_input v0.xy
dcl_input_sgv v1.x, vertex_id
dcl_input_sgv v2.x, instance_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xyz
dcl_output o2.xy
dcl_output o2.zw
dcl_temps 3
mad r0.xy, v0.yxyy, l(255.000000, 255.000000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
ftou r0.xy, r0.xyxx
ishl r0.x, r0.x, l(8)
iadd r0.x, r0.x, r0.y
ilt r0.y, l(0x00008000), r0.x
if_nz r0.y
  iadd r0.x, r0.x, l(0xffff0000)
endif 
itof r0.x, r0.x
ftoi r0.y, cb0[82].x
ige r0.z, v1.x, r0.y
if_nz r0.z
  iadd r1.xyz, r0.yyyy, l(16, 32, 48, 0)
  ilt r0.zw, v1.xxxx, r1.xxxy
  if_nz r0.z
    iadd r0.z, v1.x, -r0.y
    itof r0.z, r0.z
    mul r0.z, r0.z, cb0[82].y
    mad r2.y, r0.z, l(50.000000), cb0[82].w
    mov r2.x, cb0[82].z
  else 
    mov r2.xy, l(0,0,0,0)
  endif 
  ige r0.z, v1.x, r1.x
  and r0.z, r0.w, r0.z
  if_nz r0.z
    iadd r0.z, v1.x, l(-16)
    iadd r0.w, r0.z, -r0.y
    itof r0.w, r0.w
    mul r0.w, r0.w, cb0[82].y
    mad r2.x, r0.w, l(50.000000), cb0[82].z
    mov r2.y, cb0[82].w
  else 
    mov r0.z, v1.x
  endif 
  ige r0.w, r0.z, r1.z
  if_nz r0.w
    iadd r0.z, r0.z, l(-48)
    iadd r0.w, r0.z, -r0.y
    itof r0.w, r0.w
    mul r0.w, r0.w, cb0[82].y
    mad r2.y, r0.w, l(50.000000), cb0[82].w
    mad r0.w, cb0[82].y, l(800.000000), cb0[82].z
    add r2.x, r0.w, -cb0[82].y
  endif 
  ige r0.w, r0.z, r1.y
  ilt r1.x, r0.z, r1.z
  and r0.w, r0.w, r1.x
  if_nz r0.w
    iadd r0.z, r0.z, l(-32)
    iadd r0.y, r0.z, -r0.y
    itof r0.y, r0.y
    mul r0.y, r0.y, cb0[82].y
    mad r2.x, r0.y, l(50.000000), cb0[82].z
    mad r0.y, cb0[82].y, l(800.000000), cb0[82].w
    add r2.y, r0.y, -cb0[82].y
  endif 
else 
  xor r0.y, v1.x, l(257)
  imax r0.z, v1.x, -v1.x
  udiv r0.z, null, r0.z, l(257)
  ineg r0.w, r0.z
  and r0.y, r0.y, l(0x80000000)
  movc r0.y, r0.y, r0.w, r0.z
  itof r1.y, r0.y
  imad r0.y, r0.y, l(-257), v1.x
  itof r1.x, r0.y
  mul r2.xy, r1.xyxx, l(50.000000, 50.000000, 0.000000, 0.000000)
endif 
mul r2.z, r0.x, cb0[90].z
add r0.xyz, r2.xzyx, cb0[80].xyzx
utof r1.x, v2.x
mul r1.x, r1.x, cb0[90].w
mul r1.x, r1.x, l(0.500000)
max r1.x, r1.x, l(0.100000)
add r0.y, r0.y, r1.x
mov r0.w, l(1.000000)
dp4 o0.x, r0.xyzw, cb0[67].xyzw
dp4 o0.y, r0.xyzw, cb0[68].xyzw
dp4 o0.z, r0.xyzw, cb0[69].xyzw
dp4 o0.w, r0.xyzw, cb0[70].xyzw
add r1.xy, r2.xyxx, -cb0[89].xyxx
div r1.xy, r1.xyxx, cb0[90].xyxx
add r1.zw, -cb0[87].xxxy, cb0[88].xxxy
mad o2.xy, r1.xyxx, r1.zwzz, cb0[87].xyxx
mul r0.w, r2.y, cb0[46].x
mad r1.x, -r2.x, l(0.0000781249983), l(1.000000)
mul r1.z, r0.w, l(0.0000781249983)
mul r1.w, r1.x, cb0[46].y
add o2.zw, r1.zzzw, cb0[46].zzzw
mov o1.xyz, r0.xyzx
ret 
// Approximately 92 instruction slots used

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