//Decals PS 1
cbuffer PER_BATCH : register(b0)
{
  float4 g_LightDiffuse : packoffset(c0);
  float4 g_WorldViewPos : packoffset(c1);
  row_major float4x4 g_mLightProj : packoffset(c2);
  float4 g_GeneralParams : packoffset(c6);
  float4 g_ScreenScale : packoffset(c7);
  float4 vWBasisX : packoffset(c8);
  float4 vWBasisY : packoffset(c9);
  float4 vWBasisZ : packoffset(c10);
  row_major float4x4 g_mDecalTS : packoffset(c11);
}
SamplerState _tex0_s : register(s0);
SamplerState _tex2_s : register(s2);
SamplerState _tex3_s : register(s3);
Texture2D<float4> _tex0 : register(t0);
Texture2D<float4> _tex2 : register(t2);
Texture2D<float4> _tex3 : register(t3);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main( 
  float4 v0 : SV_POSITION0,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1,
  
      row_major matrix vp : TEXCOORD0,
  row_major matrix ivp : TEXCOORD4)
  
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = v0.xy * g_ScreenScale.xy + g_ScreenScale.zw;
  r0.x = _tex0.Sample(_tex0_s, r0.xy).x;
  r0.yzw = vWBasisX.xyz * v0.xxx + vWBasisZ.xyz;
  r0.yzw = vWBasisY.xyz * v0.yyy + r0.yzw;
  r0.xyz = r0.yzw * r0.xxx + g_WorldViewPos.xyz;
  r0.w = 1;
  
        float4 stereo = StereoParams.Load(0);
  float4 tmp = mul(vp, r0);
  tmp.x -= stereo.x * (tmp.w - stereo.y);
  r0 = mul(ivp, tmp);
  
  r1.x = dot(g_mLightProj._m00_m01_m02_m03, r0.xyzw);
  r1.y = dot(g_mLightProj._m10_m11_m12_m13, r0.xyzw);
  r1.z = dot(g_mLightProj._m20_m21_m22_m23, r0.xyzw);
  r0.x = dot(g_mLightProj._m30_m31_m32_m33, r0.xyzw);
  r0.xyz = r1.xyz / r0.xxx;
  r1.xyzw = r0.xyxy * float4(1,1,-1,-1) + float4(0,0,1,1);
  r1.xyzw = r1.xyzw < float4(0,0,0,0);
  r1.xy = (int2)r1.zw | (int2)r1.xy;
  r0.w = (int)r1.y | (int)r1.x;
  if (r0.w != 0) discard;
  r1.xy = r0.zz < float2(0,0.200000003);
  if (r1.x != 0) discard;
  r0.w = r1.y ? 5 : 1;
  r1.xyzw = _tex2.Sample(_tex2_s, r0.xy).xyzw;
  r2.x = -g_GeneralParams.w + r1.w;
  r2.x = r2.x < 0;
  if (r2.x != 0) discard;
  r0.z = -0.200000003 + r0.z;
  r0.xy = _tex3.Sample(_tex3_s, r0.xy).xy;
  r0.xy = r0.yx * float2(2,2) + float2(-1,-1);
  r0.z = r0.z * r0.w;
  r0.z = -r0.z * r0.z + 1;
  r0.z = max(0, r0.z);
  r0.z = g_LightDiffuse.w * r0.z;
  r0.z = r1.w * r0.z;
  r1.xyz = g_LightDiffuse.xyz * r1.xyz;
  o0.xyz = sqrt(r1.xyz);
  o0.w = r0.z;
  o1.w = r0.z;
  r1.xyz = g_mDecalTS._m10_m11_m12 * r0.yyy;
  r1.xyz = r0.xxx * g_mDecalTS._m00_m01_m02 + r1.xyz;
  r0.x = dot(r0.xy, -r0.xy);
  r0.x = saturate(1 + r0.x);
  r0.x = sqrt(r0.x);
  r0.xyz = r0.xxx * g_mDecalTS._m20_m21_m22 + r1.xyz;
  o1.xyz = r0.xyz * float3(0.5,0.5,0.5) + float3(0.5,0.5,0.5);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.2.1 on Sun Aug 30 07:48:03 2015
