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

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

cbuffer cbMatDynParam : register(b2)
{
  bool FC_isDitherAlpha : packoffset(c0);
  float FC_TranslucencyScale : packoffset(c1);
  float4 FC_EmissiveColor : packoffset(c2);
  float4 FC_BlendMaskParam : packoffset(c3);
  float FC_PomHeightScale : packoffset(c4);
  float FC_PomHeightBias : packoffset(c4.y);
  float FC_PomMinSamples : packoffset(c4.z);
  float FC_PomMaxSamples : packoffset(c4.w);
  float FC_PomShadowSoftening : packoffset(c5);
  bool FC_bPomDisplayShadows : packoffset(c5.y);
  float4 FC_ParallaxParam : packoffset(c6);
  float FC_Pom2HeightScale : packoffset(c7);
  float FC_Pom2HeightBias : packoffset(c7.y);
  float FC_Pom2MinSamples : packoffset(c7.z);
  float FC_Pom2MaxSamples : packoffset(c7.w);
  bool VC_isEnableCloth : packoffset(c8);
  float FC_EnvMapDolBlendRate : packoffset(c9);
  float4 FC_SnowMaskParam : packoffset(c10);
  float FC_FROZEN_THRESHOLD : packoffset(c11);
  float FC_FROZEN_POW : packoffset(c11.y);
  float FC_BlendRate : packoffset(c12);
  float4 FC_FlowMapUvTiling : packoffset(c13);
  float4 FC_FlowMapIntencity : packoffset(c14);
  float FC_SoftVolume : packoffset(c15);
  float FC_PointCloudRate : packoffset(c16);
  float4 FC_WaterNormalUvScrollSpeed : packoffset(c17);
  float4 FC_WaterDiffuseUvScrollSpeed : packoffset(c18);
  float4 FC_WaterMiddleUvScrollSpeed : packoffset(c19);
  float4 FC_WaterFogParam0 : packoffset(c20);
  float4 FC_WaterFogParam1 : packoffset(c21);
  float4 FC_WaterFresnel : packoffset(c22);
  float4 FC_WaterFadeParam : packoffset(c23);
  float4 FC_DynamicDiffuseColor : packoffset(c24);
  float FC_SSS_ID : packoffset(c25);
  float4 FC_PhantomEdgeColor : packoffset(c26);
  float4 FC_PhantomFrontColor : packoffset(c27);
  float4 FC_PhantomDiffColor : packoffset(c28);
  float4 FC_PhantomSpecColor : packoffset(c29);
  float4 FC_PhantomLightColor : packoffset(c30);
  float VC_VelocityOffset : packoffset(c31);
  float4 FC_DamagedNormalParam : packoffset(c32);
  float4 FC_DamagedNormalUvTiling : packoffset(c33);
  float4 FC_DamagedNormal2UvTiling : packoffset(c34);
  float4 FC_WetDiffuseColor : packoffset(c35);
  float4 FC_WetParam1 : packoffset(c36);
  float4 FC_WetRefrectanceColor : packoffset(c37);
  float4 FC_WetParam2 : packoffset(c38);
  float Veill_snp_0_color_0_0 : packoffset(c39);
  float Veill_snp_0_color_0_1 : packoffset(c39.y);
  float Veill_snp_0_color_0_2 : packoffset(c39.z);
  float Veill_snp_0_color_0_3 : packoffset(c39.w);
  float Veill_snp_0_float_1_0 : packoffset(c40);
  float Veill_snp_0_float_2_0 : packoffset(c40.y);
}

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> Veill_snp_0_Texture2D_2 : register(t2);
Texture2D<float4> Veill_snp_0_Texture2D_1 : register(t3);
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 : NORMAL0,
  float4 v2 : TANGENT0,
  float4 v3 : POSITION1,
  float2 v4 : TEXCOORD0,
  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,r19;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = v2.yzx * v1.zxy;
  r0.xyz = v1.yzx * v2.zxy + -r0.xyz;
  r0.xyz = v2.www * r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r0.w = dot(v1.xyz, v1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = v1.xyz * r0.www;
  r0.w = dot(v2.xyz, v2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = v2.xyz * r0.www;
  r1.xyz = v5.xxx ? r1.xyz : -r1.xyz;
  r3.x = dot(v3.xyzw, FC_MatrixInvViewProj._m00_m10_m20_m30);
  r3.y = dot(v3.xyzw, FC_MatrixInvViewProj._m01_m11_m21_m31);
  r3.z = dot(v3.xyzw, FC_MatrixInvViewProj._m02_m12_m22_m32);
  r0.w = dot(v3.xyzw, FC_MatrixInvViewProj._m03_m13_m23_m33);
  r3.xyz = r3.xyz / r0.www;
  r4.x = FC_MatrixInvView._m30 + -r3.x;
  r4.y = FC_MatrixInvView._m31 + -r3.y;
  r4.z = FC_MatrixInvView._m32 + -r3.z;
  r3.xy = v4.xy * FC_TextureTilingScale[2].xy + FC_TextureTilingScale[2].zw;
  r3.xyzw = Veill_snp_0_Texture2D_2.Sample(SS_DiffuseMap_s, r3.xy).xyzw;
  r0.w = dot(r4.xyz, r4.xyz);
  r0.w = rsqrt(r0.w);
  r5.xyz = r4.xyz * r0.www;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r6.xyz = r1.xyz * r1.www;
  r1.w = saturate(dot(r6.xyz, r5.xyz));
  r1.w = Veill_snp_0_float_2_0 + r1.w;
  r1.w = log2(r1.w);
  r1.w = Veill_snp_0_float_1_0 * r1.w;
  r1.w = exp2(r1.w);
  r2.w = 1 + -r1.w;
  r6.xyz = Veill_snp_0_color_0_0 * r2.www;
  r6.xyz = saturate(r3.xyz * r1.www + r6.xyz);
  r7.xy = v4.xy * FC_TextureTilingScale[1].xy + FC_TextureTilingScale[1].zw;
  r7.xy = Veill_snp_0_Texture2D_1.Sample(SS_DiffuseMap_s, r7.xy).xy;
  r7.xy = r7.xy * float2(2,2) + float2(-1,-1);
  r1.w = dot(r7.xy, r7.xy);
  r1.w = 1 + -r1.w;
  r1.w = max(0, r1.w);
  r1.w = sqrt(r1.w);
  r2.xyz = r7.yyy * r2.xyz;
  r0.xyz = r7.xxx * r0.xyz + r2.xyz;
  r0.xyz = r1.www * r1.xyz + r0.xyz;
  r1.x = dot(r0.xyz, r0.xyz);
  r1.x = rsqrt(r1.x);
  r1.xyz = r1.xxx * r0.xyz;
  r0.x = round(v1.w);
  r0.x = (uint)r0.x;
  r0.yz = FC_ScreenSize.zw * v0.xy;
  r2.x = g_SSAOTexture.Sample(SS_WrapLinear_s, r0.yz).x;
  r0.x = (int)r0.x * 17;
  r1.w = 1;
  r7.x = dot(r1.xyzw, VC_InstanceData[r0.x].aSh[0].xyzw);
  r7.y = dot(r1.xyzw, VC_InstanceData[r0.x].aSh[1].xyzw);
  r7.z = dot(r1.xyzw, VC_InstanceData[r0.x].aSh[2].xyzw);
  r2.yzw = max(float3(0,0,0), r7.xyz);
  r7.xyz = VC_InstanceData[r0.x].ShLightMask.xxx * FC_DirLightCol_0.xyz;
  r8.x = dot(FC_DirLightVec_0.xyz, r1.xyz);
  r8.y = dot(FC_DirLightVec_1.xyz, r1.xyz);
  r8.zw = saturate(r8.xy);
  r9.xyz = FC_DirLightCol_1.xyz * r8.www;
  r7.xyz = r7.xyz * r8.zzz + r9.xyz;
  r9.xy = cmp(int2(0,0) < (uint2)FC_bLocalLight.xy);
  if (FC_bLocalLight.x != 0) {
    r1.w = dot(FC_DirLightVec_2.xyz, r1.xyz);
    r1.w = r1.w * 0.5 + 0.5;
    r1.w = r1.w * r1.w;
    r1.w = min(1, r1.w);
    r7.xyz = FC_DirLightCol_2.xyz * r1.www + r7.xyz;
  }
  if (FC_bLocalLight.y != 0) {
    r1.w = dot(FC_DirLightVec_3.xyz, r1.xyz);
    r1.w = r1.w * 0.5 + 0.5;
    r1.w = r1.w * r1.w;
    r1.w = min(1, r1.w);
    r7.xyz = FC_DirLightCol_3.xyz * r1.www + r7.xyz;
  }
  r10.xyz = VC_InstanceData[r0.x].ShLightMask.xxx * FC_DirLightSpc_0.xyz;
  r11.xyz = r4.xyz * r0.www + FC_DirLightVec_0.xyz;
  r1.w = dot(r11.xyz, r11.xyz);
  r1.w = rsqrt(r1.w);
  r11.xyz = r11.xyz * r1.www;
  r12.xyz = r4.xyz * r0.www + FC_DirLightVec_1.xyz;
  r1.w = dot(r12.xyz, r12.xyz);
  r1.w = rsqrt(r1.w);
  r12.xyz = r12.xyz * r1.www;
  r13.x = saturate(dot(r11.xyz, r1.xyz));
  r13.y = saturate(dot(r12.xyz, r1.xyz));
  r1.w = 0.00999999978 + FC_DirLightVec_0.w;
  r1.w = FC_DirLightVec_0.w / r1.w;
  r14.x = max(1, r1.w);
  r1.w = 0.00999999978 + FC_DirLightVec_1.w;
  r1.w = FC_DirLightVec_1.w / r1.w;
  r14.y = max(1, r1.w);
  r9.zw = log2(r13.xy);
  r9.zw = r14.xy * r9.zw;
  r9.zw = exp2(r9.zw);
  r1.w = dot(r5.xyz, r1.xyz);
  r11.x = saturate(dot(r5.xyz, r11.xyz));
  r11.y = saturate(dot(r5.xyz, r12.xyz));
  r11.xy = float2(1,1) + -r11.xy;
  r11.zw = r11.xy * r11.xy;
  r11.zw = r11.zw * r11.zw;
  r11.xy = r11.xy * r11.zw;
  r8.xy = max(r8.xy, r1.ww);
  r8.xy = max(float2(9.99999975e-005,9.99999975e-005), r8.xy);
  r8.xy = r8.zw / r8.xy;
  r8.zw = r11.xy * r9.zw;
  r8.xy = r8.zw * r8.xy;
  r8.zw = r14.xy * float2(0.125,0.125) + float2(0.25,0.25);
  r10.xyz = r8.zzz * r10.xyz;
  r11.xyz = FC_DirLightSpc_1.xyz * r8.www;
  r8.yzw = r11.xyz * r8.yyy;
  r8.xyz = r10.xyz * r8.xxx + r8.yzw;
  r4.w = dot(r1.xyz, FC_DirLightVec_2.xyz);
  r10.xyz = r4.xyz * r0.www + FC_DirLightVec_2.xyz;
  r5.w = dot(r10.xyz, r10.xyz);
  r5.w = rsqrt(r5.w);
  r10.xyz = r10.xyz * r5.www;
  r5.w = saturate(dot(r10.xyz, r1.xyz));
  r6.w = 0.00999999978 + FC_DirLightVec_2.w;
  r6.w = FC_DirLightVec_2.w / r6.w;
  r6.w = max(1, r6.w);
  r5.w = log2(r5.w);
  r5.w = r6.w * r5.w;
  r5.w = exp2(r5.w);
  r7.w = saturate(dot(r5.xyz, r10.xyz));
  r7.w = 1 + -r7.w;
  r8.w = r7.w * r7.w;
  r8.w = r8.w * r8.w;
  r7.w = r8.w * r7.w;
  r8.w = saturate(r4.w);
  r4.w = max(r4.w, r1.w);
  r4.w = max(9.99999975e-005, r4.w);
  r4.w = r8.w / r4.w;
  r5.w = r7.w * r5.w;
  r4.w = r5.w * r4.w;
  r5.w = r6.w * 0.125 + 0.25;
  r10.xyz = FC_DirLightSpc_2.xyz * r5.www;
  r10.xyz = r10.xyz * r4.www + r8.xyz;
  r8.xyz = r9.xxx ? r10.xyz : r8.xyz;
  r4.w = dot(r1.xyz, FC_DirLightVec_3.xyz);
  r9.xzw = r4.xyz * r0.www + FC_DirLightVec_3.xyz;
  r0.w = dot(r9.xzw, r9.xzw);
  r0.w = rsqrt(r0.w);
  r9.xzw = r9.xzw * r0.www;
  r0.w = saturate(dot(r9.xzw, r1.xyz));
  r5.w = 0.00999999978 + FC_DirLightVec_3.w;
  r5.w = FC_DirLightVec_3.w / r5.w;
  r5.w = max(1, r5.w);
  r0.w = log2(r0.w);
  r0.w = r5.w * r0.w;
  r0.w = exp2(r0.w);
  r5.x = saturate(dot(r5.xyz, r9.xzw));
  r5.x = 1 + -r5.x;
  r5.y = r5.x * r5.x;
  r5.y = r5.y * r5.y;
  r5.x = r5.x * r5.y;
  r5.y = saturate(r4.w);
  r1.w = max(r4.w, r1.w);
  r1.w = max(9.99999975e-005, r1.w);
  r1.w = r5.y / r1.w;
  r0.w = r5.x * r0.w;
  r0.w = r0.w * r1.w;
  r1.w = r5.w * 0.125 + 0.25;
  r5.xyz = FC_DirLightSpc_3.xyz * r1.www;
  r5.xyz = r5.xyz * r0.www + r8.xyz;
  r5.xyz = r9.yyy ? r5.xyz : r8.xyz;
  if (VC_InstanceData[r0.x].dynamicLightDisable == 0) {
    r8.x = dot(r1.xyz, FC_MatrixView._m00_m10_m20);
    r8.y = dot(r1.xyz, FC_MatrixView._m01_m11_m21);
    r8.z = dot(r1.xyz, FC_MatrixView._m02_m12_m22);
    r1.x = dot(v3.xyzw, FC_MatrixInvProj._m00_m10_m20_m30);
    r1.y = dot(v3.xyzw, FC_MatrixInvProj._m01_m11_m21_m31);
    r1.z = dot(v3.xyzw, FC_MatrixInvProj._m02_m12_m22_m32);
    r0.w = dot(v3.xyzw, FC_MatrixInvProj._m03_m13_m23_m33);
    r1.xyz = r1.xyz / r0.www;
    r0.yz = FC_ScreenSize.xy * r0.yz;
    r0.yz = (uint2)r0.yz;
    uiDest.yz = (uint2)r0.yz / FC_LightTile_Width;
    r0.yz = uiDest.yz;
    r0.yz = (uint2)r0.yz;
    r0.w = FC_LightTile_NumCellX;
    r0.y = r0.z * r0.w + r0.y;
    r0.z = -FC_FrustumNear + r1.z;
    r0.z = log2(r0.z);
    r0.z = -FC_FrustumSliceBias + r0.z;
    r0.z = r0.z / FC_FrustumSliceScale;
    r0.z = max(0, r0.z);
    r0.z = min(14, r0.z);
    r0.yz = (uint2)r0.yz;
    r0.z = 1 << (int)r0.z;
  // Known bad code for instruction (needs manual fix):
    ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r9.xyz, r0.y, l(0), t60.xyzx
  r9.x = SS_DiffuseMap[]..swiz;
  r9.y = SS_DiffuseMap[]..swiz;
  r9.z = SS_DiffuseMap[]..swiz;
    r10.xyz = float3(0,0,0);
    r0.y = r9.x;
    r0.w = 0;
    while (true) {
      r4.w = cmp((uint)r0.w >= (uint)r9.y);
      if (r4.w != 0) break;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r11.xy, r0.y, l(0), t59.xyxx
    r11.x = SS_DiffuseMap[]..swiz;
    r11.y = SS_DiffuseMap[]..swiz;
      r4.w = (int)r0.y + 1;
      r5.w = (int)r0.z & (int)r11.y;
      r6.w = (int)r0.w + 1;
      r0.w = r5.w ? r0.w : r6.w;
      r0.y = r4.w;
      if (r5.w == 0) continue;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r12.xyzw, r11.x, l(0), t61.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=64)(mixed,mixed,mixed,mixed) r11.xyz, r11.x, l(16), t61.xyzx
    r11.x = SS_DiffuseMap[]..swiz;
    r11.y = SS_DiffuseMap[]..swiz;
    r11.z = SS_DiffuseMap[]..swiz;
      r12.xyz = r12.xyz + -r1.xyz;
      r5.w = dot(r12.xyz, r12.xyz);
      r7.w = rsqrt(r5.w);
      r12.xyz = r12.xyz * r7.www;
      r7.w = saturate(dot(r8.xyz, r12.xyz));
      r5.w = saturate(r5.w * r12.w);
      r5.w = sqrt(r5.w);
      r5.w = 1 + -r5.w;
      r5.w = r5.w * r5.w;
      r11.xyz = r11.xyz * r7.www;
      r10.xyz = r11.xyz * r5.www + r10.xyz;
      r0.w = r6.w;
      r0.y = r4.w;
    }
    r0.w = (uint)r9.z >> 16;
    r1.w = 1;
    r9.z = 1;
    r11.xyz = r10.xyz;
    r4.w = r0.y;
    r5.w = 0;
    while (true) {
      r6.w = cmp((uint)r5.w >= (uint)r0.w);
      if (r6.w != 0) break;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r12.xy, r4.w, l(0), t59.xyxx
    r12.x = SS_DiffuseMap[]..swiz;
    r12.y = SS_DiffuseMap[]..swiz;
      r6.w = (int)r4.w + 1;
      r7.w = (int)r0.z & (int)r12.y;
      r8.w = (int)r5.w + 1;
      r5.w = r7.w ? r5.w : r8.w;
      r4.w = r6.w;
      if (r7.w == 0) continue;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r12.x, l(0), 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) r12.yzw, r12.x, l(16), t62.xxyz
    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) r14.xyzw, r12.x, l(60), t62.xyzw
    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, r12.x, l(76), 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, r12.x, l(92), t62.yzwx
    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.xyzw, r12.x, l(108), t62.xyzw
    r17.x = SS_DiffuseMap[]..swiz;
    r17.y = SS_DiffuseMap[]..swiz;
    r17.z = SS_DiffuseMap[]..swiz;
    r17.w = SS_DiffuseMap[]..swiz;
    // Known bad code for instruction (needs manual fix):
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r18.w, r12.x, l(124), t62.xxxx
    r18.w = SS_DiffuseMap[]..swiz;
      r19.xyz = r14.yzw;
      r19.w = r15.w;
      r19.x = dot(r1.xyzw, r19.xyzw);
      r15.w = r16.w;
      r19.y = dot(r1.xyzw, r15.xyzw);
      r16.w = r17.x;
      r7.w = dot(r1.xyzw, r16.xyzw);
      r18.xyz = r17.yzw;
      r9.w = dot(r1.xyzw, r18.xyzw);
      r7.w = cmp(0 < r7.w);
      r13.xyz = r13.xyz + -r1.xyz;
      r10.w = dot(r13.xyz, r13.xyz);
      r11.w = rsqrt(r10.w);
      r13.xyz = r13.xyz * r11.www;
      r11.w = cmp(0 < r14.x);
      r12.x = r13.w * r13.w;
      r12.x = 1 / r12.x;
      r14.x = 1 / r10.w;
      r10.w = r14.x + -r12.x;
      r14.z = max(0, r10.w);
      r10.w = saturate(dot(r13.xyz, r8.xyz));
      r13.xy = r19.xy / r9.ww;
      r12.x = dot(r13.xy, r13.xy);
      r12.x = 1 + -r12.x;
      r14.y = max(0, r12.x);
      r9.w = r9.w / r13.w;
      r9.w = saturate(1 + -r9.w);
      r9.y = r14.y * r14.y;
      r9.x = r9.w * r9.w;
      r9.xyw = r11.www ? r14.xyz : r9.xyz;
      r9.xy = r9.yy * r9.wx;
      r12.xyz = r12.yzw * r10.www;
      r13.xyz = r12.xyz * r9.xxx;
      r9.xyw = r12.xyz * r9.yyy;
      r9.xyw = r11.www ? r13.xyz : r9.xyw;
      r9.xyw = r7.www ? r9.xyw : 0;
      r11.xyz = r11.xyz + r9.xyw;
      r5.w = r8.w;
      r4.w = r6.w;
    }
    r7.xyz = r11.xyz * r2.xxx + r7.xyz;
  }
  r0.yzw = r2.yzw * r2.xxx + r7.xyz;
  r3.xyz = r6.xyz * r0.yzw + r5.xyz;
  r0.xyzw = VC_InstanceData[r0.x].mulCol.xyzw * r3.xyzw;
  r1.x = FC_HeightFogParam.w + -r4.y;
  r1.x = -FC_HeightFogParam.y + r1.x;
  r1.x = saturate(FC_HeightFogParam.z * r1.x);
  r1.y = dot(-r4.xz, -r4.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 cbMatDynParam
// {
//
//   bool FC_isDitherAlpha;             // Offset:    0 Size:     4 [unused]
//   float FC_TranslucencyScale;        // Offset:   16 Size:     4 [unused]
//   float4 FC_EmissiveColor;           // Offset:   32 Size:    16 [unused]
//   float4 FC_BlendMaskParam;          // Offset:   48 Size:    16 [unused]
//   float FC_PomHeightScale;           // Offset:   64 Size:     4 [unused]
//   float FC_PomHeightBias;            // Offset:   68 Size:     4 [unused]
//   float FC_PomMinSamples;            // Offset:   72 Size:     4 [unused]
//   float FC_PomMaxSamples;            // Offset:   76 Size:     4 [unused]
//   float FC_PomShadowSoftening;       // Offset:   80 Size:     4 [unused]
//   bool FC_bPomDisplayShadows;        // Offset:   84 Size:     4 [unused]
//   float4 FC_ParallaxParam;           // Offset:   96 Size:    16 [unused]
//   float FC_Pom2HeightScale;          // Offset:  112 Size:     4 [unused]
//   float FC_Pom2HeightBias;           // Offset:  116 Size:     4 [unused]
//   float FC_Pom2MinSamples;           // Offset:  120 Size:     4 [unused]
//   float FC_Pom2MaxSamples;           // Offset:  124 Size:     4 [unused]
//   bool VC_isEnableCloth;             // Offset:  128 Size:     4 [unused]
//   float FC_EnvMapDolBlendRate;       // Offset:  144 Size:     4 [unused]
//   float4 FC_SnowMaskParam;           // Offset:  160 Size:    16 [unused]
//   float FC_FROZEN_THRESHOLD;         // Offset:  176 Size:     4 [unused]
//   float FC_FROZEN_POW;               // Offset:  180 Size:     4 [unused]
//   float FC_BlendRate;                // Offset:  192 Size:     4 [unused]
//   float4 FC_FlowMapUvTiling;         // Offset:  208 Size:    16 [unused]
//   float4 FC_FlowMapIntencity;        // Offset:  224 Size:    16 [unused]
//   float FC_SoftVolume;               // Offset:  240 Size:     4 [unused]
//   float FC_PointCloudRate;           // Offset:  256 Size:     4 [unused]
//   float4 FC_WaterNormalUvScrollSpeed;// Offset:  272 Size:    16 [unused]
//   float4 FC_WaterDiffuseUvScrollSpeed;// Offset:  288 Size:    16 [unused]
//   float4 FC_WaterMiddleUvScrollSpeed;// Offset:  304 Size:    16 [unused]
//   float4 FC_WaterFogParam0;          // Offset:  320 Size:    16 [unused]
//   float4 FC_WaterFogParam1;          // Offset:  336 Size:    16 [unused]
//   float4 FC_WaterFresnel;            // Offset:  352 Size:    16 [unused]
//   float4 FC_WaterFadeParam;          // Offset:  368 Size:    16 [unused]
//   float4 FC_DynamicDiffuseColor;     // Offset:  384 Size:    16 [unused]
//   float FC_SSS_ID;                   // Offset:  400 Size:     4 [unused]
//   float4 FC_PhantomEdgeColor;        // Offset:  416 Size:    16 [unused]
//   float4 FC_PhantomFrontColor;       // Offset:  432 Size:    16 [unused]
//   float4 FC_PhantomDiffColor;        // Offset:  448 Size:    16 [unused]
//   float4 FC_PhantomSpecColor;        // Offset:  464 Size:    16 [unused]
//   float4 FC_PhantomLightColor;       // Offset:  480 Size:    16 [unused]
//   float VC_VelocityOffset;           // Offset:  496 Size:     4 [unused]
//   float4 FC_DamagedNormalParam;      // Offset:  512 Size:    16 [unused]
//   float4 FC_DamagedNormalUvTiling;   // Offset:  528 Size:    16 [unused]
//   float4 FC_DamagedNormal2UvTiling;  // Offset:  544 Size:    16 [unused]
//   float4 FC_WetDiffuseColor;         // Offset:  560 Size:    16 [unused]
//   float4 FC_WetParam1;               // Offset:  576 Size:    16 [unused]
//   float4 FC_WetRefrectanceColor;     // Offset:  592 Size:    16 [unused]
//   float4 FC_WetParam2;               // Offset:  608 Size:    16 [unused]
//   float Veill_snp_0_color_0_0;       // Offset:  624 Size:     4
//   float Veill_snp_0_color_0_1;       // Offset:  628 Size:     4
//   float Veill_snp_0_color_0_2;       // Offset:  632 Size:     4
//   float Veill_snp_0_color_0_3;       // Offset:  636 Size:     4 [unused]
//   float Veill_snp_0_float_1_0;       // Offset:  640 Size:     4
//   float Veill_snp_0_float_2_0;       // Offset:  644 Size:     4
//
// }
//
// 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 [unused]
//   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
//   float4 FC_DirLightSpc_1;           // Offset:  144 Size:    16
//   float4 FC_DirLightSpc_2;           // Offset:  160 Size:    16
//   float4 FC_DirLightSpc_3;           // Offset:  176 Size:    16
//   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
// Veill_snp_0_Texture2D_2           texture  float4          2d    2        1
// Veill_snp_0_Texture2D_1           texture  float4          2d    3        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
// cbMatDynParam                     cbuffer      NA          NA    2        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  
// NORMAL                   0   xyzw        1     NONE   float   xyzw
// TANGENT                  0   xyzw        2     NONE   float   xyzw
// POSITION                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 0   xy          4     NONE   float   xy  
// 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[3], immediateIndexed
dcl_constantbuffer cb2[41], 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) t2
dcl_resource_texture2d (float,float,float,float) t3
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.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xy
dcl_input_ps_sgv v5.x, is_front_face
dcl_output o0.xyzw
dcl_temps 20
mul r0.xyz, v1.zxyz, v2.yzxy
mad r0.xyz, v1.yzxy, v2.zxyz, -r0.xyzx
mul r0.xyz, r0.xyzx, v2.wwww
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
dp3 r0.w, v1.xyzx, v1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, v1.xyzx
dp3 r0.w, v2.xyzx, v2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, v2.xyzx
movc r1.xyz, v5.xxxx, r1.xyzx, -r1.xyzx
dp4 r3.x, v3.xyzw, cb8[8].xyzw
dp4 r3.y, v3.xyzw, cb8[9].xyzw
dp4 r3.z, v3.xyzw, cb8[10].xyzw
dp4 r0.w, v3.xyzw, cb8[11].xyzw
div r3.xyz, r3.xyzx, r0.wwww
add r4.x, -r3.x, cb8[20].w
add r4.y, -r3.y, cb8[21].w
add r4.z, -r3.z, cb8[22].w
mad r3.xy, v4.xyxx, cb1[2].xyxx, cb1[2].zwzz
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r3.xyxx, t2.xyzw, s0
dp3 r0.w, r4.xyzx, r4.xyzx
rsq r0.w, r0.w
mul r5.xyz, r0.wwww, r4.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r6.xyz, r1.wwww, r1.xyzx
dp3_sat r1.w, r6.xyzx, r5.xyzx
add r1.w, r1.w, cb2[40].y
log r1.w, r1.w
mul r1.w, r1.w, cb2[40].x
exp r1.w, r1.w
add r2.w, -r1.w, l(1.000000)
mul r6.xyz, r2.wwww, cb2[39].xyzx
mad_sat r6.xyz, r3.xyzx, r1.wwww, r6.xyzx
mad r7.xy, v4.xyxx, cb1[1].xyxx, cb1[1].zwzz
sample_indexable(texture2d)(float,float,float,float) r7.xy, r7.xyxx, t3.xyzw, s0
mad r7.xy, r7.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r1.w, r7.xyxx, r7.xyxx
add r1.w, -r1.w, l(1.000000)
max r1.w, r1.w, l(0.000000)
sqrt r1.w, r1.w
mul r2.xyz, r2.xyzx, r7.yyyy
mad r0.xyz, r7.xxxx, r0.xyzx, r2.xyzx
mad r0.xyz, r1.wwww, r1.xyzx, r0.xyzx
dp3 r1.x, r0.xyzx, r0.xyzx
rsq r1.x, r1.x
mul r1.xyz, r0.xyzx, r1.xxxx
round_ne r0.x, v1.w
ftou r0.x, r0.x
mul r0.yz, v0.xxyx, cb8[1].zzwz
sample_indexable(texture2d)(float,float,float,float) r2.x, r0.yzyy, t33.xyzw, s8
imul null, r0.x, r0.x, l(17)
mov r1.w, l(1.000000)
dp4 r7.x, r1.xyzw, cb4[r0.x + 8].xyzw
dp4 r7.y, r1.xyzw, cb4[r0.x + 9].xyzw
dp4 r7.z, r1.xyzw, cb4[r0.x + 10].xyzw
max r2.yzw, r7.xxyz, l(0.000000, 0.000000, 0.000000, 0.000000)
mul r7.xyz, cb5[4].xyzx, cb4[r0.x + 11].xxxx
dp3 r8.x, cb5[0].xyzx, r1.xyzx
dp3 r8.y, cb5[1].xyzx, r1.xyzx
mov_sat r8.zw, r8.xxxy
mul r9.xyz, r8.wwww, cb5[5].xyzx
mad r7.xyz, r7.xyzx, r8.zzzz, r9.xyzx
ult r9.xy, l(0, 0, 0, 0), cb5[16].xyxx
if_nz cb5[16].x
  dp3 r1.w, cb5[2].xyzx, r1.xyzx
  mad r1.w, r1.w, l(0.500000), l(0.500000)
  mul r1.w, r1.w, r1.w
  min r1.w, r1.w, l(1.000000)
  mad r7.xyz, cb5[6].xyzx, r1.wwww, r7.xyzx
