// DOF

cbuffer cPSScene : register(b2)
{

  struct
  {
    float4x4 m_projectionView;
    float4x4 m_projection;
    float4x4 m_view;
    float4x4 m_shadowProjection;
    float4x4 m_shadowProjection2;
    float4 m_eyepos;
    float4 m_projectionParam;
    float4 m_viewportSize;
    float4 m_exposure;
    float4 m_fogParam[3];
    float4 m_fogColor;
    float4 m_cameraCenterOffset;
    float4 m_shadowMapResolutions;
  } g_psScene : packoffset(c0);

}

cbuffer cPSObject : register(b5)
{

  struct
  {
    float4x4 m_viewWorld;
    float4x4 m_world;
    float4 m_useWeightCount;
    float4 m_localParam[4];
  } g_psObject : packoffset(c0);

}

cbuffer cPSSystem : register(b0)
{

  struct
  {
    float4 m_param;
    float4 m_renderInfo;
    float4 m_renderBuffer;
    float4 m_dominantLightDir;
  } g_psSystem : packoffset(c0);

}

SamplerState g_samplerPoint_Clamp_s : register(s9);
SamplerState g_samplerLinear_Clamp_s : register(s11);
Texture2D<float4> inTexture0 : register(t0);
Texture2D<float4> inTexture1 : register(t1);
Texture2D<float4> inDepth : register(t2);


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


