//water reflections on walls
// ---- Created with 3Dmigoto v1.2.39 on Sun Jun 26 04:14:51 2016

cbuffer _Globals : register(b0)
{
  float4x4 ScreenToWorldMatrix : packoffset(c0);
  bool bDecompressSceneColor : packoffset(c4);
  float4 PackedParameters : packoffset(c5);
  float4 MinMaxBlurClamp : packoffset(c6);
  float4 LightColorAndFalloffExponent : packoffset(c7);
  float3 DistanceFieldParameters : packoffset(c8);
  float4x4 ScreenToShadowMatrix : packoffset(c9);
  float4 ShadowBufferAndTexelSize : packoffset(c13);
  float ShadowOverrideFactor : packoffset(c14);
  float SSSMultiplier : packoffset(c14.y);
  bool bReceiveDynamicShadows : packoffset(c14.z);
  bool bEnableDistanceShadowFading : packoffset(c14.w);
  float2 DistanceFadeParameters : packoffset(c15);
  float4 IBLPositionAndWeight0 : packoffset(c16);
  float4 IBLPositionAndWeight1 : packoffset(c17);
  float4 IBLPositionAndWeight2 : packoffset(c18);
  float4 IBLPositionAndWeight3 : packoffset(c19);
  float4x4 IBLProxyOBB0 : packoffset(c20);
  float4x4 IBLProxyOBB1 : packoffset(c24);
  float4x4 IBLProxyOBB2 : packoffset(c28);
  float4 IBLUseProxyVolume : packoffset(c32);
  float4x4 IBLLastProxyOBB0 : packoffset(c33);
  float4x4 IBLLastProxyOBB1 : packoffset(c37);
  float4x4 IBLLastProxyOBB2 : packoffset(c41);
  float4 IBLUseLastProxyVolume : packoffset(c45);
  float ForcedIBLWeight : packoffset(c46);
  float AdditionalReflections : packoffset(c46.y);
  float4x4 InvViewProjectionMatrix : packoffset(c47);
  float3 CameraWorldPos : packoffset(c51);
  float3 ActorWorldPos : packoffset(c52);
  float4 ObjectWorldPositionAndRadius : packoffset(c53);
  float3 ObjectOrientation : packoffset(c54);
  float3 ObjectPostProjectionPosition : packoffset(c55);
  float3 ObjectNDCPosition : packoffset(c56);
  float4 ObjectMacroUVScales : packoffset(c57);
  float3 FoliageImpulseDirection : packoffset(c58);
  float4 FoliageNormalizedRotationAxisAndAngle : packoffset(c59);
  float4 WindDirectionAndSpeed : packoffset(c60);
  float3x3 LocalToWorldMatrix : packoffset(c61);
  float3x3 WorldToLocalMatrix : packoffset(c64);
  float3x3 WorldToViewMatrix : packoffset(c67);
  float3x3 ViewToWorldMatrix : packoffset(c70);
  float4 UniformPixelVector_0 : packoffset(c73);
  float4 UniformPixelVector_1 : packoffset(c74);
  float4 UniformPixelVector_2 : packoffset(c75);
  float4 UniformPixelVector_3 : packoffset(c76);
  float4 UniformPixelVector_4 : packoffset(c77);
  float4 UniformPixelVector_5 : packoffset(c78);
  float4 UniformPixelVector_6 : packoffset(c79);
  float4 UniformPixelScalars_0 : packoffset(c80);
  float4 UniformPixelScalars_1 : packoffset(c81);
  float4 UniformPixelScalars_2 : packoffset(c82);
  float4 UniformPixelScalars_3 : packoffset(c83);
  float4 UniformPixelScalars_4 : packoffset(c84);
  float3 TemporalAAParameters : packoffset(c85);
  float4x4 ScreenToLight : packoffset(c86);
  float2 LightFunctionParameters : packoffset(c90);
}

cbuffer PSOffsetConstants : register(b2)
{
  float4 ScreenPositionScaleBias : packoffset(c0);
  float4 MinZ_MaxZRatio : packoffset(c1);
  float NvStereoEnabled : packoffset(c2);
  float4 DiffuseOverrideParameter : packoffset(c3);
  float4 SpecularOverrideParameter : packoffset(c4);
  float4 CameraPositionPS : packoffset(c5);
  float4 ScreenAndTexelSize : packoffset(c6);
}

