// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:31:00 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);
}

cbuffer cbModelParam : register(b7)
{
  float4 FC_DifColMul : packoffset(c0);
  float FC_EnvMapInterpRatio : packoffset(c1);
  float FC_EnvMapColorScale0 : packoffset(c1.y);
  float FC_EnvMapColorScale1 : packoffset(c1.z);
  float FC_DitherEnable : packoffset(c2);
  float FC_FROZEN_RATE : packoffset(c2.w);
  float FC_Perlin_Freq : packoffset(c3);
  float FC_Perlin_Amp : packoffset(c3.y);
  float FC_Perlin_Lacunarity : packoffset(c3.z);
  float FC_Perlin_Gain : packoffset(c3.w);
  float FC_SnowRate : packoffset(c4);
  float FC_SnowMinDot : packoffset(c4.y);
  float FC_SnowMaxDot : packoffset(c4.z);
  float FC_SparkleExponent : packoffset(c5);
  float FC_SparkleThreshold : packoffset(c5.y);
  float FC_SparkleMul : packoffset(c5.z);
  float FC_SparkleMaskExponent : packoffset(c5.w);
  float4 FC_SkinMatchColor : packoffset(c6);
  int FC_EnvId : packoffset(c7);
  float4 FC_ParallaxCorrectedCubemapOriginA : packoffset(c8);
  float4 FC_ParallaxCorrectedCubemapOriginB : packoffset(c9);
  float4x4 FC_ParallaxCorrectedCubemapObbA : packoffset(c10);
  float4x4 FC_ParallaxCorrectedCubemapInvObbA : packoffset(c14);
  float4x4 FC_ParallaxCorrectedCubemapObbB : packoffset(c18);
  float4x4 FC_ParallaxCorrectedCubemapInvObbB : packoffset(c22);
  float FC_ParallaxCorrectedCubemapObbAEnable : packoffset(c26);
  float FC_ParallaxCorrectedCubemapObbBEnable : packoffset(c26.y);
}

cbuffer cbCubeEnvSH1 : register(b11)
{
  float4 FC_CubeEnvSH1[3] : packoffset(c0);
}

