// ---- Created with 3Dmigoto v1.2.39 on Mon Jun 20 11:05:17 2016

cbuffer VSOffsetConstants : register(b1)
{
  float4x4 ViewProjectionMatrix : packoffset(c0);
  float4 CameraPositionVS : packoffset(c4);
  float4 PreViewTranslation : packoffset(c5);
}

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 PixelTexture2D_0Sampler_s : register(s1);
Texture2D<float4> SceneDepthTexture : register(t0);
Texture2D<float4> PixelTexture2D_0 : register(t1);


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


void main( 
  float4 v0 : TEXCOORD10,
  float4 v1 : TEXCOORD11,
  float4 v2 : TEXCOORD0,
  float4 v3 : TEXCOORD1,
  float4 v4 : TEXCOORD5,
  float4 v5 : TEXCOORD6,
  uint v6 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, v2.xy, 0).xy;
  r0.xy = v3.ww * r0.xy;
  r0.zw = float2(5,5) * r0.xy;
  r0.z = dot(r0.zw, r0.zw);
  r0.z = -0.100000001 + r0.z;
  r0.z = cmp(r0.z < 0);
  if (r0.z != 0) discard;
  r1.xyz = ViewProjectionMatrix._m01_m11_m31 * v4.yyy;
  r1.xyz = ViewProjectionMatrix._m00_m10_m30 * v4.xxx + r1.xyz;
  r1.xyz = ViewProjectionMatrix._m02_m12_m32 * v4.zzz + r1.xyz;
  r1.xyz = ViewProjectionMatrix._m03_m13_m33 * v4.www + r1.xyz;

float4 stereo = StereoParams.Load(0);
r1.x += stereo.x*(r1.z - stereo.y);

  r0.zw = r1.xy / r1.zz;
  r0.zw = r0.zw * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r0.zw = r0.xy * float2(0.0196078438,-0.0196078438) + r0.zw;
  r0.xy = float2(20,20) * r0.xy;
  r0.xy = max(float2(-255,-255), r0.xy);
  r0.xy = min(float2(255,255), r0.xy);
  r0.xy = float2(0.00392156886,0.00392156886) * r0.xy;
  r0.z = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r0.zw, 0).x;
  r0.z = min(0.999000013, r0.z);
  r0.z = r0.z * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
  r0.z = 1 / r0.z;
  r0.z = cmp(r1.z >= r0.z);
  r0.xy = r0.zz ? float2(0,0) : r0.xy;
  o0.xy = max(float2(0,0), r0.xy);
  r0.xy = min(float2(0,0), r0.xy);
  o0.zw = -r0.xy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Mon Jun 20 11:05:17 2016
//
//
// Buffer Definitions: 
//
// cbuffer VSOffsetConstants
// {
//
//   float4x4 ViewProjectionMatrix;     // Offset:    0 Size:    64
//   float4 CameraPositionVS;           // Offset:   64 Size:    16 [unused]
//   float4 PreViewTranslation;         // Offset:   80 Size:    16 [unused]
//
// }
//
// cbuffer PSOffsetConstants
// {
//
//   float4 ScreenPositionScaleBias;    // Offset:    0 Size:    16
//   float4 MinZ_MaxZRatio;             // Offset:   16 Size:    16
//   float NvStereoEnabled;             // Offset:   32 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]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SceneDepthTextureSampler          sampler      NA          NA    0        1
// PixelTexture2D_0Sampler           sampler      NA          NA    1        1
// SceneDepthTexture                 texture  float4          2d    0        1
// PixelTexture2D_0                  texture  float4          2d    1        1
// VSOffsetConstants                 cbuffer      NA          NA    1        1
// PSOffsetConstants                 cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                10   xyzw        0     NONE   float       
// TEXCOORD                11   xyzw        1     NONE   float       
// TEXCOORD                 0   xy          2     NONE   float   xy  
// TEXCOORD                 1   xyzw        3     NONE   float      w
// TEXCOORD                 5   xyzw        4     NONE   float   xyzw
// TEXCOORD                 6   xyzw        5     NONE   float       
// SV_IsFrontFace           0   x           6    FFACE    uint       
//
//
// 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 cb1[4], immediateIndexed
dcl_constantbuffer cb2[2], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.w
dcl_input_ps linear v4.xyzw
dcl_output o0.xyzw
dcl_temps 2
sample_b_indexable(texture2d)(float,float,float,float) r0.xy, v2.xyxx, t1.xyzw, s1, l(0.000000)
mul r0.xy, r0.xyxx, v3.wwww
mul r0.zw, r0.xxxy, l(0.000000, 0.000000, 5.000000, 5.000000)
dp2 r0.z, r0.zwzz, r0.zwzz
add r0.z, r0.z, l(-0.100000)
lt r0.z, r0.z, l(0.000000)
discard_nz r0.z
mul r1.xyz, v4.yyyy, cb1[1].xywx
mad r1.xyz, cb1[0].xywx, v4.xxxx, r1.xyzx
mad r1.xyz, cb1[2].xywx, v4.zzzz, r1.xyzx
mad r1.xyz, cb1[3].xywx, v4.wwww, r1.xyzx
div r0.zw, r1.xxxy, r1.zzzz
mad r0.zw, r0.zzzw, cb2[0].xxxy, cb2[0].wwwz
mad r0.zw, r0.xxxy, l(0.000000, 0.000000, 0.0196078438, -0.0196078438), r0.zzzw
mul r0.xy, r0.xyxx, l(20.000000, 20.000000, 0.000000, 0.000000)
max r0.xy, r0.xyxx, l(-255.000000, -255.000000, 0.000000, 0.000000)
min r0.xy, r0.xyxx, l(255.000000, 255.000000, 0.000000, 0.000000)
mul r0.xy, r0.xyxx, l(0.00392156886, 0.00392156886, 0.000000, 0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t0.yzxw, s0, l(0.000000)
min r0.z, r0.z, l(0.999000)
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
ge r0.z, r1.z, r0.z
movc r0.xy, r0.zzzz, l(0,0,0,0), r0.xyxx
max o0.xy, r0.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
min r0.xy, r0.xyxx, l(0.000000, 0.000000, 0.000000, 0.000000)
mov o0.zw, -r0.xxxy
ret 
// Approximately 28 instruction slots used

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