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

cbuffer cbTextureTilingScale : register(b1)
{
  float4 FC_TextureTilingScale[25] : packoffset(c0);
}

cbuffer cbMtdParam : register(b3)
{
  float4 FC_DifMapMulCol : packoffset(c0);
  float4 FC_SpcMapMulCol : packoffset(c1);
  float4 FC_SpcParam : packoffset(c2);
  float4 FC_SSAOParam : packoffset(c3);
  float3 FC_CDRFParam : packoffset(c4);
  float4 FC_AlphaRef : packoffset(c5);
  float FC_BloodAmount : packoffset(c6);
  float4 old_FC_ParallaxParam : packoffset(c7);
  float FC_IOR : packoffset(c8);
  float4 FC_GlowScale : packoffset(c9);
  float4 FC_GhostEdgeColor : packoffset(c10);
  float4 FC_GhostEdgeParam : packoffset(c11);
  float4 FC_BmpBlendParam0 : packoffset(c12);
  float4 FC_BmpBlendParam1 : packoffset(c13);
  float FC_UNUSED_SSS_ID : packoffset(c14);
  float4 FC_Falloff_InsideColor : packoffset(c15);
  float4 FC_Falloff_OutsideColor : packoffset(c16);
  float4 FC_Falloff_Offset : packoffset(c17);
  float4 FC_Falloff_EdgePower : packoffset(c18);
  float4 FC_Falloff_HeightFade : packoffset(c19);
  float4 FC_HairSpecularParam0 : packoffset(c20);
  float4 FC_HairSpecularParam1 : packoffset(c21);
  float4 FC_HairSpecularParam2 : packoffset(c22);
  float4 FC_RimLightingParam : packoffset(c23);
  float4 FC_SAT_DUMMMY_P7_8 : packoffset(c24);
  float4 FC_SAT_DUMMMY_P7_9 : packoffset(c25);
  float4 FC_SAT_DUMMMY_P7_10 : packoffset(c26);
}

cbuffer cbInstanceData : register(b4)
{

  struct
  {
    float4x3 mWorld;
    float4 atlasUvScaleOffset;
    float4 userClipPlane;
    uint4 matricesData;
    uint envData;
    bool dynamicLightDisable;
    uint2 envPad;
    float4 mulCol;
    float4 aSh[3];
    float4 ShLightMask;
    float4 vDominantRotateParam;
    float4 parallaxCorrectedCubemapOrigin_envMapInterpRatio;
    float4 parallaxCorrectedCubemapAabbMin_envMapColorScale0;
    float4 parallaxCorrectedCubemapAabbMax_envMapColorScale1;
    float ditherFadeAlpha;
  } VC_InstanceData[2] : packoffset(c0);

}

SamplerState SS_DiffuseMap_s : register(s0);
Texture2D<float4> SATTest_ARN_snp_0_Texture2D_5 : register(t1);
Texture2D<float4> SATTest_ARN_snp_0_Texture2D_13 : register(t2);
Texture2D<float4> SATTest_ARN_snp_0_Texture2D_1 : register(t3);


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