SamplerState SS_DiffuseMap_s : register(s0);
SamplerState SS_BumpMap_s : register(s2);
SamplerState SS_WrapPoint_s : register(s6);
SamplerState SS_ClampPoint_s : register(s7);
TextureCube<float4> g_CubeDiffuseTexture : register(t0);
TextureCube<float4> g_CubeBumpmapTexture : register(t3);
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,
  out float4 o1 : SV_Target1,
  out float4 o2 : SV_Target2,
  out float4 o3 : SV_Target3,
  out float4 o4 : SV_Target4,
  out float4 o5 : SV_Target5,
  out float4 o6 : SV_Target6)
{
  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;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = sqrt(r0.w);
  r0.w = cmp(1 < r0.w);
  if (r0.w != 0) discard;
  r2.xyz = cmp(r0.xyz < float3(-1,-1,-1));
  r2.xyz = r2.xyz ? float3(1,1,1) : 0;
  r3.xyz = cmp(float3(1,1,1) < r0.xyz);
  r0.xyz = FC_CubeCenterOffset.xyz + 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;
  r1.xy = saturate(FC_NearFade_ReciRange * r1.xy);
  r0.w = r1.x * r0.w;
  r1.x = 1 + -r1.y;
  r0.w = r1.x * r0.w;
  r1.xyzw = g_CubeDiffuseTexture.Sample(SS_DiffuseMap_s, r0.xyz).xyzw;
  r0.xy = g_CubeBumpmapTexture.Sample(SS_BumpMap_s, r0.xyz).xy;
  r0.xy = r0.xy * float2(2,2) + float2(-1,-1);
  r0.z = r1.w * r0.w;
  r1.xyz = FC_DiffuseScale.xyz * r1.xyz;
  r0.z = FC_DiffuseScale.w * r0.z;
  r0.z = FC_DifColMul.w * r0.z;
  r2.w = FC_ParallaxScale.z * r0.z;
  r0.w = cmp(0 >= r2.w);
  if (r0.w != 0) discard;
  r2.xyz = float3(0,0,1);
  o0.xyzw = r2.xxxw;
  o1.xyzw = r2.yyzw;
  o2.xyz = r1.xyz * r0.zzz;
  o6.w = FC_ParallaxScale.y * r0.z;
  o2.w = r2.w;
  o4.w = r2.w;
  o3.xyzw = r2.yyyw;
  o5.xyzw = r2.yyyw;
  r0.z = dot(r0.xy, r0.xy);
  r0.z = min(1, r0.z);
  r0.z = 1 + -r0.z;
  r0.z = sqrt(r0.z);
  r1.xyz = FC_DecalWorldRotation._m10_m11_m12 * r0.zzz;
  r0.xzw = r0.xxx * FC_DecalWorldRotation._m00_m01_m02 + r1.xyz;
  r0.xyz = r0.yyy * FC_DecalWorldRotation._m20_m21_m22 + r0.xzw;
  r0.w = 1;
  r1.x = dot(r0.xyzw, FC_CubeEnvSH1[0].xyzw);
  r1.y = dot(r0.xyzw, FC_CubeEnvSH1[1].xyzw);
  r1.z = dot(r0.xyzw, FC_CubeEnvSH1[2].xyzw);
  o6.xyz = r0.xyz * float3(0.5,0.5,0.5) + float3(0.500488758,0.500488758,0.500488758);
  o4.xyz = max(float3(0,0,0), r1.xyz);
  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
//   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
//
// }
//
// cbuffer cbModelParam
// {
//
//   float4 FC_DifColMul;               // Offset:    0 Size:    16
//   float FC_EnvMapInterpRatio;        // Offset:   16 Size:     4 [unused]
//   float FC_EnvMapColorScale0;        // Offset:   20 Size:     4 [unused]
//   float FC_EnvMapColorScale1;        // Offset:   24 Size:     4 [unused]
//   float FC_DitherEnable;             // Offset:   32 Size:     4 [unused]
//   float FC_FROZEN_RATE;              // Offset:   44 Size:     4 [unused]
//   float FC_Perlin_Freq;              // Offset:   48 Size:     4 [unused]
//   float FC_Perlin_Amp;               // Offset:   52 Size:     4 [unused]
//   float FC_Perlin_Lacunarity;        // Offset:   56 Size:     4 [unused]
//   float FC_Perlin_Gain;              // Offset:   60 Size:     4 [unused]
//   float FC_SnowRate;                 // Offset:   64 Size:     4 [unused]
//   float FC_SnowMinDot;               // Offset:   68 Size:     4 [unused]
//   float FC_SnowMaxDot;               // Offset:   72 Size:     4 [unused]
//   float FC_SparkleExponent;          // Offset:   80 Size:     4 [unused]
//   float FC_SparkleThreshold;         // Offset:   84 Size:     4 [unused]
//   float FC_SparkleMul;               // Offset:   88 Size:     4 [unused]
//   float FC_SparkleMaskExponent;      // Offset:   92 Size:     4 [unused]
//   float4 FC_SkinMatchColor;          // Offset:   96 Size:    16 [unused]
//   int FC_EnvId;                      // Offset:  112 Size:     4 [unused]
//   float4 FC_ParallaxCorrectedCubemapOriginA;// Offset:  128 Size:    16 [unused]
//   float4 FC_ParallaxCorrectedCubemapOriginB;// Offset:  144 Size:    16 [unused]
//   float4x4 FC_ParallaxCorrectedCubemapObbA;// Offset:  160 Size:    64 [unused]
//   float4x4 FC_ParallaxCorrectedCubemapInvObbA;// Offset:  224 Size:    64 [unused]
//   float4x4 FC_ParallaxCorrectedCubemapObbB;// Offset:  288 Size:    64 [unused]
//   float4x4 FC_ParallaxCorrectedCubemapInvObbB;// Offset:  352 Size:    64 [unused]
//   float FC_ParallaxCorrectedCubemapObbAEnable;// Offset:  416 Size:     4 [unused]
//   float FC_ParallaxCorrectedCubemapObbBEnable;// Offset:  420 Size:     4 [unused]
//
// }
//
// cbuffer cbCubeEnvSH1
// {
//
//   float4 FC_CubeEnvSH1[3];           // Offset:    0 Size:    48
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_DiffuseMap                     sampler      NA          NA    0        1
// SS_BumpMap                        sampler      NA          NA    2        1
// SS_WrapPoint                      sampler      NA          NA    6        1
// SS_ClampPoint                     sampler      NA          NA    7        1
// g_CubeDiffuseTexture              texture  float4        cube    0        1
// g_CubeBumpmapTexture              texture  float4        cube    3        1
// g_DepthTexture                    texture  float4          2d    4        1
// g_LightPrepassAttrTexture         texture  float4          2d   13        1
// cbModelParam                      cbuffer      NA          NA    7        1
// cbDecalParam                      cbuffer      NA          NA   10        1
// cbCubeEnvSH1                      cbuffer      NA          NA   11        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
// SV_Target                1   xyzw        1   TARGET   float   xyzw
// SV_Target                2   xyzw        2   TARGET   float   xyzw
// SV_Target                3   xyzw        3   TARGET   float   xyzw
// SV_Target                4   xyzw        4   TARGET   float   xyzw
// SV_Target                5   xyzw        5   TARGET   float   xyzw
// SV_Target                6   xyzw        6   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb10[26], immediateIndexed
dcl_constantbuffer cb7[1], immediateIndexed
dcl_constantbuffer cb11[3], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s2, mode_default
dcl_sampler s6, mode_default
dcl_sampler s7, mode_default
dcl_resource_texturecube (float,float,float,float) t0
dcl_resource_texturecube (float,float,float,float) t3
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_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.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
dp3 r0.w, r0.xyzx, r0.xyzx
sqrt r0.w, r0.w
lt r0.w, l(1.000000), r0.w
discard_nz r0.w
lt r2.xyz, r0.xyzx, l(-1.000000, -1.000000, -1.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
add r0.xyz, r0.xyzx, cb10[19].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
mul_sat r1.xy, r1.xyxx, cb10[24].ywyy
mul r0.w, r0.w, r1.x
add r1.x, -r1.y, l(1.000000)
mul r0.w, r0.w, r1.x
sample_indexable(texturecube)(float,float,float,float) r1.xyzw, r0.xyzx, t0.xyzw, s0
sample_indexable(texturecube)(float,float,float,float) r0.xy, r0.xyzx, t3.xyzw, s2
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r0.z, r0.w, r1.w
mul r1.xyz, r1.xyzx, cb10[20].xyzx
mul r0.z, r0.z, cb10[20].w
mul r0.z, r0.z, cb7[0].w
mul r2.w, r0.z, cb10[17].z
ge r0.w, l(0.000000), r2.w
discard_nz r0.w
mov r2.xyz, l(0,0,1.000000,0)
mov o0.xyzw, r2.xxxw
mov o1.xyzw, r2.yyzw
mul o2.xyz, r0.zzzz, r1.xyzx
mul o6.w, r0.z, cb10[17].y
mov o2.w, r2.w
mov o4.w, r2.w
mov o3.xyzw, r2.yyyw
mov o5.xyzw, r2.yyyw
dp2 r0.z, r0.xyxx, r0.xyxx
min r0.z, r0.z, l(1.000000)
add r0.z, -r0.z, l(1.000000)
sqrt r0.z, r0.z
mul r1.xyz, r0.zzzz, cb10[14].xyzx
mad r0.xzw, r0.xxxx, cb10[13].xxyz, r1.xxyz
mad r0.xyz, r0.yyyy, cb10[15].xyzx, r0.xzwx
mov r0.w, l(1.000000)
dp4 r1.x, r0.xyzw, cb11[0].xyzw
dp4 r1.y, r0.xyzw, cb11[1].xyzw
dp4 r1.z, r0.xyzw, cb11[2].xyzw
mad o6.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), l(0.500489, 0.500489, 0.500489, 0.000000)
max o4.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
ret 
// Approximately 69 instruction slots used

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