//
//
// Buffer Definitions: 
//
// cbuffer PER_BATCH
// {
//
//   float4 g_LightDiffuse;             // Offset:    0 Size:    16
//   float4 g_WorldViewPos;             // Offset:   16 Size:    16
//   row_major float4x4 g_mLightProj;   // Offset:   32 Size:    64
//   float4 g_GeneralParams;            // Offset:   96 Size:    16
//   float4 g_ScreenScale;              // Offset:  112 Size:    16
//   float4 vWBasisX;                   // Offset:  128 Size:    16
//   float4 vWBasisY;                   // Offset:  144 Size:    16
//   float4 vWBasisZ;                   // Offset:  160 Size:    16
//   row_major float4x4 g_mDecalTS;     // Offset:  176 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// _tex0                             sampler      NA          NA    0        1
// _tex2                             sampler      NA          NA    2        1
// _tex3                             sampler      NA          NA    3        1
// _tex0                             texture  float4          2d    0        1
// _tex2                             texture  float4          2d    2        1
// _tex3                             texture  float4          2d    3        1
// PER_BATCH                         cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                1   xyzw        1   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[14], immediateIndexed
dcl_sampler s0, 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) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 3
mad r0.xy, v0.xyxx, cb0[7].xyxx, cb0[7].zwzz
sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t0.xyzw, s0
mad r0.yzw, cb0[8].xxyz, v0.xxxx, cb0[10].xxyz
mad r0.yzw, cb0[9].xxyz, v0.yyyy, r0.yyzw
mad r0.xyz, r0.yzwy, r0.xxxx, cb0[1].xyzx
mov r0.w, l(1.000000)
dp4 r1.x, cb0[2].xyzw, r0.xyzw
dp4 r1.y, cb0[3].xyzw, r0.xyzw
dp4 r1.z, cb0[4].xyzw, r0.xyzw
dp4 r0.x, cb0[5].xyzw, r0.xyzw
div r0.xyz, r1.xyzx, r0.xxxx
mad r1.xyzw, r0.xyxy, l(1.000000, 1.000000, -1.000000, -1.000000), l(0.000000, 0.000000, 1.000000, 1.000000)
lt r1.xyzw, r1.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
or r1.xy, r1.zwzz, r1.xyxx
or r0.w, r1.y, r1.x
discard_nz r0.w
lt r1.xy, r0.zzzz, l(0.000000, 0.200000, 0.000000, 0.000000)
discard_nz r1.x
movc r0.w, r1.y, l(5.000000), l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyxx, t2.xyzw, s2
add r2.x, r1.w, -cb0[6].w
lt r2.x, r2.x, l(0.000000)
discard_nz r2.x
add r0.z, r0.z, l(-0.200000)
sample_indexable(texture2d)(float,float,float,float) r0.xy, r0.xyxx, t3.xyzw, s3
mad r0.xy, r0.yxyy, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r0.z, r0.w, r0.z
mad r0.z, -r0.z, r0.z, l(1.000000)
max r0.z, r0.z, l(0.000000)
mul r0.z, r0.z, cb0[0].w
mul r0.z, r0.z, r1.w
mul r1.xyz, r1.xyzx, cb0[0].xyzx
sqrt o0.xyz, r1.xyzx
mov o0.w, r0.z
mov o1.w, r0.z
mul r1.xyz, r0.yyyy, cb0[12].xyzx
mad r1.xyz, r0.xxxx, cb0[11].xyzx, r1.xyzx
dp2 r0.x, r0.xyxx, -r0.xyxx
add_sat r0.x, r0.x, l(1.000000)
sqrt r0.x, r0.x
mad r0.xyz, r0.xxxx, cb0[13].xyzx, r1.xyzx
mad o1.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), l(0.500000, 0.500000, 0.500000, 0.000000)
ret 
// Approximately 43 instruction slots used

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