SamplerState SceneDepthTextureSampler_s : register(s0);
SamplerState NvStereoFixTextureSampler_s : register(s1);
SamplerState PixelTexture2D_0Sampler_s : register(s2);
Texture2D<float4> SceneDepthTexture : register(t0);
Texture2D<float4> NvStereoFixTexture : register(t1);
Texture2D<float4> PixelTexture2D_0 : register(t2);


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


void main( 
  float4 v0 : TEXCOORD0,
  float4 v1 : SV_POSITION0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r12,r20;
  uint4 bitmask, uiDest;
  float4 fDest;


r20.xyw = v0.xyw;
float4 stereo = StereoParams.Load(0);
r20.x += stereo.x*(r20.w - stereo.y);

  r0.x = cmp(0 != NvStereoEnabled);
  if (r0.x != 0) {
    r0.yz = NvStereoFixTexture.Sample(NvStereoFixTextureSampler_s, float2(0.0625,0)).xy;
    r0.z = v0.w + -r0.z;
    r1.x = r0.y * r0.z + v0.x;
    r1.yz = v0.yw;
  }
  r0.xyz = r0.xxx ? r1.xyz : v0.xyw;
  r0.xy = r0.xy / r0.zz;
  r0.xy = r0.xy * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r0.x = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r0.xy, 0).x;
  r0.x = min(0.999000013, r0.x);
  r0.x = r0.x * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
  r0.x = 1 / r0.x;
  r0.yz = r20.xy / v0.ww;
  r0.yz = r0.yz * r0.xx;