endif 
if_nz cb5[16].y
  dp3 r1.w, cb5[3].xyzx, r1.xyzx
  mad r1.w, r1.w, l(0.500000), l(0.500000)
  mul r1.w, r1.w, r1.w
  min r1.w, r1.w, l(1.000000)
  mad r7.xyz, cb5[7].xyzx, r1.wwww, r7.xyzx
endif 
mul r10.xyz, cb5[8].xyzx, cb4[r0.x + 11].xxxx
mad r11.xyz, r4.xyzx, r0.wwww, cb5[0].xyzx
dp3 r1.w, r11.xyzx, r11.xyzx
rsq r1.w, r1.w
mul r11.xyz, r1.wwww, r11.xyzx
mad r12.xyz, r4.xyzx, r0.wwww, cb5[1].xyzx
dp3 r1.w, r12.xyzx, r12.xyzx
rsq r1.w, r1.w
mul r12.xyz, r1.wwww, r12.xyzx
dp3_sat r13.x, r11.xyzx, r1.xyzx
dp3_sat r13.y, r12.xyzx, r1.xyzx
add r1.w, cb5[0].w, l(0.010000)
div r1.w, cb5[0].w, r1.w
max r14.x, r1.w, l(1.000000)
add r1.w, cb5[1].w, l(0.010000)
div r1.w, cb5[1].w, r1.w
max r14.y, r1.w, l(1.000000)
log r9.zw, r13.xxxy
mul r9.zw, r9.zzzw, r14.xxxy
exp r9.zw, r9.zzzw
dp3 r1.w, r5.xyzx, r1.xyzx
dp3_sat r11.x, r5.xyzx, r11.xyzx
dp3_sat r11.y, r5.xyzx, r12.xyzx
add r11.xy, -r11.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
mul r11.zw, r11.xxxy, r11.xxxy
mul r11.zw, r11.zzzw, r11.zzzw
mul r11.xy, r11.zwzz, r11.xyxx
max r8.xy, r1.wwww, r8.xyxx
max r8.xy, r8.xyxx, l(0.000100, 0.000100, 0.000000, 0.000000)
div r8.xy, r8.zwzz, r8.xyxx
mul r8.zw, r9.zzzw, r11.xxxy
mul r8.xy, r8.xyxx, r8.zwzz
mad r8.zw, r14.xxxy, l(0.000000, 0.000000, 0.125000, 0.125000), l(0.000000, 0.000000, 0.250000, 0.250000)
mul r10.xyz, r10.xyzx, r8.zzzz
mul r11.xyz, r8.wwww, cb5[9].xyzx
mul r8.yzw, r8.yyyy, r11.xxyz
mad r8.xyz, r10.xyzx, r8.xxxx, r8.yzwy
dp3 r4.w, r1.xyzx, cb5[2].xyzx
mad r10.xyz, r4.xyzx, r0.wwww, cb5[2].xyzx
dp3 r5.w, r10.xyzx, r10.xyzx
rsq r5.w, r5.w
mul r10.xyz, r5.wwww, r10.xyzx
dp3_sat r5.w, r10.xyzx, r1.xyzx
add r6.w, cb5[2].w, l(0.010000)
div r6.w, cb5[2].w, r6.w
max r6.w, r6.w, l(1.000000)
log r5.w, r5.w
mul r5.w, r5.w, r6.w
exp r5.w, r5.w
dp3_sat r7.w, r5.xyzx, r10.xyzx
add r7.w, -r7.w, l(1.000000)
mul r8.w, r7.w, r7.w
mul r8.w, r8.w, r8.w
mul r7.w, r7.w, r8.w
mov_sat r8.w, r4.w
max r4.w, r1.w, r4.w
max r4.w, r4.w, l(0.000100)
div r4.w, r8.w, r4.w
mul r5.w, r5.w, r7.w
mul r4.w, r4.w, r5.w
mad r5.w, r6.w, l(0.125000), l(0.250000)
mul r10.xyz, r5.wwww, cb5[10].xyzx
mad r10.xyz, r10.xyzx, r4.wwww, r8.xyzx
movc r8.xyz, r9.xxxx, r10.xyzx, r8.xyzx
dp3 r4.w, r1.xyzx, cb5[3].xyzx
mad r9.xzw, r4.xxyz, r0.wwww, cb5[3].xxyz
dp3 r0.w, r9.xzwx, r9.xzwx
rsq r0.w, r0.w
mul r9.xzw, r0.wwww, r9.xxzw
dp3_sat r0.w, r9.xzwx, r1.xyzx
add r5.w, cb5[3].w, l(0.010000)
div r5.w, cb5[3].w, r5.w
max r5.w, r5.w, l(1.000000)
log r0.w, r0.w
mul r0.w, r0.w, r5.w
exp r0.w, r0.w
dp3_sat r5.x, r5.xyzx, r9.xzwx
add r5.x, -r5.x, l(1.000000)
mul r5.y, r5.x, r5.x
mul r5.y, r5.y, r5.y
mul r5.x, r5.y, r5.x
mov_sat r5.y, r4.w
max r1.w, r1.w, r4.w
max r1.w, r1.w, l(0.000100)
div r1.w, r5.y, r1.w
mul r0.w, r0.w, r5.x
mul r0.w, r1.w, r0.w
mad r1.w, r5.w, l(0.125000), l(0.250000)
mul r5.xyz, r1.wwww, cb5[11].xyzx
mad r5.xyz, r5.xyzx, r0.wwww, r8.xyzx
movc r5.xyz, r9.yyyy, r5.xyzx, r8.xyzx
if_z cb4[r0.x + 6].y
  dp3 r8.x, r1.xyzx, cb8[5].xyzx
  dp3 r8.y, r1.xyzx, cb8[6].xyzx
  dp3 r8.z, r1.xyzx, cb8[7].xyzx
  dp4 r1.x, v3.xyzw, cb8[12].xyzw
  dp4 r1.y, v3.xyzw, cb8[13].xyzw
  dp4 r1.z, v3.xyzw, cb8[14].xyzw
  dp4 r0.w, v3.xyzw, cb8[15].xyzw
  div r1.xyz, r1.xyzx, r0.wwww
  mul r0.yz, r0.yyzy, cb8[1].xxyx
  ftou r0.yz, r0.yyzy
  udiv r0.yz, null, r0.yyzy, cb8[56].xxxx
  utof r0.yz, r0.yyzy
  utof r0.w, cb8[56].y
  mad r0.y, r0.z, r0.w, r0.y
  add r0.z, r1.z, -cb8[55].x
  log r0.z, r0.z
  add r0.z, r0.z, -cb8[55].z
  div r0.z, r0.z, cb8[55].y
  max r0.z, r0.z, l(0.000000)
  min r0.z, r0.z, l(14.000000)
  ftou r0.yz, r0.yyzy
  ishl r0.z, l(1), r0.z
  ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r9.xyz, r0.y, l(0), t60.xyzx
  mov r10.xyz, l(0,0,0,0)
  mov r0.y, r9.x
  mov r0.w, l(0)
  loop 
    uge r4.w, r0.w, r9.y
    breakc_nz r4.w
    ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r11.xy, r0.y, l(0), t59.xyxx
    iadd r4.w, r0.y, l(1)
    and r5.w, r0.z, r11.y
    iadd r6.w, r0.w, l(1)
    movc r0.w, r5.w, r0.w, r6.w
    mov r0.y, r4.w
    continuec_z r5.w
    ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r12.xyzw, r11.x, l(0), t61.xyzw
    ld_structured_indexable(structured_buffer, stride=64)(mixed,mixed,mixed,mixed) r11.xyz, r11.x, l(16), t61.xyzx
    add r12.xyz, -r1.xyzx, r12.xyzx
    dp3 r5.w, r12.xyzx, r12.xyzx
    rsq r7.w, r5.w
    mul r12.xyz, r7.wwww, r12.xyzx
    dp3_sat r7.w, r8.xyzx, r12.xyzx
    mul_sat r5.w, r12.w, r5.w
    sqrt r5.w, r5.w
    add r5.w, -r5.w, l(1.000000)
    mul r5.w, r5.w, r5.w
    mul r11.xyz, r7.wwww, r11.xyzx
    mad r10.xyz, r11.xyzx, r5.wwww, r10.xyzx
    mov r0.w, r6.w
    mov r0.y, r4.w
  endloop 
  ushr r0.w, r9.z, l(16)
  mov r1.w, l(1.000000)
  mov r9.z, l(1.000000)
  mov r11.xyz, r10.xyzx
  mov r4.w, r0.y
  mov r5.w, l(0)
  loop 
    uge r6.w, r5.w, r0.w
    breakc_nz r6.w
    ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r12.xy, r4.w, l(0), t59.xyxx
    iadd r6.w, r4.w, l(1)
    and r7.w, r0.z, r12.y
    iadd r8.w, r5.w, l(1)
    movc r5.w, r7.w, r5.w, r8.w
    mov r4.w, r6.w
    continuec_z r7.w
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r12.x, l(0), t62.xyzw
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.yzw, r12.x, l(16), t62.xxyz
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r14.xyzw, r12.x, l(60), t62.xyzw
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r15.xyzw, r12.x, l(76), t62.yzwx
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r16.xyzw, r12.x, l(92), t62.yzwx
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r17.xyzw, r12.x, l(108), t62.xyzw
    ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r18.w, r12.x, l(124), t62.xxxx
    mov r19.xyz, r14.yzwy
    mov r19.w, r15.w
    dp4 r19.x, r1.xyzw, r19.xyzw
    mov r15.w, r16.w
    dp4 r19.y, r1.xyzw, r15.xyzw
    mov r16.w, r17.x
    dp4 r7.w, r1.xyzw, r16.xyzw
    mov r18.xyz, r17.yzwy
    dp4 r9.w, r1.xyzw, r18.xyzw
    lt r7.w, l(0.000000), r7.w
    add r13.xyz, -r1.xyzx, r13.xyzx
    dp3 r10.w, r13.xyzx, r13.xyzx
    rsq r11.w, r10.w
    mul r13.xyz, r11.wwww, r13.xyzx
    lt r11.w, l(0.000000), r14.x
    mul r12.x, r13.w, r13.w
    div r12.x, l(1.000000, 1.000000, 1.000000, 1.000000), r12.x
    div r14.x, l(1.000000, 1.000000, 1.000000, 1.000000), r10.w
    add r10.w, -r12.x, r14.x
    max r14.z, r10.w, l(0.000000)
    dp3_sat r10.w, r13.xyzx, r8.xyzx
    div r13.xy, r19.xyxx, r9.wwww
    dp2 r12.x, r13.xyxx, r13.xyxx
    add r12.x, -r12.x, l(1.000000)
    max r14.y, r12.x, l(0.000000)
    div r9.w, r9.w, r13.w
    add_sat r9.w, -r9.w, l(1.000000)
    mul r9.y, r14.y, r14.y
    mul r9.x, r9.w, r9.w
    movc r9.xyw, r11.wwww, r14.xyxz, r9.xyxz
    mul r9.xy, r9.wxww, r9.yyyy
    mul r12.xyz, r10.wwww, r12.yzwy
    mul r13.xyz, r9.xxxx, r12.xyzx
    mul r9.xyw, r9.yyyy, r12.xyxz
    movc r9.xyw, r11.wwww, r13.xyxz, r9.xyxw
    and r9.xyw, r7.wwww, r9.xyxw
    add r11.xyz, r9.xywx, r11.xyzx
    mov r5.w, r8.w
    mov r4.w, r6.w
  endloop 
  mad r7.xyz, r11.xyzx, r2.xxxx, r7.xyzx
endif 
mad r0.yzw, r2.yyzw, r2.xxxx, r7.xxyz
mad r3.xyz, r6.xyzx, r0.yzwy, r5.xyzx
mul r0.xyzw, r3.xyzw, cb4[r0.x + 7].xyzw
add r1.x, -r4.y, cb6[3].w
add r1.x, r1.x, -cb6[3].y
mul_sat r1.x, r1.x, cb6[3].z
dp2 r1.y, -r4.xzxx, -r4.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 313 instruction slots used

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