// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:30:49 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_HairSpecularParam0 : packoffset(c20);
  float4 FC_HairSpecularParam1 : packoffset(c21);
  float4 FC_HairSpecularParam2 : packoffset(c22);
  float4 FC_RimLightingParam : packoffset(c23);
}

cbuffer cbSceneParam : register(b8)
{
  float4 FC_FarClipInfo : packoffset(c0);
  float4 FC_ScreenSize : packoffset(c1);
  float4 FC_DepthComputeParam : packoffset(c2);
  float4 SC_CameraPos : packoffset(c3);
  float4 VC_ClipPlane : packoffset(c4);
  float4x3 FC_MatrixView : packoffset(c5);
  float4x4 FC_MatrixInvViewProj : packoffset(c8);
  float4x4 FC_MatrixInvProj : packoffset(c12);
  float4x4 FC_MatrixProj : packoffset(c16);
  float4x4 FC_MatrixInvView : packoffset(c20);
  float4x4 VC_MatrixViewProj : packoffset(c24);
  float4 FC_ShadowMapParam : packoffset(c28);
  float4 FC_ShadowColor : packoffset(c29);
  float4 FC_ShadowDir : packoffset(c30);
  float4x4 VC_ShadowMapMatrix : packoffset(c31);
  float FC_ShadowDepthRate : packoffset(c35);
  float FC_ShadowDepthScale : packoffset(c35.y);
  float FC_ShadowKernelScale : packoffset(c35.z);
  float FC_ShadowRandTexInvScale : packoffset(c35.w);
  float FC_ShadowTexInvScaleX : packoffset(c36);
  float FC_ShadowTexInvScaleY : packoffset(c36.y);
  float FC_ShadowDepthOffsetScale : packoffset(c36.z);
  float4 FC_ShadowViewKernelScale : packoffset(c37);
  float4x4 FC_ProjSpaceToShadowMatrix[4] : packoffset(c38);
  float4 FC_CascadeSelectDist : packoffset(c54);
  float FC_FrustumNear : packoffset(c55);
  float FC_FrustumSliceScale : packoffset(c55.y);
  float FC_FrustumSliceBias : packoffset(c55.z);
  uint FC_LightTile_Width : packoffset(c56);
  uint FC_LightTile_NumCellX : packoffset(c56.y);
  float4 FC_CloudShadowParam0 : packoffset(c57);
  float4 FC_CloudShadowParam1 : packoffset(c58);
  float FC_ShadowScale0 : packoffset(c59);
  float FC_ShadowScale1 : packoffset(c59.y);
}

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);

}

cbuffer cbLight : register(b5)
{
  float4 FC_DirLightVec_0 : packoffset(c0);
  float4 FC_DirLightVec_1 : packoffset(c1);
  float4 FC_DirLightVec_2 : packoffset(c2);
  float4 FC_DirLightVec_3 : packoffset(c3);
  float4 FC_DirLightCol_0 : packoffset(c4);
  float4 FC_DirLightCol_1 : packoffset(c5);
  float4 FC_DirLightCol_2 : packoffset(c6);
  float4 FC_DirLightCol_3 : packoffset(c7);
  float4 FC_DirLightSpc_0 : packoffset(c8);
  float4 FC_DirLightSpc_1 : packoffset(c9);
  float4 FC_DirLightSpc_2 : packoffset(c10);
  float4 FC_DirLightSpc_3 : packoffset(c11);
  float4 FC_AmbientSH[3] : packoffset(c12);
  float4 FC_AmbientReflection : packoffset(c15);
  uint4 FC_bLocalLight : packoffset(c16);
  float4 FC_SsaoWeight : packoffset(c17);
}

cbuffer cbFog : register(b6)
{
  float4 FC_FogParam : packoffset(c0);
  float4 FC_FogCol : packoffset(c1);
  float4 FC_ExtFogParam : packoffset(c2);
  float4 FC_HeightFogParam : packoffset(c3);
  float4 FC_HeightFogCol : packoffset(c4);
  bool FC_FogType : packoffset(c5);
  float4 FC_LsBeta1PlusBeta2 : packoffset(c6);
  float4 FC_LsTerrainReflectance : packoffset(c7);
  float4 FC_LsOneOverBeta1PlusBeta2 : packoffset(c8);
  float4 FC_LsHGg : packoffset(c9);
  float4 FC_LsBetaDash1 : packoffset(c10);
  float4 FC_LsBetaDash2 : packoffset(c11);
  float4 FC_LsSunColor : packoffset(c12);
  float4 FC_LsLightDir : packoffset(c13);
}

SamplerState SS_DiffuseMap_s : register(s0);
SamplerState SS_WrapLinear_s : register(s8);
Texture2D<float4> g_DiffuseTexture : register(t0);
Texture2D<float4> g_ShadowTexture : register(t32);
Texture2D<float4> g_SSAOTexture : register(t33);
StructuredBuffer<g_LightIndices> g_LightIndices : register(t59);
StructuredBuffer<g_LightLookupBuffer> g_LightLookupBuffer : register(t60);
StructuredBuffer<g_LightBuffer> g_LightBuffer : register(t61);
StructuredBuffer<g_SpotLightBuffer> g_SpotLightBuffer : register(t62);


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


