// ---- Created with 3Dmigoto v1.2.39 on Sun Jun 26 11:38:53 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);
Texture2D<float4> SceneDepthTexture : register(t0);


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


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

  r0.x = dot(v4.xyz, v4.xyz);
  r0.x = rsqrt(r0.x);
  r0.x = v4.z * r0.x;
  r0.x = max(0, r0.x);
  r0.x = 1 + -r0.x;
  r0.y = log2(abs(r0.x));
  r0.x = cmp(abs(r0.x) < 9.99999997e-007);
  r0.y = 1.20000005 * r0.y;
  r0.y = exp2(r0.y);
  r0.y = 1 + -r0.y;
  r0.x = r0.x ? 1 : r0.y;
  r0.yz = float2(0.600000024,2.4000001) * r0.xx;
  r0.y = dot(r0.yy, r0.yy);
  r0.z = max(-255, r0.z);
  r0.z = 0.00392156886 * r0.z;
  r0.y = -0.100000001 + r0.y;
  r0.y = cmp(r0.y < 0);
  if (r0.y != 0) discard;
  r1.xyz = ViewProjectionMatrix._m01_m11_m31 * v3.yyy;
  r1.xyz = ViewProjectionMatrix._m00_m10_m30 * v3.xxx + r1.xyz;
  r1.xyz = ViewProjectionMatrix._m02_m12_m32 * v3.zzz + r1.xyz;
  r1.xyz = ViewProjectionMatrix._m03_m13_m33 * v3.www + r1.xyz;

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

  r0.yw = r1.xy / r1.zz;
  r0.yw = r0.yw * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r0.xy = r0.xx * float2(0.00235294132,-0.00235294132) + r0.yw;
  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.x = cmp(r1.z >= r0.x);
  r0.x = r0.x ? 0 : r0.z;
  o0.xy = max(float2(0,0), r0.xx);
  r0.x = min(0, r0.x);
  o0.zw = -r0.xx;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Sun Jun 26 11:38:53 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
// SceneDepthTexture                 texture  float4          2d    0        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       
// COLOR                    0   xyzw        2     NONE   float       
// TEXCOORD                 5   xyzw        3     NONE   float   xyzw
// TEXCOORD                 6   xyzw        4     NONE   float   xyz 
// SV_IsFrontFace           0   x           5    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_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyz
dcl_output o0.xyzw
dcl_temps 2
dp3 r0.x, v4.xyzx, v4.xyzx
rsq r0.x, r0.x
mul r0.x, r0.x, v4.z
max r0.x, r0.x, l(0.000000)
add r0.x, -r0.x, l(1.000000)
log r0.y, |r0.x|
lt r0.x, |r0.x|, l(0.000001)
mul r0.y, r0.y, l(1.200000)
exp r0.y, r0.y
add r0.y, -r0.y, l(1.000000)
movc r0.x, r0.x, l(1.000000), r0.y
mul r0.yz, r0.xxxx, l(0.000000, 0.600000, 2.400000, 0.000000)
dp2 r0.y, r0.yyyy, r0.yyyy
max r0.z, r0.z, l(-255.000000)
mul r0.z, r0.z, l(0.00392156886)
add r0.y, r0.y, l(-0.100000)
lt r0.y, r0.y, l(0.000000)
discard_nz r0.y
mul r1.xyz, v3.yyyy, cb1[1].xywx
mad r1.xyz, cb1[0].xywx, v3.xxxx, r1.xyzx
mad r1.xyz, cb1[2].xywx, v3.zzzz, r1.xyzx
mad r1.xyz, cb1[3].xywx, v3.wwww, r1.xyzx
div r0.yw, r1.xxxy, r1.zzzz
mad r0.yw, r0.yyyw, cb2[0].xxxy, cb2[0].wwwz
mad r0.xy, r0.xxxx, l(0.00235294132, -0.00235294132, 0.000000, 0.000000), r0.ywyy
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
ge r0.x, r1.z, r0.x
movc r0.x, r0.x, l(0), r0.z
max o0.xy, r0.xxxx, l(0.000000, 0.000000, 0.000000, 0.000000)
min r0.x, r0.x, l(0.000000)
mov o0.zw, -r0.xxxx
ret 
// Approximately 35 instruction slots used

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