// Reflections

cbuffer _Globals : register(b0)
{
  float2 ProjectionScaleBias : packoffset(c0);
  float4 SourceTexelOffsets01 : packoffset(c1);
  float4 SourceTexelOffsets23 : packoffset(c2);
}

cbuffer PSOffsetConstants : register(b2)
{
  float4 ScreenPositionScaleBias : packoffset(c0);
  float4 MinZ_MaxZRatio : packoffset(c1);
  float NvStereoEnabled : packoffset(c2);
  float MetallicOverrideParameter : packoffset(c2.y);
  float4 DiffuseOverrideParameter : packoffset(c3);
  float4 SpecularOverrideParameter : packoffset(c4);
  float4 CameraPositionPS : packoffset(c5);
  float4 ScreenAndTexelSize : packoffset(c6);
  float4 ViewClampRect : packoffset(c7);
  float2 ProjectionInvScale : packoffset(c8);
  float4x4 ViewProjectionMatrixPS : packoffset(c9);
  float2 SceneColorExponentBias : packoffset(c13);
}

SamplerState SceneDepthTextureSampler_s : register(s2);
Texture2D<float4> SceneDepthTexture : register(t0);


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


void main( 
  float2 v0 : TEXCOORD0,
  out float4 o0 : SV_Target0,
  out float oDepth : SV_Depth)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyzw = SourceTexelOffsets01.xyzw + v0.xyxy;
  r0.x = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r0.xy, 0).x;
  r0.y = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r0.zw, 0).x;
  r0.xy = max(float2(0.00100000994,0.00100000994), r0.xy);
  r0.y = r0.y * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
  r0.y = 1 / r0.y;
  r0.x = r0.x * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
  r0.x = 1 / r0.x;
  r0.x = max(r0.x, r0.y);
  r1.xyzw = SourceTexelOffsets23.xyzw + v0.xyxy;
  r0.y = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r1.xy, 0).x;
  r0.z = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r1.zw, 0).x;
  r0.yz = max(float2(0.00100000994,0.00100000994), r0.yz);
  r0.z = r0.z * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
  r0.z = 1 / r0.z;
  r0.y = r0.y * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
  r0.y = 1 / r0.y;
  r0.y = max(r0.y, r0.z);
  r0.x = max(r0.x, r0.y);
  r0.y = r0.x * ProjectionScaleBias.x + ProjectionScaleBias.y;
  oDepth = r0.y / r0.x;
  o0.xyzw = float4(0,0,0,0);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float2 ProjectionScaleBias;        // Offset:    0 Size:     8
//   float4 SourceTexelOffsets01;       // Offset:   16 Size:    16
//   float4 SourceTexelOffsets23;       // Offset:   32 Size:    16
//
// }
//
// cbuffer PSOffsetConstants
// {
//
//   float4 ScreenPositionScaleBias;    // Offset:    0 Size:    16 [unused]
//   float4 MinZ_MaxZRatio;             // Offset:   16 Size:    16
//   float NvStereoEnabled;             // Offset:   32 Size:     4 [unused]
//   float MetallicOverrideParameter;   // Offset:   36 Size:     4 [unused]
//   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]
//   float4 ViewClampRect;              // Offset:  112 Size:    16 [unused]
//   float2 ProjectionInvScale;         // Offset:  128 Size:     8 [unused]
//   float4x4 ViewProjectionMatrixPS;   // Offset:  144 Size:    64 [unused]
//   float2 SceneColorExponentBias;     // Offset:  208 Size:     8 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SceneDepthTextureSampler          sampler      NA          NA    2        1
// SceneDepthTexture                 texture  float4          2d    0        1
// $Globals                          cbuffer      NA          NA    0        1
// PSOffsetConstants                 cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Depth                 0    N/A   oDepth    DEPTH   float    YES
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[3], immediateIndexed
dcl_constantbuffer cb2[2], immediateIndexed
dcl_sampler s2, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v0.xy
dcl_output o0.xyzw
dcl_output oDepth
dcl_temps 2
add r0.xyzw, v0.xyxy, cb0[1].xyzw
sample_l_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t0.xyzw, s2, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r0.y, r0.zwzz, t0.yxzw, s2, l(0.000000)
max r0.xy, r0.xyxx, l(0.001000, 0.001000, 0.000000, 0.000000)
mad r0.y, r0.y, cb2[1].z, -cb2[1].w
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
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
max r0.x, r0.y, r0.x
add r1.xyzw, v0.xyxy, cb0[2].xyzw
sample_l_indexable(texture2d)(float,float,float,float) r0.y, r1.xyxx, t0.yxzw, s2, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r0.z, r1.zwzz, t0.yzxw, s2, l(0.000000)
max r0.yz, r0.yyzy, l(0.000000, 0.001000, 0.001000, 0.000000)
mad r0.z, r0.z, cb2[1].z, -cb2[1].w
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mad r0.y, r0.y, cb2[1].z, -cb2[1].w
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
max r0.y, r0.z, r0.y
max r0.x, r0.y, r0.x
mad r0.y, r0.x, cb0[0].x, cb0[0].y
div oDepth, r0.y, r0.x
mov o0.xyzw, l(0,0,0,0)
ret 
// Approximately 23 instruction slots used

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