void main( 
  float4 v0 : SV_POSITION0,
  float4 v1 : NORMAL0,
  float4 v2 : TANGENT0,
  float2 v3 : TEXCOORD0,
  uint v4 : SV_ISFRONTFACE0,
  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)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = dot(v1.xyz, v1.xyz);
  r0.x = rsqrt(r0.x);
  r0.xyz = v1.xyz * r0.xxx;
  r0.xyz = v4.xxx ? r0.xyz : -r0.xyz;
  r1.xyz = v2.yzx * v1.zxy;
  r1.xyz = v1.yzx * v2.zxy + -r1.xyz;
  r1.xyz = v2.www * r1.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r0.w = dot(v2.xyz, v2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = v2.xyz * r0.www;
  r3.xy = v3.xy * FC_TextureTilingScale[13].xy + FC_TextureTilingScale[13].zw;
  r3.xyz = SATTest_ARN_snp_0_Texture2D_13.Sample(SS_DiffuseMap_s, r3.xy).xyz;
  r3.xy = r3.xy * float2(2,2) + float2(-1,-1);
  o1.x = r3.z;
  r2.xyz = r3.yyy * r2.xyz;
  r1.xyz = r3.xxx * r1.xyz + r2.xyz;
  r0.w = dot(r3.xy, r3.xy);
  r0.w = min(1, r0.w);
  r0.w = 1 + -r0.w;
  r0.w = sqrt(r0.w);
  r0.xyz = r0.www * r0.xyz + r1.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  o0.xyz = r0.xyz * float3(0.5,0.5,0.5) + float3(0.500488758,0.500488758,0.500488758);
  r1.x = cmp(0 != FC_AlphaRef.z);
  r2.xz = float2(0,1);
  r1.y = round(v1.w);
  r1.y = (uint)r1.y;
  r1.y = (int)r1.y * 17;
  r1.z = (uint7)VC_InstanceData[r1.y].envData;
  r2.y = 0.00392156886 * r1.z;
  r2.xyw = r1.xxx ? VC_InstanceData[r1.y].mulCol.www : r2.yzx;
  o0.w = r2.w;
  o1.w = r2.w;
  o1.y = 0;
  o1.z = VC_InstanceData[r1.y].ShLightMask.x;
  r1.xz = v3.xy * FC_TextureTilingScale[1].xy + FC_TextureTilingScale[1].zw;
  r1.xzw = SATTest_ARN_snp_0_Texture2D_1.Sample(SS_DiffuseMap_s, r1.xz).xyz;
  o2.xyz = r1.xzw;
  o2.w = VC_InstanceData[r1.y].mulCol.w;
  o3.w = r2.x;
  o4.w = r2.y;
  r1.xz = v3.xy * FC_TextureTilingScale[5].xy + FC_TextureTilingScale[5].zw;
  r1.xzw = SATTest_ARN_snp_0_Texture2D_5.Sample(SS_DiffuseMap_s, r1.xz).xyz;
  o3.xyz = sqrt(r1.xzw);
  r1.xzw = float3(1,1,1) + -r1.xzw;
  r0.w = 1;
  r2.x = dot(r0.xyzw, VC_InstanceData[r1.y].aSh[0].xyzw);
  r2.y = dot(r0.xyzw, VC_InstanceData[r1.y].aSh[1].xyzw);
  r2.z = dot(r0.xyzw, VC_InstanceData[r1.y].aSh[2].xyzw);
  r0.xyz = max(float3(0,0,0), r2.xyz);
  o4.xyz = r0.xyz * r1.xzw;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbTextureTilingScale
// {
//
//   float4 FC_TextureTilingScale[25];  // Offset:    0 Size:   400
//
// }
//
// cbuffer cbMtdParam
// {
//
//   float4 FC_DifMapMulCol;            // Offset:    0 Size:    16 [unused]
//   float4 FC_SpcMapMulCol;            // Offset:   16 Size:    16 [unused]
//   float4 FC_SpcParam;                // Offset:   32 Size:    16 [unused]
//   float4 FC_SSAOParam;               // Offset:   48 Size:    16 [unused]
//   float3 FC_CDRFParam;               // Offset:   64 Size:    12 [unused]
//   float4 FC_AlphaRef;                // Offset:   80 Size:    16
//   float FC_BloodAmount;              // Offset:   96 Size:     4 [unused]
//   float4 old_FC_ParallaxParam;       // Offset:  112 Size:    16 [unused]
//   float FC_IOR;                      // Offset:  128 Size:     4 [unused]
//   float4 FC_GlowScale;               // Offset:  144 Size:    16 [unused]
//   float4 FC_GhostEdgeColor;          // Offset:  160 Size:    16 [unused]
//   float4 FC_GhostEdgeParam;          // Offset:  176 Size:    16 [unused]
//   float4 FC_BmpBlendParam0;          // Offset:  192 Size:    16 [unused]
//   float4 FC_BmpBlendParam1;          // Offset:  208 Size:    16 [unused]
//   float FC_UNUSED_SSS_ID;            // Offset:  224 Size:     4 [unused]
//   float4 FC_Falloff_InsideColor;     // Offset:  240 Size:    16 [unused]
//   float4 FC_Falloff_OutsideColor;    // Offset:  256 Size:    16 [unused]
//   float4 FC_Falloff_Offset;          // Offset:  272 Size:    16 [unused]
//   float4 FC_Falloff_EdgePower;       // Offset:  288 Size:    16 [unused]
//   float4 FC_Falloff_HeightFade;      // Offset:  304 Size:    16 [unused]
//   float4 FC_HairSpecularParam0;      // Offset:  320 Size:    16 [unused]
//   float4 FC_HairSpecularParam1;      // Offset:  336 Size:    16 [unused]
//   float4 FC_HairSpecularParam2;      // Offset:  352 Size:    16 [unused]
//   float4 FC_RimLightingParam;        // Offset:  368 Size:    16 [unused]
//   float4 FC_SAT_DUMMMY_P7_8;         // Offset:  384 Size:    16 [unused]
//   float4 FC_SAT_DUMMMY_P7_9;         // Offset:  400 Size:    16 [unused]
//   float4 FC_SAT_DUMMMY_P7_10;        // Offset:  416 Size:    16 [unused]
//
// }
//
// cbuffer cbInstanceData
// {
//
//   struct PerInstanceData
//   {
//       
//       float4x3 mWorld;               // Offset:    0
//       float4 atlasUvScaleOffset;     // Offset:   48
//       float4 userClipPlane;          // Offset:   64
//       uint4 matricesData;            // Offset:   80
//       uint envData;                  // Offset:   96
//       bool dynamicLightDisable;      // Offset:  100
//       uint2 envPad;                  // Offset:  104
//       float4 mulCol;                 // Offset:  112
//       float4 aSh[3];                 // Offset:  128
//       float4 ShLightMask;            // Offset:  176
//       float4 vDominantRotateParam;   // Offset:  192
//       float4 parallaxCorrectedCubemapOrigin_envMapInterpRatio;// Offset:  208
//       float4 parallaxCorrectedCubemapAabbMin_envMapColorScale0;// Offset:  224
//       float4 parallaxCorrectedCubemapAabbMax_envMapColorScale1;// Offset:  240
//       float ditherFadeAlpha;         // Offset:  256
//
//   } VC_InstanceData[2];              // Offset:    0 Size:   532
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_DiffuseMap                     sampler      NA          NA    0        1
// SATTest_ARN_snp_0_Texture2D_5     texture  float4          2d    1        1
// SATTest_ARN_snp_0_Texture2D_13    texture  float4          2d    2        1
// SATTest_ARN_snp_0_Texture2D_1     texture  float4          2d    3        1
// cbTextureTilingScale              cbuffer      NA          NA    1        1
// cbMtdParam                        cbuffer      NA          NA    3        1
// cbInstanceData                    cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float       
// NORMAL                   0   xyzw        1     NONE   float   xyzw
// TANGENT                  0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 0   xy          3     NONE   float   xy  
// SV_ISFRONTFACE           0   x           4    FFACE    uint   x   
//
//
// 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
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb1[14], immediateIndexed
dcl_constantbuffer cb3[6], immediateIndexed
dcl_constantbuffer cb4[34], dynamicIndexed
dcl_sampler s0, mode_default
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 v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xy
dcl_input_ps_sgv v4.x, is_front_face
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_temps 4
dp3 r0.x, v1.xyzx, v1.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v1.xyzx
movc r0.xyz, v4.xxxx, r0.xyzx, -r0.xyzx
mul r1.xyz, v1.zxyz, v2.yzxy
mad r1.xyz, v1.yzxy, v2.zxyz, -r1.xyzx
mul r1.xyz, r1.xyzx, v2.wwww
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
dp3 r0.w, v2.xyzx, v2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, v2.xyzx
mad r3.xy, v3.xyxx, cb1[13].xyxx, cb1[13].zwzz
sample_indexable(texture2d)(float,float,float,float) r3.xyz, r3.xyxx, t2.xyzw, s0
mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mov o1.x, r3.z
mul r2.xyz, r2.xyzx, r3.yyyy
mad r1.xyz, r3.xxxx, r1.xyzx, r2.xyzx
dp2 r0.w, r3.xyxx, r3.xyxx
min r0.w, r0.w, l(1.000000)
add r0.w, -r0.w, l(1.000000)
sqrt r0.w, r0.w
mad r0.xyz, r0.wwww, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mad o0.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), l(0.500489, 0.500489, 0.500489, 0.000000)
ne r1.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb3[5].z
mov r2.xz, l(0,0,1.000000,0)
round_ne r1.y, v1.w
ftou r1.y, r1.y
imul null, r1.y, r1.y, l(17)
utof r1.z, cb4[r1.y + 6].x
mul r2.y, r1.z, l(0.003922)
movc r2.xyw, r1.xxxx, cb4[r1.y + 7].wwww, r2.yzyx
mov o0.w, r2.w
mov o1.w, r2.w
mov o1.y, l(0)
mov o1.z, cb4[r1.y + 11].x
mad r1.xz, v3.xxyx, cb1[1].xxyx, cb1[1].zzwz
sample_indexable(texture2d)(float,float,float,float) r1.xzw, r1.xzxx, t3.xwyz, s0
mov o2.xyz, r1.xzwx
mov o2.w, cb4[r1.y + 7].w
mov o3.w, r2.x
mov o4.w, r2.y
mad r1.xz, v3.xxyx, cb1[5].xxyx, cb1[5].zzwz
sample_indexable(texture2d)(float,float,float,float) r1.xzw, r1.xzxx, t1.xwyz, s0
sqrt o3.xyz, r1.xzwx
add r1.xzw, -r1.xxzw, l(1.000000, 0.000000, 1.000000, 1.000000)
mov r0.w, l(1.000000)
dp4 r2.x, r0.xyzw, cb4[r1.y + 8].xyzw
dp4 r2.y, r0.xyzw, cb4[r1.y + 9].xyzw
dp4 r2.z, r0.xyzw, cb4[r1.y + 10].xyzw
max r0.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mul o4.xyz, r1.xzwx, r0.xyzx
ret 
// Approximately 57 instruction slots used

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