//float4 stereo = StereoParams.Load(0);
r0.y -= stereo.x*(r0.x - stereo.y);

  r1.xyz = ScreenToLight._m01_m11_m31 * r0.zzz;
  r0.yzw = ScreenToLight._m00_m10_m30 * r0.yyy + r1.xyz;
  r0.xyz = ScreenToLight._m02_m12_m32 * r0.xxx + r0.yzw;
  r0.xyz = ScreenToLight._m03_m13_m33 + r0.xyz;
  r0.xy = r0.xy / r0.zz;
  r0.zw = float2(-0.0500000007,0.0799999982) + r0.xy;
  r1.x = dot(UniformPixelVector_1.xy, r0.zw);
  r1.y = dot(UniformPixelVector_2.xy, r0.zw);
  r0.zw = UniformPixelVector_3.xy + r1.xy;
  r0.zw = float2(0.0500000007,-0.0799999982) + r0.zw;
  r1.xyz = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, r0.zw, 0).xyz;
  r0.xy = r0.xy * float2(2,2) + float2(0.0799999982,-0.0500000007);
  r2.x = dot(UniformPixelVector_4.xy, r0.xy);
  r2.y = dot(UniformPixelVector_5.xy, r0.xy);
  r0.xy = UniformPixelVector_6.xy + r2.xy;
  r0.xy = float2(-0.0799999982,0.0500000007) + r0.xy;
  r0.xyz = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, r0.xy, 0).xyz;
  r0.xyz = r1.xyz + r0.xyz;
  r0.xyz = UniformPixelVector_0.xyz + r0.xyz;
  r0.w = dot(r0.xyz, float3(0.333000004,0.333000004,0.333000004));
  r1.xyz = r0.www + -r0.xyz;
  r0.xyz = LightFunctionParameters.xxx * r1.xyz + r0.xyz;
  r0.xyz = float3(-1,-1,-1) + r0.xyz;
  r0.xyz = LightFunctionParameters.yyy * r0.xyz + float3(1,1,1);
  o0.xyz = sqrt(r0.xyz);
  o0.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Sun Jun 26 04:14:51 2016
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4x4 ScreenToWorldMatrix;      // Offset:    0 Size:    64 [unused]
//   bool bDecompressSceneColor;        // Offset:   64 Size:     4 [unused]
//   float4 PackedParameters;           // Offset:   80 Size:    16 [unused]
//   float4 MinMaxBlurClamp;            // Offset:   96 Size:    16 [unused]
//   float4 LightColorAndFalloffExponent;// Offset:  112 Size:    16 [unused]
//   float3 DistanceFieldParameters;    // Offset:  128 Size:    12 [unused]
//   float4x4 ScreenToShadowMatrix;     // Offset:  144 Size:    64 [unused]
//   float4 ShadowBufferAndTexelSize;   // Offset:  208 Size:    16 [unused]
//   float ShadowOverrideFactor;        // Offset:  224 Size:     4 [unused]
//   float SSSMultiplier;               // Offset:  228 Size:     4 [unused]
//   bool bReceiveDynamicShadows;       // Offset:  232 Size:     4 [unused]
//   bool bEnableDistanceShadowFading;  // Offset:  236 Size:     4 [unused]
//   float2 DistanceFadeParameters;     // Offset:  240 Size:     8 [unused]
//   float4 IBLPositionAndWeight0;      // Offset:  256 Size:    16 [unused]
//   float4 IBLPositionAndWeight1;      // Offset:  272 Size:    16 [unused]
//   float4 IBLPositionAndWeight2;      // Offset:  288 Size:    16 [unused]
//   float4 IBLPositionAndWeight3;      // Offset:  304 Size:    16 [unused]
//   float4x4 IBLProxyOBB0;             // Offset:  320 Size:    64 [unused]
//   float4x4 IBLProxyOBB1;             // Offset:  384 Size:    64 [unused]
//   float4x4 IBLProxyOBB2;             // Offset:  448 Size:    64 [unused]
//   float4 IBLUseProxyVolume;          // Offset:  512 Size:    16 [unused]
//   float4x4 IBLLastProxyOBB0;         // Offset:  528 Size:    64 [unused]
//   float4x4 IBLLastProxyOBB1;         // Offset:  592 Size:    64 [unused]
//   float4x4 IBLLastProxyOBB2;         // Offset:  656 Size:    64 [unused]
//   float4 IBLUseLastProxyVolume;      // Offset:  720 Size:    16 [unused]
//   float ForcedIBLWeight;             // Offset:  736 Size:     4 [unused]
//   float AdditionalReflections;       // Offset:  740 Size:     4 [unused]
//   float4x4 InvViewProjectionMatrix;  // Offset:  752 Size:    64 [unused]
//   float3 CameraWorldPos;             // Offset:  816 Size:    12 [unused]
//   float3 ActorWorldPos;              // Offset:  832 Size:    12 [unused]
//   float4 ObjectWorldPositionAndRadius;// Offset:  848 Size:    16 [unused]
//   float3 ObjectOrientation;          // Offset:  864 Size:    12 [unused]
//   float3 ObjectPostProjectionPosition;// Offset:  880 Size:    12 [unused]
//   float3 ObjectNDCPosition;          // Offset:  896 Size:    12 [unused]
//   float4 ObjectMacroUVScales;        // Offset:  912 Size:    16 [unused]
//   float3 FoliageImpulseDirection;    // Offset:  928 Size:    12 [unused]
//   float4 FoliageNormalizedRotationAxisAndAngle;// Offset:  944 Size:    16 [unused]
//   float4 WindDirectionAndSpeed;      // Offset:  960 Size:    16 [unused]
//   float3x3 LocalToWorldMatrix;       // Offset:  976 Size:    44 [unused]
//   float3x3 WorldToLocalMatrix;       // Offset: 1024 Size:    44 [unused]
//   float3x3 WorldToViewMatrix;        // Offset: 1072 Size:    44 [unused]
//   float3x3 ViewToWorldMatrix;        // Offset: 1120 Size:    44 [unused]
//   float4 UniformPixelVector_0;       // Offset: 1168 Size:    16
//   float4 UniformPixelVector_1;       // Offset: 1184 Size:    16
//   float4 UniformPixelVector_2;       // Offset: 1200 Size:    16
//   float4 UniformPixelVector_3;       // Offset: 1216 Size:    16
//   float4 UniformPixelVector_4;       // Offset: 1232 Size:    16
//   float4 UniformPixelVector_5;       // Offset: 1248 Size:    16
//   float4 UniformPixelVector_6;       // Offset: 1264 Size:    16
//   float4 UniformPixelScalars_0;      // Offset: 1280 Size:    16 [unused]
//   float4 UniformPixelScalars_1;      // Offset: 1296 Size:    16 [unused]
//   float4 UniformPixelScalars_2;      // Offset: 1312 Size:    16 [unused]
//   float4 UniformPixelScalars_3;      // Offset: 1328 Size:    16 [unused]
//   float4 UniformPixelScalars_4;      // Offset: 1344 Size:    16 [unused]
//   float3 TemporalAAParameters;       // Offset: 1360 Size:    12 [unused]
//   float4x4 ScreenToLight;            // Offset: 1376 Size:    64
//   float2 LightFunctionParameters;    // Offset: 1440 Size:     8
//
// }
//
// cbuffer PSOffsetConstants
// {
//
//   float4 ScreenPositionScaleBias;    // Offset:    0 Size:    16
//   float4 MinZ_MaxZRatio;             // Offset:   16 Size:    16
//   float NvStereoEnabled;             // Offset:   32 Size:     4
//   float4 DiffuseOverrideParameter;   // Offset:   48 Size:    16 [unused]
//   float4 SpecularOverrideParameter;  // Offset:   64 Size:    16 [unused]
//   float4 CameraPositionPS;           // Offset:   80 Size:    16 [unused]
//   float4 ScreenAndTexelSize;         // Offset:   96 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SceneDepthTextureSampler          sampler      NA          NA    0        1
// NvStereoFixTextureSampler         sampler      NA          NA    1        1
// PixelTexture2D_0Sampler           sampler      NA          NA    2        1
// SceneDepthTexture                 texture  float4          2d    0        1
// NvStereoFixTexture                texture  float4          2d    1        1
// PixelTexture2D_0                  texture  float4          2d    2        1
// $Globals                          cbuffer      NA          NA    0        1
// PSOffsetConstants                 cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyzw        0     NONE   float   xy w
//
//
// 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[91], immediateIndexed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_input_ps linear v0.xyw
dcl_output o0.xyzw
dcl_temps 3
ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb2[2].x
if_nz r0.x
  sample_indexable(texture2d)(float,float,float,float) r0.yz, l(0.062500, 0.000000, 0.000000, 0.000000), t1.zxyw, s1
  add r0.z, -r0.z, v0.w
  mad r1.x, r0.y, r0.z, v0.x
  mov r1.yz, v0.yywy
