// ---- Created with 3Dmigoto v1.2.39 on Mon Jun 20 11:22:57 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 SceneColorTextureSampler_s : register(s1);
SamplerState NvStereoFixTextureSampler_s : register(s2);
SamplerState PixelTexture2D_0Sampler_s : register(s3);
Texture2D<float4> SceneDepthTexture : register(t0);
Texture2D<float4> SceneColorTexture : register(t1);
Texture2D<float4> NvStereoFixTexture : register(t2);
Texture2D<float4> PixelTexture2D_0 : register(t3);


// 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 : TEXCOORD4,
  float4 v5 : TEXCOORD6,
  float4 v6 : TEXCOORD5,
  uint v7 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = ViewProjectionMatrix._m01_m11_m31 * v6.yyy;
  r0.xyz = ViewProjectionMatrix._m00_m10_m30 * v6.xxx + r0.xyz;
  r0.xyz = ViewProjectionMatrix._m02_m12_m32 * v6.zzz + r0.xyz;
  r0.yzw = ViewProjectionMatrix._m03_m13_m33 * v6.www + r0.xyz;

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

  r1.x = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, v2.xy, 0).x;
  r1.y = cmp(0 != NvStereoEnabled);
  if (r1.y != 0) {
    r1.zw = NvStereoFixTexture.Sample(NvStereoFixTextureSampler_s, float2(0.0625,0)).xy;
    r1.w = -r1.w + r0.w;
    r0.x = r1.z * r1.w + r0.y;
    r2.xyz = r0.xzw;
  }
  r1.yzw = r1.yyy ? r2.xyz : r0.yzw;
  r1.yz = r1.yz / r1.ww;
  r1.yz = r1.yz * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r0.x = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r1.yz, 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 = r0.x + -r0.w;
  r0.x = saturate(0.03125 * r0.x);
  r0.x = r1.x * r0.x;
  r0.x = v3.w * r0.x;
  r1.x = max(-64, r0.x);
  r1.y = 0;
  r1.xy = min(float2(64,64), r1.xy);
  r0.xy = r0.yz / r0.ww;
  r0.xy = r0.xy * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r0.xy = r1.xy * float2(0.00392156886,-0.00392156886) + r0.xy;
  r0.xyz = SceneColorTexture.Sample(SceneColorTextureSampler_s, r0.xy).xyz;
  o0.xyz = r0.xyz;
  o0.w = 0;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Mon Jun 20 11:22:57 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
//   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
// SceneColorTextureSampler          sampler      NA          NA    1        1
// NvStereoFixTextureSampler         sampler      NA          NA    2        1
// PixelTexture2D_0Sampler           sampler      NA          NA    3        1
// SceneDepthTexture                 texture  float4          2d    0        1
// SceneColorTexture                 texture  float4          2d    1        1
// NvStereoFixTexture                texture  float4          2d    2        1
// PixelTexture2D_0                  texture  float4          2d    3        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                 4   xyzw        4     NONE   float       
// TEXCOORD                 6   xyzw        5     NONE   float       
// TEXCOORD                 5   xyzw        6     NONE   float   xyzw
// SV_IsFrontFace           0   x           7    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[3], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, 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_resource_texture2d (float,float,float,float) t3
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.w
dcl_input_ps linear v6.xyzw
dcl_output o0.xyzw
dcl_temps 3
mul r0.xyz, v6.yyyy, cb1[1].xywx
mad r0.xyz, cb1[0].xywx, v6.xxxx, r0.xyzx
mad r0.xyz, cb1[2].xywx, v6.zzzz, r0.xyzx
mad r0.yzw, cb1[3].xxyw, v6.wwww, r0.xxyz
sample_b_indexable(texture2d)(float,float,float,float) r1.x, v2.xyxx, t3.xyzw, s3, l(0.000000)
ne r1.y, l(0.000000, 0.000000, 0.000000, 0.000000), cb2[2].x
if_nz r1.y
  sample_indexable(texture2d)(float,float,float,float) r1.zw, l(0.062500, 0.000000, 0.000000, 0.000000), t2.zwxy, s2
  add r1.w, r0.w, -r1.w
  mad r0.x, r1.z, r1.w, r0.y
  mov r2.xyz, r0.xzwx
endif 
movc r1.yzw, r1.yyyy, r2.xxyz, r0.yyzw
div r1.yz, r1.yyzy, r1.wwww
mad r1.yz, r1.yyzy, cb2[0].xxyx, cb2[0].wwzw
sample_l_indexable(texture2d)(float,float,float,float) r0.x, r1.yzyy, 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
add r0.x, -r0.w, r0.x
mul_sat r0.x, r0.x, l(0.031250)
mul r0.x, r0.x, r1.x
mul r0.x, r0.x, v3.w
max r1.x, r0.x, l(-64.000000)
mov r1.y, l(0)
min r1.xy, r1.xyxx, l(64.000000, 64.000000, 0.000000, 0.000000)
div r0.xy, r0.yzyy, r0.wwww
mad r0.xy, r0.xyxx, cb2[0].xyxx, cb2[0].wzww
mad r0.xy, r1.xyxx, l(0.00392156886, -0.00392156886, 0.000000, 0.000000), r0.xyxx
sample_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t1.xyzw, s1
mov o0.xyz, r0.xyzx
mov o0.w, l(0)
ret 
// Approximately 33 instruction slots used

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