void main( 
  float4 v0 : SV_Position0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = g_psSystem.m_renderInfo.xy * v1.xy;
  r0.xy = g_psSystem.m_renderBuffer.zw * r0.xy;
  r1.xyzw = inTexture1.Sample(g_samplerLinear_Clamp_s, r0.xy).xyzw;
  r2.xyz = float3(0.0549999997,0.0549999997,0.0549999997) + r1.xyz;
  r2.xyz = float3(0.947867274,0.947867274,0.947867274) * r2.xyz;
  r2.xyz = max(float3(9.99999975e-006,9.99999975e-006,9.99999975e-006), r2.xyz);
  r2.xyz = log2(r2.xyz);
  r2.xyz = float3(2.4000001,2.4000001,2.4000001) * r2.xyz;
  r2.xyz = exp2(r2.xyz);
  r3.xyz = cmp(float3(0.0392800011,0.0392800011,0.0392800011) >= r1.xyz);
  r4.xyz = r3.xyz ? float3(0,0,0) : float3(1,1,1);
  r3.xyz = r3.xyz ? 1.000000 : 0;
  r1.xyz = r3.xyz * r1.xyz;
  o0.w = r1.w;
  r2.xyz = r4.xyz * r2.xyz;
  r1.xyz = r1.xyz * float3(0.0773993805,0.0773993805,0.0773993805) + r2.xyz;
  r2.xyzw = inTexture0.Sample(g_samplerLinear_Clamp_s, r0.xy).wxyz;
  r0.x = inDepth.Sample(g_samplerPoint_Clamp_s, r0.xy).x;
  r0.x = -g_psScene.m_projectionParam.w + r0.x;
  r0.x = g_psScene.m_projectionParam.z / r0.x;
  r2.x = saturate(r2.x);
  r0.y = 1 + -r2.x;
  r0.yzw = r1.xyz * r0.yyy;
  r1.x = -g_psObject.m_localParam[3].w + r0.x;
  r1.x = g_psObject.m_localParam[3].z * r1.x;
  r0.x = r1.x / r0.x;
  r0.x = -g_psObject.m_localParam[3].x + abs(r0.x);
  r1.x = g_psObject.m_localParam[3].y + -g_psObject.m_localParam[3].x;
  r1.x = 0.5 * r1.x;
  r0.x = saturate(r0.x / r1.x);
  r0.x = 1 + -r0.x;
  r0.xyz = r0.yzw * r0.xxx + r2.yzw;
  r1.xyz = max(float3(9.99999975e-006,9.99999975e-006,9.99999975e-006), r0.xyz);
  r1.xyz = log2(r1.xyz);
  r1.xyz = float3(0.416666657,0.416666657,0.416666657) * r1.xyz;
  r1.xyz = exp2(r1.xyz);
  r1.xyz = r1.xyz * float3(1.05499995,1.05499995,1.05499995) + float3(-0.0549999997,-0.0549999997,-0.0549999997);
  r2.xyz = cmp(float3(0.00313080009,0.00313080009,0.00313080009) >= r0.xyz);
  r3.xyz = r2.xyz ? float3(0,0,0) : float3(1,1,1);
  r2.xyz = r2.xyz ? 1.000000 : 0;
  r0.xyz = r2.xyz * r0.xyz;
  r1.xyz = r3.xyz * r1.xyz;
  o0.xyz = r0.xyz * float3(12.9200001,12.9200001,12.9200001) + r1.xyz;
  
    
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.24 on Mon Jan 18 12:34:55 2016
//
//
// Buffer Definitions: 
//
// cbuffer cPSScene
// {
//
//   struct PSScene
//   {
//       
//       float4x4 m_projectionView;     // Offset:    0
//       float4x4 m_projection;         // Offset:   64
//       float4x4 m_view;               // Offset:  128
//       float4x4 m_shadowProjection;   // Offset:  192
//       float4x4 m_shadowProjection2;  // Offset:  256
//       float4 m_eyepos;               // Offset:  320
//       float4 m_projectionParam;      // Offset:  336
//       float4 m_viewportSize;         // Offset:  352
//       float4 m_exposure;             // Offset:  368
//       float4 m_fogParam[3];          // Offset:  384
//       float4 m_fogColor;             // Offset:  432
//       float4 m_cameraCenterOffset;   // Offset:  448
//       float4 m_shadowMapResolutions; // Offset:  464
//
//   } g_psScene;                       // Offset:    0 Size:   480
//
// }
//
// cbuffer cPSObject
// {
//
//   struct PSObject
//   {
//       
//       float4x4 m_viewWorld;          // Offset:    0
//       float4x4 m_world;              // Offset:   64
//       float4 m_useWeightCount;       // Offset:  128
//       float4 m_localParam[4];        // Offset:  144
//
//   } g_psObject;                      // Offset:    0 Size:   208
//
// }
//
// cbuffer cPSSystem
// {
//
//   struct PSSystem
//   {
//       
//       float4 m_param;                // Offset:    0
//       float4 m_renderInfo;           // Offset:   16
//       float4 m_renderBuffer;         // Offset:   32
//       float4 m_dominantLightDir;     // Offset:   48
//
//   } g_psSystem;                      // Offset:    0 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_samplerPoint_Clamp              sampler      NA          NA    9        1
// g_samplerLinear_Clamp             sampler      NA          NA   11        1
// inTexture0                        texture  float4          2d    0        1
// inTexture1                        texture  float4          2d    1        1
// inDepth                           texture  float4          2d    2        1
// cPSSystem                         cbuffer      NA          NA    0        1
// cPSScene                          cbuffer      NA          NA    2        1
// cPSObject                         cbuffer      NA          NA    5        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
//
//
// 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 cb2[22], immediateIndexed
dcl_constantbuffer cb5[13], immediateIndexed
dcl_constantbuffer cb0[3], immediateIndexed
dcl_sampler s9, mode_default
dcl_sampler s11, 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 v1.xy
dcl_output o0.xyzw
dcl_temps 5
mul r0.xy, v1.xyxx, cb0[1].xyxx
mul r0.xy, r0.xyxx, cb0[2].zwzz
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyxx, t1.xyzw, s11
add r2.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000)
mul r2.xyz, r2.xyzx, l(0.947867274, 0.947867274, 0.947867274, 0.000000)
max r2.xyz, r2.xyzx, l(0.000010, 0.000010, 0.000010, 0.000000)
log r2.xyz, r2.xyzx
mul r2.xyz, r2.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000)
exp r2.xyz, r2.xyzx
ge r3.xyz, l(0.039280, 0.039280, 0.039280, 0.000000), r1.xyzx
movc r4.xyz, r3.xyzx, l(0,0,0,0), l(1.000000,1.000000,1.000000,0)
and r3.xyz, r3.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0)
mul r1.xyz, r1.xyzx, r3.xyzx
mov o0.w, r1.w
mul r2.xyz, r2.xyzx, r4.xyzx
mad r1.xyz, r1.xyzx, l(0.0773993805, 0.0773993805, 0.0773993805, 0.000000), r2.xyzx
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r0.xyxx, t0.wxyz, s11
sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t2.xyzw, s9
add r0.x, r0.x, -cb2[21].w
div r0.x, cb2[21].z, r0.x
mov_sat r2.x, r2.x
add r0.y, -r2.x, l(1.000000)
mul r0.yzw, r0.yyyy, r1.xxyz
add r1.x, r0.x, -cb5[12].w
mul r1.x, r1.x, cb5[12].z
div r0.x, r1.x, r0.x
add r0.x, |r0.x|, -cb5[12].x
add r1.x, -cb5[12].x, cb5[12].y
mul r1.x, r1.x, l(0.500000)
div_sat r0.x, r0.x, r1.x
add r0.x, -r0.x, l(1.000000)
mad r0.xyz, r0.yzwy, r0.xxxx, r2.yzwy
max r1.xyz, r0.xyzx, l(0.000010, 0.000010, 0.000010, 0.000000)
log r1.xyz, r1.xyzx
mul r1.xyz, r1.xyzx, l(0.416666657, 0.416666657, 0.416666657, 0.000000)
exp r1.xyz, r1.xyzx
mad r1.xyz, r1.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000)
ge r2.xyz, l(0.00313080009, 0.00313080009, 0.00313080009, 0.000000), r0.xyzx
movc r3.xyz, r2.xyzx, l(0,0,0,0), l(1.000000,1.000000,1.000000,0)
and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0)
mul r0.xyz, r0.xyzx, r2.xyzx
mul r1.xyz, r1.xyzx, r3.xyzx
mad o0.xyz, r0.xyzx, l(12.920000, 12.920000, 12.920000, 0.000000), r1.xyzx
ret 
// Approximately 44 instruction slots used

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