endif 
movc r0.xyz, r0.xxxx, r1.xyzx, v0.xywx
div r0.xy, r0.xyxx, r0.zzzz
mad r0.xy, r0.xyxx, cb2[0].xyxx, cb2[0].wzww
sample_l_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t0.xyzw, s0, l(0.000000)
min r0.x, r0.x, l(0.999000)
mad r0.x, r0.x, cb2[1].z, -cb2[1].w
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x
div r0.yz, v0.xxyx, v0.wwww
mul r0.yz, r0.xxxx, r0.yyzy
mul r1.xyz, r0.zzzz, cb0[87].xywx
mad r0.yzw, cb0[86].xxyw, r0.yyyy, r1.xxyz
mad r0.xyz, cb0[88].xywx, r0.xxxx, r0.yzwy
add r0.xyz, r0.xyzx, cb0[89].xywx
div r0.xy, r0.xyxx, r0.zzzz
add r0.zw, r0.xxxy, l(0.000000, 0.000000, -0.050000, 0.080000)
dp2 r1.x, cb0[74].xyxx, r0.zwzz
dp2 r1.y, cb0[75].xyxx, r0.zwzz
add r0.zw, r1.xxxy, cb0[76].xxxy
add r0.zw, r0.zzzw, l(0.000000, 0.000000, 0.050000, -0.080000)
sample_b_indexable(texture2d)(float,float,float,float) r1.xyz, r0.zwzz, t2.xyzw, s2, l(0.000000)
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(0.080000, -0.050000, 0.000000, 0.000000)
dp2 r2.x, cb0[77].xyxx, r0.xyxx
dp2 r2.y, cb0[78].xyxx, r0.xyxx
add r0.xy, r2.xyxx, cb0[79].xyxx
add r0.xy, r0.xyxx, l(-0.080000, 0.050000, 0.000000, 0.000000)
sample_b_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t2.xyzw, s2, l(0.000000)
add r0.xyz, r0.xyzx, r1.xyzx
add r0.xyz, r0.xyzx, cb0[73].xyzx
dp3 r0.w, r0.xyzx, l(0.333000, 0.333000, 0.333000, 0.000000)
add r1.xyz, -r0.xyzx, r0.wwww
mad r0.xyz, cb0[90].xxxx, r1.xyzx, r0.xyzx
add r0.xyz, r0.xyzx, l(-1.000000, -1.000000, -1.000000, 0.000000)
mad r0.xyz, cb0[90].yyyy, r0.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
sqrt o0.xyz, r0.xyzx
mov o0.w, l(1.000000)
ret 
// Approximately 43 instruction slots used

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