void main( 
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  float4 v2 : COLOR1,
  float4 v3 : TEXCOORD4,
  float4 v4 : TEXCOORD7,
  uint v5 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0)
{
// Needs manual fix for instruction: 
// unknown dcl_: dcl_resource_structured t59, 8 
// Needs manual fix for instruction: 
// unknown dcl_: dcl_resource_structured t60, 12 
// Needs manual fix for instruction: 
// unknown dcl_: dcl_resource_structured t61, 64 
// Needs manual fix for instruction: 
// unknown dcl_: dcl_resource_structured t62, 128 
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = dot(v1.xyz, v1.xyz);
  r0.x = rsqrt(r0.x);
  r0.xyz = v1.xyz * r0.xxx;
  r0.w = round(v1.w);
  r0.w = (uint)r0.w;
  r1.x = dot(v4.xyzw, FC_MatrixInvViewProj._m00_m10_m20_m30);
  r1.y = dot(v4.xyzw, FC_MatrixInvViewProj._m01_m11_m21_m31);
  r1.z = dot(v4.xyzw, FC_MatrixInvViewProj._m02_m12_m22_m32);
  r1.w = dot(v4.xyzw, FC_MatrixInvViewProj._m03_m13_m23_m33);
  r1.xyz = r1.xyz / r1.www;
  r2.x = FC_MatrixInvView._m30 + -r1.x;
  r1.x = FC_MatrixInvView._m31 + -r1.y;
  r2.z = FC_MatrixInvView._m32 + -r1.z;
  r1.yz = FC_ScreenSize.zw * v0.xy;
  r3.xyz = v5.xxx ? r0.xyz : -r0.xyz;
  r0.xy = v3.xy * FC_TextureTilingScale[0].xy + FC_TextureTilingScale[0].zw;
  r4.xyzw = g_DiffuseTexture.Sample(SS_DiffuseMap_s, r0.xy).xyzw;
  r5.x = 1;
  r5.w = v2.w;
  r4.xyzw = r5.xxxw * r4.xyzw;
  r0.xyz = FC_DifMapMulCol.xyz * r4.xyz;
  r1.w = g_SSAOTexture.Sample(SS_WrapLinear_s, r1.yz).x;
  r1.w = r1.w * FC_SSAOParam.x + 1;
  r1.w = -FC_SSAOParam.x + r1.w;
  r2.y = cmp(v2.x == 0.000000);
  r2.y = r2.y ? 1 : v2.x;
  r2.y = r2.y * r1.w;
  r0.w = (int)r0.w * 17;
  r3.w = 1;
  r5.x = dot(r3.xyzw, VC_InstanceData[r0.w].aSh[0].xyzw);
  r5.y = dot(r3.xyzw, VC_InstanceData[r0.w].aSh[1].xyzw);
  r5.z = dot(r3.xyzw, VC_InstanceData[r0.w].aSh[2].xyzw);
  r5.xyz = max(float3(0,0,0), r5.xyz);
  r2.w = g_ShadowTexture.Sample(SS_WrapLinear_s, r1.yz).w;
  r6.xyz = -FC_ShadowColor.xyz + float3(1,1,1);
  r7.xyz = float3(1,1,1) + -r6.xyz;
  r6.xyz = r2.www * r7.xyz + r6.xyz;
  r6.xyz = VC_InstanceData[r0.w].ShLightMask.xxx * r6.xyz;
  r6.xyz = FC_DirLightCol_0.xyz * r6.xyz;
  r2.w = saturate(dot(FC_DirLightVec_0.xyz, r3.xyz));
  r3.w = saturate(dot(FC_DirLightVec_1.xyz, r3.xyz));
  r7.xyz = FC_DirLightCol_1.xyz * r3.www;
  r6.xyz = r6.xyz * r2.www + r7.xyz;
  if (FC_bLocalLight.x != 0) {
    r2.w = dot(FC_DirLightVec_2.xyz, r3.xyz);
    r2.w = r2.w * 0.5 + 0.5;
    r2.w = r2.w * r2.w;
    r2.w = min(1, r2.w);
    r6.xyz = FC_DirLightCol_2.xyz * r2.www + r6.xyz;
  }
  if (FC_bLocalLight.y != 0) {
    r2.w = dot(FC_DirLightVec_3.xyz, r3.xyz);
    r2.w = r2.w * 0.5 + 0.5;
    r2.w = r2.w * r2.w;
    r2.w = min(1, r2.w);
    r6.xyz = FC_DirLightCol_3.xyz * r2.www + r6.xyz;
  }
  if (VC_InstanceData[r0.w].dynamicLightDisable == 0) {
    r7.x = dot(r3.xyz, FC_MatrixView._m00_m10_m20);
    r7.y = dot(r3.xyz, FC_MatrixView._m01_m11_m21);
    r7.z = dot(r3.xyz, FC_MatrixView._m02_m12_m22);
    r3.x = dot(v4.xyzw, FC_MatrixInvProj._m00_m10_m20_m30);
    r3.y = dot(v4.xyzw, FC_MatrixInvProj._m01_m11_m21_m31);
    r3.z = dot(v4.xyzw, FC_MatrixInvProj._m02_m12_m22_m32);
    r2.w = dot(v4.xyzw, FC_MatrixInvProj._m03_m13_m23_m33);
    r3.xyz = r3.xyz / r2.www;
    r1.yz = FC_ScreenSize.xy * r1.yz;
    r1.yz = (uint2)r1.yz;
    uiDest.yz = (uint2)r1.yz / FC_LightTile_Width;
    r1.yz = uiDest.yz;
    r1.yz = (uint2)r1.yz;
    r2.w = FC_LightTile_NumCellX;
    r1.y = r1.z * r2.w + r1.y;
    r1.z = -FC_FrustumNear + r3.z;
    r1.z = log2(r1.z);
    r1.z = -FC_FrustumSliceBias + r1.z;
    r1.z = r1.z / FC_FrustumSliceScale;
    r1.z = max(0, r1.z);
    r1.z = min(14, r1.z);
    r1.yz = (uint2)r1.yz;
    r1.z = 1 << (int)r1.z;
  // Known bad code for instruction (needs manual fix):
    ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r8.xyz, r1.y, l(0), t60.xyzx
  r8.x = SS_DiffuseMap[]..swiz;
  r8.y = SS_DiffuseMap[]..swiz;
  r8.z = SS_DiffuseMap[]..swiz;
    r9.xyz = float3(0,0,0);
    r1.y = r8.x;
    r2.w = 0;
    while (true) {
      r5.w = cmp((uint)r2.w >= (uint)r8.y);
      if (r5.w != 0) break;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r10.xy, r1.y, l(0), t59.xyxx
    r10.x = SS_DiffuseMap[]..swiz;
    r10.y = SS_DiffuseMap[]..swiz;
      r5.w = (int)r1.y + 1;
      r6.w = (int)r1.z & (int)r10.y;
      r7.w = (int)r2.w + 1;
      r2.w = r6.w ? r2.w : r7.w;
      r1.y = r5.w;
      if (r6.w == 0) continue;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r11.xyzw, r10.x, l(0), t61.xyzw
    r11.x = SS_DiffuseMap[]..swiz;
    r11.y = SS_DiffuseMap[]..swiz;
    r11.z = SS_DiffuseMap[]..swiz;
    r11.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r10.xyz, r10.x, l(16), t61.xyzx
    r10.x = SS_DiffuseMap[]..swiz;
    r10.y = SS_DiffuseMap[]..swiz;
    r10.z = SS_DiffuseMap[]..swiz;
      r11.xyz = r11.xyz + -r3.xyz;
      r6.w = dot(r11.xyz, r11.xyz);
      r8.w = rsqrt(r6.w);
      r11.xyz = r11.xyz * r8.www;
      r8.w = saturate(dot(r7.xyz, r11.xyz));
      r6.w = saturate(r6.w * r11.w);
      r6.w = sqrt(r6.w);
      r6.w = 1 + -r6.w;
      r6.w = r6.w * r6.w;
      r10.xyz = r10.xyz * r8.www;
      r9.xyz = r10.xyz * r6.www + r9.xyz;
      r2.w = r7.w;
      r1.y = r5.w;
    }
    r2.w = (uint)r8.z >> 16;
    r3.w = 1;
    r8.w = 1;
    r10.xyz = r9.xyz;
    r5.w = r1.y;
    r6.w = 0;
    while (true) {
      r7.w = cmp((uint)r6.w >= (uint)r2.w);
      if (r7.w != 0) break;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r11.xy, r5.w, l(0), t59.xyxx
    r11.x = SS_DiffuseMap[]..swiz;
    r11.y = SS_DiffuseMap[]..swiz;
      r7.w = (int)r5.w + 1;
      r9.w = (int)r1.z & (int)r11.y;
      r10.w = (int)r6.w + 1;
      r6.w = r9.w ? r6.w : r10.w;
      r5.w = r7.w;
      if (r9.w == 0) continue;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.xyzw, r11.x, l(0), t62.xyzw
    r12.x = SS_DiffuseMap[]..swiz;
    r12.y = SS_DiffuseMap[]..swiz;
    r12.z = SS_DiffuseMap[]..swiz;
    r12.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r11.yzw, r11.x, l(16), t62.xxyz
    r11.y = SS_DiffuseMap[]..swiz;
    r11.z = SS_DiffuseMap[]..swiz;
    r11.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r11.x, l(60), t62.xyzw
    r13.x = SS_DiffuseMap[]..swiz;
    r13.y = SS_DiffuseMap[]..swiz;
    r13.z = SS_DiffuseMap[]..swiz;
    r13.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r14.xyzw, r11.x, l(76), t62.yzwx
    r14.x = SS_DiffuseMap[]..swiz;
    r14.y = SS_DiffuseMap[]..swiz;
    r14.z = SS_DiffuseMap[]..swiz;
    r14.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r15.xyzw, r11.x, l(92), t62.yzwx
    r15.x = SS_DiffuseMap[]..swiz;
    r15.y = SS_DiffuseMap[]..swiz;
    r15.z = SS_DiffuseMap[]..swiz;
    r15.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r16.xyzw, r11.x, l(108), t62.xyzw
    r16.x = SS_DiffuseMap[]..swiz;
    r16.y = SS_DiffuseMap[]..swiz;
    r16.z = SS_DiffuseMap[]..swiz;
    r16.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r17.w, r11.x, l(124), t62.xxxx
    r17.w = SS_DiffuseMap[]..swiz;
      r18.xyz = r13.yzw;
      r18.w = r14.w;
      r18.x = dot(r3.xyzw, r18.xyzw);
      r14.w = r15.w;
      r18.y = dot(r3.xyzw, r14.xyzw);
      r15.w = r16.x;
      r9.w = dot(r3.xyzw, r15.xyzw);
      r17.xyz = r16.yzw;
      r11.x = dot(r3.xyzw, r17.xyzw);
      r9.w = cmp(0 < r9.w);
      r12.xyz = r12.xyz + -r3.xyz;
      r13.y = dot(r12.xyz, r12.xyz);
      r13.z = rsqrt(r13.y);
      r12.xyz = r13.zzz * r12.xyz;
      r13.x = cmp(0 < r13.x);
      r13.z = r12.w * r12.w;
      r13.z = 1 / r13.z;
      r14.x = 1 / r13.y;
      r13.y = r14.x + -r13.z;
      r14.w = max(0, r13.y);
      r14.y = saturate(dot(r12.xyz, r7.xyz));
      r12.xy = r18.xy / r11.xx;
      r12.x = dot(r12.xy, r12.xy);
      r12.x = 1 + -r12.x;
      r14.z = max(0, r12.x);
      r11.x = r11.x / r12.w;
      r11.x = saturate(1 + -r11.x);
      r8.z = r14.z * r14.z;
      r8.x = r11.x * r11.x;
      r8.y = r14.y;
      r12.xyzw = r13.xxxx ? r14.xyzw : r8.xyzw;
      r8.xy = r12.zz * r12.wx;
      r11.xyz = r12.yyy * r11.yzw;
      r12.xyz = r11.xyz * r8.xxx;
      r8.xyz = r11.xyz * r8.yyy;
      r8.xyz = r13.xxx ? r12.xyz : r8.xyz;
      r8.xyz = r9.www ? r8.xyz : 0;
      r10.xyz = r10.xyz + r8.xyz;
      r6.w = r10.w;
      r5.w = r7.w;
    }
    r6.xyz = r10.xyz * r1.www + r6.xyz;
  }
  r1.yzw = r5.xyz * r2.yyy + r6.xyz;
  r4.xyz = r1.yzw * r0.xyz;
  r0.xyzw = VC_InstanceData[r0.w].mulCol.xyzw * r4.xyzw;
  r1.x = FC_HeightFogParam.w + -r1.x;
  r1.x = -FC_HeightFogParam.y + r1.x;
  r1.x = saturate(FC_HeightFogParam.z * r1.x);
  r1.y = dot(-r2.xz, -r2.xz);
  r1.y = sqrt(r1.y);
  r1.y = -FC_ExtFogParam.y + r1.y;
  r1.y = FC_ExtFogParam.z * r1.y;
  r1.y = exp2(-r1.y);
  r1.y = saturate(-r1.y * FC_ExtFogParam.x + FC_ExtFogParam.x);
  r1.x = saturate(FC_HeightFogParam.x * r1.x);
  r1.z = dot(r0.xyz, float3(0.298909992,0.586610019,0.114480004));
  r1.z = -1 + r1.z;
  r1.w = FC_FogCol.w * r1.z + 1;
  r1.z = FC_HeightFogCol.w * r1.z + 1;
  r2.xyz = FC_FogCol.xyz * r1.www + -r0.xyz;
  r0.xyz = r1.yyy * r2.xyz + r0.xyz;
  r1.yzw = FC_HeightFogCol.xyz * r1.zzz + -r0.xyz;
  o0.xyz = r1.xxx * r1.yzw + r0.xyz;
  o0.w = r0.w;
  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
//   float4 FC_SpcMapMulCol;            // Offset:   16 Size:    16 [unused]
//   float4 FC_SpcParam;                // Offset:   32 Size:    16 [unused]
//   float4 FC_SSAOParam;               // Offset:   48 Size:    16
//   float3 FC_CDRFParam;               // Offset:   64 Size:    12 [unused]
//   float4 FC_AlphaRef;                // Offset:   80 Size:    16 [unused]
//   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_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]
//
// }
//
// cbuffer cbSceneParam
// {
//
//   float4 FC_FarClipInfo;             // Offset:    0 Size:    16 [unused]
//   float4 FC_ScreenSize;              // Offset:   16 Size:    16
//   float4 FC_DepthComputeParam;       // Offset:   32 Size:    16 [unused]
//   float4 SC_CameraPos;               // Offset:   48 Size:    16 [unused]
//   float4 VC_ClipPlane;               // Offset:   64 Size:    16 [unused]
//   float4x3 FC_MatrixView;            // Offset:   80 Size:    48
//   float4x4 FC_MatrixInvViewProj;     // Offset:  128 Size:    64
//   float4x4 FC_MatrixInvProj;         // Offset:  192 Size:    64
//   float4x4 FC_MatrixProj;            // Offset:  256 Size:    64 [unused]
//   float4x4 FC_MatrixInvView;         // Offset:  320 Size:    64
//   float4x4 VC_MatrixViewProj;        // Offset:  384 Size:    64 [unused]
//   float4 FC_ShadowMapParam;          // Offset:  448 Size:    16 [unused]
//   float4 FC_ShadowColor;             // Offset:  464 Size:    16
//   float4 FC_ShadowDir;               // Offset:  480 Size:    16 [unused]
//   float4x4 VC_ShadowMapMatrix;       // Offset:  496 Size:    64 [unused]
//   float FC_ShadowDepthRate;          // Offset:  560 Size:     4 [unused]
//   float FC_ShadowDepthScale;         // Offset:  564 Size:     4 [unused]
//   float FC_ShadowKernelScale;        // Offset:  568 Size:     4 [unused]
//   float FC_ShadowRandTexInvScale;    // Offset:  572 Size:     4 [unused]
//   float FC_ShadowTexInvScaleX;       // Offset:  576 Size:     4 [unused]
//   float FC_ShadowTexInvScaleY;       // Offset:  580 Size:     4 [unused]
//   float FC_ShadowDepthOffsetScale;   // Offset:  584 Size:     4 [unused]
//   float4 FC_ShadowViewKernelScale;   // Offset:  592 Size:    16 [unused]
//   float4x4 FC_ProjSpaceToShadowMatrix[4];// Offset:  608 Size:   256 [unused]
//   float4 FC_CascadeSelectDist;       // Offset:  864 Size:    16 [unused]
//   float FC_FrustumNear;              // Offset:  880 Size:     4
//   float FC_FrustumSliceScale;        // Offset:  884 Size:     4
//   float FC_FrustumSliceBias;         // Offset:  888 Size:     4
//   uint FC_LightTile_Width;           // Offset:  896 Size:     4
//   uint FC_LightTile_NumCellX;        // Offset:  900 Size:     4
//   float4 FC_CloudShadowParam0;       // Offset:  912 Size:    16 [unused]
//   float4 FC_CloudShadowParam1;       // Offset:  928 Size:    16 [unused]
//   float FC_ShadowScale0;             // Offset:  944 Size:     4 [unused]
//   float FC_ShadowScale1;             // Offset:  948 Size:     4 [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
//
// }
//
// cbuffer cbLight
// {
//
//   float4 FC_DirLightVec_0;           // Offset:    0 Size:    16
//   float4 FC_DirLightVec_1;           // Offset:   16 Size:    16
//   float4 FC_DirLightVec_2;           // Offset:   32 Size:    16
//   float4 FC_DirLightVec_3;           // Offset:   48 Size:    16
//   float4 FC_DirLightCol_0;           // Offset:   64 Size:    16
//   float4 FC_DirLightCol_1;           // Offset:   80 Size:    16
//   float4 FC_DirLightCol_2;           // Offset:   96 Size:    16
//   float4 FC_DirLightCol_3;           // Offset:  112 Size:    16
//   float4 FC_DirLightSpc_0;           // Offset:  128 Size:    16 [unused]
//   float4 FC_DirLightSpc_1;           // Offset:  144 Size:    16 [unused]
//   float4 FC_DirLightSpc_2;           // Offset:  160 Size:    16 [unused]
//   float4 FC_DirLightSpc_3;           // Offset:  176 Size:    16 [unused]
//   float4 FC_AmbientSH[3];            // Offset:  192 Size:    48 [unused]
//   float4 FC_AmbientReflection;       // Offset:  240 Size:    16 [unused]
//   uint4 FC_bLocalLight;              // Offset:  256 Size:    16
//   float4 FC_SsaoWeight;              // Offset:  272 Size:    16 [unused]
//
// }
//
// cbuffer cbFog
// {
//
//   float4 FC_FogParam;                // Offset:    0 Size:    16 [unused]
//   float4 FC_FogCol;                  // Offset:   16 Size:    16
//   float4 FC_ExtFogParam;             // Offset:   32 Size:    16
//   float4 FC_HeightFogParam;          // Offset:   48 Size:    16
//   float4 FC_HeightFogCol;            // Offset:   64 Size:    16
//   bool FC_FogType;                   // Offset:   80 Size:     4 [unused]
//   float4 FC_LsBeta1PlusBeta2;        // Offset:   96 Size:    16 [unused]
//   float4 FC_LsTerrainReflectance;    // Offset:  112 Size:    16 [unused]
//   float4 FC_LsOneOverBeta1PlusBeta2; // Offset:  128 Size:    16 [unused]
//   float4 FC_LsHGg;                   // Offset:  144 Size:    16 [unused]
//   float4 FC_LsBetaDash1;             // Offset:  160 Size:    16 [unused]
//   float4 FC_LsBetaDash2;             // Offset:  176 Size:    16 [unused]
//   float4 FC_LsSunColor;              // Offset:  192 Size:    16 [unused]
//   float4 FC_LsLightDir;              // Offset:  208 Size:    16 [unused]
//
// }
//
// Resource bind info for g_LightIndices
// {
//
//   uint2 $Element;                    // Offset:    0 Size:     8
//
// }
//
// Resource bind info for g_LightLookupBuffer
// {
//
//   uint3 $Element;                    // Offset:    0 Size:    12
//
// }
//
// Resource bind info for g_LightBuffer
// {
//
//   struct PointLight
//   {
//       
//       float4 PositionAndRadius;      // Offset:    0
//       float4 DiffColor;              // Offset:   16
//       float4 SpecColor;              // Offset:   32
//       float4 TransLightParam;        // Offset:   48
//
//   } $Element;                        // Offset:    0 Size:    64
//
// }
//
// Resource bind info for g_SpotLightBuffer
// {
//
//   struct SpotLight
//   {
//       
//       float4 PositionAndRange;       // Offset:    0
//       float4 DiffColor;              // Offset:   16
//       float4 SpecColor;              // Offset:   32
//       float3 TransLightParam;        // Offset:   48
//       float ShadingMode;             // Offset:   60
//       float4x4 ViewToLightSpaceMatrix;// Offset:   64
//
//   } $Element;                        // Offset:    0 Size:   128
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_DiffuseMap                     sampler      NA          NA    0        1
// SS_WrapLinear                     sampler      NA          NA    8        1
// g_DiffuseTexture                  texture  float4          2d    0        1
// g_ShadowTexture                   texture  float4          2d   32        1
// g_SSAOTexture                     texture  float4          2d   33        1
// g_LightIndices                    texture  struct         r/o   59        1
// g_LightLookupBuffer               texture  struct         r/o   60        1
// g_LightBuffer                     texture  struct         r/o   61        1
// g_SpotLightBuffer                 texture  struct         r/o   62        1
// cbTextureTilingScale              cbuffer      NA          NA    1        1
// cbMtdParam                        cbuffer      NA          NA    3        1
// cbInstanceData                    cbuffer      NA          NA    4        1
// cbLight                           cbuffer      NA          NA    5        1
// cbFog                             cbuffer      NA          NA    6        1
// cbSceneParam                      cbuffer      NA          NA    8        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy  
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// COLOR                    1   xyzw        2     NONE   float   x  w
// TEXCOORD                 4   xy          3     NONE   float   xy  
// TEXCOORD                 7   xyzw        4     NONE   float   xyzw
// SV_IsFrontFace           0   x           5    FFACE    uint   x   
//
//
// 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 cb1[1], immediateIndexed
dcl_constantbuffer cb3[4], immediateIndexed
dcl_constantbuffer cb8[57], immediateIndexed
dcl_constantbuffer cb4[34], dynamicIndexed
dcl_constantbuffer cb5[17], immediateIndexed
dcl_constantbuffer cb6[5], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s8, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t32
dcl_resource_texture2d (float,float,float,float) t33
dcl_resource_structured t59, 8 
dcl_resource_structured t60, 12 
dcl_resource_structured t61, 64 
dcl_resource_structured t62, 128 
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xw
dcl_input_ps linear v3.xy
dcl_input_ps linear v4.xyzw
dcl_input_ps_sgv v5.x, is_front_face
dcl_output o0.xyzw
dcl_temps 19
dp3 r0.x, v1.xyzx, v1.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v1.xyzx
round_ne r0.w, v1.w
ftou r0.w, r0.w
dp4 r1.x, v4.xyzw, cb8[8].xyzw
dp4 r1.y, v4.xyzw, cb8[9].xyzw
dp4 r1.z, v4.xyzw, cb8[10].xyzw
dp4 r1.w, v4.xyzw, cb8[11].xyzw
div r1.xyz, r1.xyzx, r1.wwww
add r2.x, -r1.x, cb8[20].w
add r1.x, -r1.y, cb8[21].w
add r2.z, -r1.z, cb8[22].w
mul r1.yz, v0.xxyx, cb8[1].zzwz
movc r3.xyz, v5.xxxx, r0.xyzx, -r0.xyzx
mad r0.xy, v3.xyxx, cb1[0].xyxx, cb1[0].zwzz
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r0.xyxx, t0.xyzw, s0
mov r5.x, l(1.000000)
mov r5.w, v2.w
mul r4.xyzw, r4.xyzw, r5.xxxw
mul r0.xyz, r4.xyzx, cb3[0].xyzx
sample_indexable(texture2d)(float,float,float,float) r1.w, r1.yzyy, t33.yzwx, s8
mad r1.w, r1.w, cb3[3].x, l(1.000000)
add r1.w, r1.w, -cb3[3].x
eq r2.y, v2.x, l(0.000000)
movc r2.y, r2.y, l(1.000000), v2.x
mul r2.y, r1.w, r2.y
imul null, r0.w, r0.w, l(17)
mov r3.w, l(1.000000)
dp4 r5.x, r3.xyzw, cb4[r0.w + 8].xyzw
dp4 r5.y, r3.xyzw, cb4[r0.w + 9].xyzw
dp4 r5.z, r3.xyzw, cb4[r0.w + 10].xyzw
max r5.xyz, r5.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r2.w, r1.yzyy, t32.xyzw, s8
add r6.xyz, l(1.000000, 1.000000, 1.000000, 0.000000), -cb8[29].xyzx
add r7.xyz, -r6.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r6.xyz, r2.wwww, r7.xyzx, r6.xyzx
mul r6.xyz, r6.xyzx, cb4[r0.w + 11].xxxx
mul r6.xyz, r6.xyzx, cb5[4].xyzx
dp3_sat r2.w, cb5[0].xyzx, r3.xyzx
dp3_sat r3.w, cb5[1].xyzx, r3.xyzx
mul r7.xyz, r3.wwww, cb5[5].xyzx
mad r6.xyz, r6.xyzx, r2.wwww, r7.xyzx
if_nz cb5[16].x
  dp3 r2.w, cb5[2].xyzx, r3.xyzx
  mad r2.w, r2.w, l(0.500000), l(0.500000)
  mul r2.w, r2.w, r2.w
  min r2.w, r2.w, l(1.000000)
  mad r6.xyz, cb5[6].xyzx, r2.wwww, r6.xyzx
endif 
if_nz cb5[16].y
  dp3 r2.w, cb5[3].xyzx, r3.xyzx
  mad r2.w, r2.w, l(0.500000), l(0.500000)
  mul r2.w, r2.w, r2.w
  min r2.w, r2.w, l(1.000000)
  mad r6.xyz, cb5[7].xyzx, r2.wwww, r6.xyzx
endif 
if_z cb4[r0.w + 6].y
  dp3 r7.x, r3.xyzx, cb8[5].xyzx
  dp3 r7.y, r3.xyzx, cb8[6].xyzx
  dp3 r7.z, r3.xyzx, cb8[7].xyzx
  dp4 r3.x, v4.xyzw, cb8[12].xyzw
  dp4 r3.y, v4.xyzw, cb8[13].xyzw
  dp4 r3.z, v4.xyzw, cb8[14].xyzw
  dp4 r2.w, v4.xyzw, cb8[15].xyzw
  div r3.xyz, r3.xyzx, r2.wwww
  mul r1.yz, r1.yyzy, cb8[1].xxyx
  ftou r1.yz, r1.yyzy
  udiv r1.yz, null, r1.yyzy, cb8[56].xxxx
  utof r1.yz, r1.yyzy
  utof r2.w, cb8[56].y
  mad r1.y, r1.z, r2.w, r1.y
  add r1.z, r3.z, -cb8[55].x
  log r1.z, r1.z
  add r1.z, r1.z, -cb8[55].z
  div r1.z, r1.z, cb8[55].y
  max r1.z, r1.z, l(0.000000)
  min r1.z, r1.z, l(14.000000)
  ftou r1.yz, r1.yyzy
  ishl r1.z, l(1), r1.z
  ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r8.xyz, r1.y, l(0), t60.xyzx
  mov r9.xyz, l(0,0,0,0)
  mov r1.y, r8.x
  mov r2.w, l(0)
  loop 
    uge r5.w, r2.w, r8.y
    breakc_nz r5.w
    ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r10.xy, r1.y, l(0), t59.xyxx
    iadd r5.w, r1.y, l(1)
    and r6.w, r1.z, r10.y
    iadd r7.w, r2.w, l(1)
    movc r2.w, r6.w, r2.w, r7.w
    mov r1.y, r5.w
    continuec_z r6.w
    ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r11.xyzw, r10.x, l(0), t61.xyzw
    ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r10.xyz, r10.x, l(16), t61.xyzx
    add r11.xyz, -r3.xyzx, r11.xyzx
    dp3 r6.w, r11.xyzx, r11.xyzx
    rsq r8.w, r6.w
    mul r11.xyz, r8.wwww, r11.xyzx
    dp3_sat r8.w, r7.xyzx, r11.xyzx
    mul_sat r6.w, r11.w, r6.w
    sqrt r6.w, r6.w
    add r6.w, -r6.w, l(1.000000)
    mul r6.w, r6.w, r6.w
    mul r10.xyz, r8.wwww, r10.xyzx
    mad r9.xyz, r10.xyzx, r6.wwww, r9.xyzx
    mov r2.w, r7.w
    mov r1.y, r5.w
  endloop 
  ushr r2.w, r8.z, l(16)
  mov r3.w, l(1.000000)
  mov r8.w, l(1.000000)
  mov r10.xyz, r9.xyzx
  mov r5.w, r1.y
  mov r6.w, l(0)
  loop 
    uge r7.w, r6.w, r2.w
    breakc_nz r7.w
    ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r11.xy, r5.w, l(0), t59.xyxx
    iadd r7.w, r5.w, l(1)
    and r9.w, r1.z, r11.y
    iadd r10.w, r6.w, l(1)
    movc r6.w, r9.w, r6.w, r10.w
    mov r5.w, r7.w
    continuec_z r9.w
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.xyzw, r11.x, l(0), t62.xyzw
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r11.yzw, r11.x, l(16), t62.xxyz
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r11.x, l(60), t62.xyzw
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r14.xyzw, r11.x, l(76), t62.yzwx
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r15.xyzw, r11.x, l(92), t62.yzwx
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r16.xyzw, r11.x, l(108), t62.xyzw
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r17.w, r11.x, l(124), t62.xxxx
    mov r18.xyz, r13.yzwy
    mov r18.w, r14.w
    dp4 r18.x, r3.xyzw, r18.xyzw
    mov r14.w, r15.w
    dp4 r18.y, r3.xyzw, r14.xyzw
    mov r15.w, r16.x
    dp4 r9.w, r3.xyzw, r15.xyzw
    mov r17.xyz, r16.yzwy
    dp4 r11.x, r3.xyzw, r17.xyzw
    lt r9.w, l(0.000000), r9.w
    add r12.xyz, -r3.xyzx, r12.xyzx
    dp3 r13.y, r12.xyzx, r12.xyzx
    rsq r13.z, r13.y
    mul r12.xyz, r12.xyzx, r13.zzzz
    lt r13.x, l(0.000000), r13.x
    mul r13.z, r12.w, r12.w
    div r13.z, l(1.000000, 1.000000, 1.000000, 1.000000), r13.z
    div r14.x, l(1.000000, 1.000000, 1.000000, 1.000000), r13.y
    add r13.y, -r13.z, r14.x
    max r14.w, r13.y, l(0.000000)
    dp3_sat r14.y, r12.xyzx, r7.xyzx
    div r12.xy, r18.xyxx, r11.xxxx
    dp2 r12.x, r12.xyxx, r12.xyxx
    add r12.x, -r12.x, l(1.000000)
    max r14.z, r12.x, l(0.000000)
    div r11.x, r11.x, r12.w
    add_sat r11.x, -r11.x, l(1.000000)
    mul r8.z, r14.z, r14.z
    mul r8.x, r11.x, r11.x
    mov r8.y, r14.y
    movc r12.xyzw, r13.xxxx, r14.xyzw, r8.xyzw
    mul r8.xy, r12.wxww, r12.zzzz
    mul r11.xyz, r11.yzwy, r12.yyyy
    mul r12.xyz, r8.xxxx, r11.xyzx
    mul r8.xyz, r8.yyyy, r11.xyzx
    movc r8.xyz, r13.xxxx, r12.xyzx, r8.xyzx
    and r8.xyz, r8.xyzx, r9.wwww
    add r10.xyz, r8.xyzx, r10.xyzx
    mov r6.w, r10.w
    mov r5.w, r7.w
  endloop 
  mad r6.xyz, r10.xyzx, r1.wwww, r6.xyzx
endif 
mad r1.yzw, r5.xxyz, r2.yyyy, r6.xxyz
mul r4.xyz, r0.xyzx, r1.yzwy
mul r0.xyzw, r4.xyzw, cb4[r0.w + 7].xyzw
add r1.x, -r1.x, cb6[3].w
add r1.x, r1.x, -cb6[3].y
mul_sat r1.x, r1.x, cb6[3].z
dp2 r1.y, -r2.xzxx, -r2.xzxx
sqrt r1.y, r1.y
add r1.y, r1.y, -cb6[2].y
mul r1.y, r1.y, cb6[2].z
exp r1.y, -r1.y
mad_sat r1.y, -r1.y, cb6[2].x, cb6[2].x
mul_sat r1.x, r1.x, cb6[3].x
dp3 r1.z, r0.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r1.z, r1.z, l(-1.000000)
mad r1.w, cb6[1].w, r1.z, l(1.000000)
mad r1.z, cb6[4].w, r1.z, l(1.000000)
mad r2.xyz, cb6[1].xyzx, r1.wwww, -r0.xyzx
mad r0.xyz, r1.yyyy, r2.xyzx, r0.xyzx
mad r1.yzw, cb6[4].xxyz, r1.zzzz, -r0.xxyz
mad o0.xyz, r1.xxxx, r1.yzwy, r0.xyzx
mov o0.w, r0.w
ret 
// Approximately 199 instruction slots used

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