// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:31:01 2016

cbuffer cbDecalParam : register(b10)
{
  row_major float4x4 FC_ProjToDecalSpace : packoffset(c0);
  float4x4 g_InvProjMatrix : packoffset(c4);
  float4x4 g_CameraMatrix : packoffset(c8);
  float4 unused_FC_ScreenSize : packoffset(c12);
  row_major float3x4 FC_DecalWorldRotation : packoffset(c13);
  float4 FC_EyeInDecalSpace : packoffset(c16);
  float4 FC_ParallaxScale : packoffset(c17);
  float4 FC_DecalSoakThreshold : packoffset(c18);
  float4 FC_CubeCenterOffset : packoffset(c19);
  float4 FC_DiffuseScale : packoffset(c20);
  float3 FC_ReflectanceScale : packoffset(c21);
  float FC_ShininessScale : packoffset(c21.w);
  float4 FC_LightInDecalSpace : packoffset(c22);
  float FC_EmissiveIntensity : packoffset(c23);
  float FC_NearFade_Start : packoffset(c24);
  float FC_NearFade_ReciRange : packoffset(c24.y);
  float FC_FarFade_Start : packoffset(c24.z);
  float FC_FarFade_ReciRange : packoffset(c24.w);
  float FC_NormalThreshold_Start : packoffset(c25);
  float FC_NormalThreshold_ReciRange : packoffset(c25.y);
}

SamplerState SS_DiffuseMap_s : register(s0);
SamplerState SS_WrapPoint_s : register(s6);
SamplerState SS_ClampPoint_s : register(s7);
Texture2D<float4> g_DiffuseTexture : register(t0);
Texture2D<float4> g_DepthTexture : register(t4);
Texture2D<float4> g_LightPrepassAttrTexture : register(t13);


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


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

  r0.xy = v1.xy / v1.ww;
  r1.xy = r0.xy * float2(0.5,-0.5) + float2(0.5,0.5);
  r0.z = g_DepthTexture.Sample(SS_ClampPoint_s, r1.xy).x;
  r1.xyz = g_LightPrepassAttrTexture.Sample(SS_WrapPoint_s, r1.xy).xyz;
  r1.xyz = r1.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.w = 1;
  r2.x = dot(FC_ProjToDecalSpace._m00_m01_m02_m03, r0.xyzw);
  r2.y = dot(FC_ProjToDecalSpace._m10_m11_m12_m13, r0.xyzw);
  r2.z = dot(FC_ProjToDecalSpace._m20_m21_m22_m23, r0.xyzw);
  r0.x = dot(FC_ProjToDecalSpace._m30_m31_m32_m33, r0.xyzw);
  r0.xyz = r2.xyz / r0.xxx;
  r2.xyz = cmp(r0.xyz < float3(0,0,0));
  r2.xyz = r2.xyz ? float3(1,1,1) : 0;
  r3.xyz = cmp(float3(1,1,1) < r0.xyz);
  r3.xyz = r3.xyz ? float3(1,1,1) : 0;
  r2.xyz = (int3)r2.xyz + (int3)r3.xyz;
  r2.xyz = (int3)r2.xyz;
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = cmp(r0.w != 0.000000);
  if (r0.w != 0) discard;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r0.w = dot(r1.xyz, -FC_DecalWorldRotation._m10_m11_m12);
  r0.w = -FC_NormalThreshold_Start + r0.w;
  r0.w = saturate(FC_NormalThreshold_ReciRange * r0.w);
  r1.xy = -FC_NearFade_Start + r0.yy;
  r0.x = g_DiffuseTexture.Sample(SS_DiffuseMap_s, r0.xz).w;
  r0.yz = saturate(FC_NearFade_ReciRange * r1.xy);
  r0.y = r0.w * r0.y;
  r0.z = 1 + -r0.z;
  r0.y = r0.y * r0.z;
  r0.x = r0.y * r0.x;
  r0.x = FC_DiffuseScale.w * r0.x;
  r0.x = FC_ParallaxScale.z * r0.x;
  r0.x = cmp(0 >= r0.x);
  if (r0.x != 0) discard;
  o0.xyzw = float4(0,0,0,0);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbDecalParam
// {
//
//   row_major float4x4 FC_ProjToDecalSpace;// Offset:    0 Size:    64
//   float4x4 g_InvProjMatrix;          // Offset:   64 Size:    64 [unused]
//   float4x4 g_CameraMatrix;           // Offset:  128 Size:    64 [unused]
//   float4 unused_FC_ScreenSize;       // Offset:  192 Size:    16 [unused]
//   row_major float3x4 FC_DecalWorldRotation;// Offset:  208 Size:    48
//   float4 FC_EyeInDecalSpace;         // Offset:  256 Size:    16 [unused]
//   float4 FC_ParallaxScale;           // Offset:  272 Size:    16
//   float4 FC_DecalSoakThreshold;      // Offset:  288 Size:    16 [unused]
//   float4 FC_CubeCenterOffset;        // Offset:  304 Size:    16 [unused]
//   float4 FC_DiffuseScale;            // Offset:  320 Size:    16
//   float3 FC_ReflectanceScale;        // Offset:  336 Size:    12 [unused]
//   float FC_ShininessScale;           // Offset:  348 Size:     4 [unused]
//   float4 FC_LightInDecalSpace;       // Offset:  352 Size:    16 [unused]
//   float FC_EmissiveIntensity;        // Offset:  368 Size:     4 [unused]
//   float FC_NearFade_Start;           // Offset:  384 Size:     4
//   float FC_NearFade_ReciRange;       // Offset:  388 Size:     4
//   float FC_FarFade_Start;            // Offset:  392 Size:     4
//   float FC_FarFade_ReciRange;        // Offset:  396 Size:     4
//   float FC_NormalThreshold_Start;    // Offset:  400 Size:     4
//   float FC_NormalThreshold_ReciRange;// Offset:  404 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_DiffuseMap                     sampler      NA          NA    0        1
// SS_WrapPoint                      sampler      NA          NA    6        1
// SS_ClampPoint                     sampler      NA          NA    7        1
// g_DiffuseTexture                  texture  float4          2d    0        1
// g_DepthTexture                    texture  float4          2d    4        1
// g_LightPrepassAttrTexture         texture  float4          2d   13        1
// cbDecalParam                      cbuffer      NA          NA   10        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xyzw        1     NONE   float   xy w
//
//
// 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 cb10[26], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s6, mode_default
dcl_sampler s7, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t13
dcl_input_ps linear v1.xyw
dcl_output o0.xyzw
dcl_temps 4
div r0.xy, v1.xyxx, v1.wwww
mad r1.xy, r0.xyxx, l(0.500000, -0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r0.z, r1.xyxx, t4.yzxw, s7
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r1.xyxx, t13.xyzw, s6
mad r1.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mov r0.w, l(1.000000)
dp4 r2.x, cb10[0].xyzw, r0.xyzw
dp4 r2.y, cb10[1].xyzw, r0.xyzw
dp4 r2.z, cb10[2].xyzw, r0.xyzw
dp4 r0.x, cb10[3].xyzw, r0.xyzw
div r0.xyz, r2.xyzx, r0.xxxx
lt r2.xyz, r0.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
and r2.xyz, r2.xyzx, l(1, 1, 1, 0)
lt r3.xyz, l(1.000000, 1.000000, 1.000000, 0.000000), r0.xyzx
and r3.xyz, r3.xyzx, l(1, 1, 1, 0)
iadd r2.xyz, r2.xyzx, r3.xyzx
itof r2.xyz, r2.xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
ne r0.w, r0.w, l(0.000000)
discard_nz r0.w
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
dp3 r0.w, r1.xyzx, -cb10[14].xyzx
add r0.w, r0.w, -cb10[25].x
mul_sat r0.w, r0.w, cb10[25].y
add r1.xy, r0.yyyy, -cb10[24].xzxx
sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xzxx, t0.wxyz, s0
mul_sat r0.yz, r1.xxyx, cb10[24].yywy
mul r0.y, r0.y, r0.w
add r0.z, -r0.z, l(1.000000)
mul r0.y, r0.z, r0.y
mul r0.x, r0.x, r0.y
mul r0.x, r0.x, cb10[20].w
mul r0.x, r0.x, cb10[17].z
ge r0.x, l(0.000000), r0.x
discard_nz r0.x
mov o0.xyzw, l(0,0,0,0)
ret 
// Approximately 39 instruction slots used

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