// Shadows

cbuffer cPSScene : register(b2)
{

  struct
  {
    float4x4 m_projectionView;
    float4x4 m_projection;
    float4x4 m_view;
    float4x4 m_shadowProjection;
    float4x4 m_shadowProjection2;
    float4 m_eyepos;
    float4 m_projectionParam;
    float4 m_viewportSize;
    float4 m_exposure;
    float4 m_fogParam[3];
    float4 m_fogColor;
    float4 m_cameraCenterOffset;
    float4 m_shadowMapResolutions;
  } g_psScene : packoffset(c0);

}

cbuffer cPSObject : register(b5)
{

  struct
  {
    float4x4 m_viewWorld;
    float4x4 m_world;
    float4 m_useWeightCount;
    float4 m_localParam[4];
  } g_psObject : packoffset(c0);

}

cbuffer cPSLight : register(b3)
{

  struct
  {
    float4 m_lightDir0;
    float4 m_lightColor0;
    float4 m_lightColor1;
    float4 m_lightSourcePos;
    float4 m_lightSourceColor;
    float4 m_lightSourceDir;
    float4 m_lightSourceParam1;
    float4 m_lightSourceParam2;
    float4 m_lightSourceParam3;
    float4 m_lightPos0;
    float4 m_lightParam2;
  } g_psLight : packoffset(c0);

}

SamplerState g_samplerPoint_Wrap_s : register(s8);
SamplerState g_samplerPoint_Clamp_s : register(s9);
SamplerState g_samplerLinear_Wrap_s : register(s10);
SamplerState g_samplerLinear_Clamp_s : register(s11);
SamplerComparisonState g_samplerComparisonLess_Linear_Clmap_s : register(s15);
Texture2D<float4> g_NormalTexture : register(t0);
Texture2D<float4> g_SpecularTexture : register(t1);
Texture2D<float4> g_DepthTexture : register(t2);
Texture2D<float4> g_ShadowTexture : register(t3);
Texture2D<float4> g_CloudTexture : register(t4);
Texture3D<float4> g_lut2 : register(t8);
Texture2D<float4> g_lut1 : register(t9);
Texture2D<float4> g_MaterialTexture : register(t10);
Texture2D<float4> g_WorldShadowMask : register(t13);
Texture2D<float4> g_SkyReflectTexture : register(t15);


// 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 : TEXCOORD1,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyzw = floor(v0.xyxy);
  r0.xyzw = r0.xyzw * float4(0.5,0.5,0.5,0.5) + float4(0.100000001,0.100000001,0.100000001,0.100000001);
  r0.xyzw = frac(r0.xyzw);
  r0.xyzw = cmp(r0.xyzw >= float4(0.300000012,0.300000012,0.300000012,0.300000012));
  r0.xyzw = r0.xyzw ? float4(0.625,0.625,-0.375,-0.375) : float4(0.375,0.375,-0.625,-0.625);
  r1.x = 1 / g_psScene.m_shadowMapResolutions.x;
  r1.y = 0.5 / g_psScene.m_shadowMapResolutions.x;
  r1.z = 0.5 + -r1.y;
  r2.xy = v1.xy / v1.ww;
  r2.xy = -g_psScene.m_cameraCenterOffset.xy + r2.xy;
  r2.xy = g_psScene.m_projectionParam.xy * r2.xy;
  r2.zw = v2.xy / v2.ww;
  r1.w = g_DepthTexture.Sample(g_samplerPoint_Wrap_s, r2.zw).x;
  r1.w = -g_psScene.m_projectionParam.w + r1.w;
  r3.z = g_psScene.m_projectionParam.z / r1.w;
  r3.xy = r3.zz * r2.xy;
  
  float4 stereo = StereoParams.Load(0);
  r3.x -= stereo.x * (r3.z - stereo.y) / g_psScene.m_projection._m00;
  
  r4.xy = r3.xy;
  r4.z = g_psScene.m_shadowProjection2._m33 + r3.z;
  r4.w = 1;
  r2.x = dot(r4.xyzw, g_psScene.m_shadowProjection._m00_m10_m20_m30);
  r2.y = dot(r4.xyzw, g_psScene.m_shadowProjection._m01_m11_m21_m31);
  r5.xyzw = max(r2.xyxy, r1.yyyy);
  r5.xyzw = min(r5.xyzw, r1.zzzz);
  r5.xyzw = g_psLight.m_lightSourcePos.xyxy + r5.xyzw;
  r6.xyzw = r0.xyzy * r1.xxxx + r5.zwzw;
  r0.xyzw = r0.xwzw * r1.xxxx + r5.xyzw;
  r1.x = dot(r4.xyzw, g_psScene.m_shadowProjection._m02_m12_m22_m32);
  r1.x = 1 + r1.x;
  r1.x = g_psScene.m_shadowProjection2._m30 * r1.x;
  r1.y = g_ShadowTexture.SampleCmp(g_samplerComparisonLess_Linear_Clmap_s, r6.xy, r1.x).x;
  r1.z = g_ShadowTexture.SampleCmp(g_samplerComparisonLess_Linear_Clmap_s, r6.zw, r1.x).x;
  r1.y = r1.y + r1.z;
  r0.x = g_ShadowTexture.SampleCmp(g_samplerComparisonLess_Linear_Clmap_s, r0.xy, r1.x).x;
  r0.y = g_ShadowTexture.SampleCmp(g_samplerComparisonLess_Linear_Clmap_s, r0.zw, r1.x).x;
  r0.x = r1.y + r0.x;
  r0.x = r0.x + r0.y;
  r0.x = -r0.x * 0.25 + 1;
  r1.x = dot(r4.xyzw, g_psScene.m_view._m00_m10_m20_m30);
  r1.y = dot(r4.xyzw, g_psScene.m_view._m02_m12_m22_m32);
  r0.yz = r1.xy * g_psLight.m_lightSourcePos.zw + float2(0.5,0.5);
  r0.y = g_WorldShadowMask.Sample(g_samplerLinear_Wrap_s, r0.yz).x;
  r0.y = -r0.x * r0.x + r0.y;
  r0.x = r0.x * r0.x;
  r1.xy = float2(-0,-0);
  r1.zw = -g_psLight.m_lightSourceParam3.xy;
  r1.xyz = r4.xyz + r1.xyz;
  r0.z = dot(r1.xyz, r1.xyz);
  r0.w = cmp(r1.z >= 0);
  r0.w = r0.w ? 1.000000 : 0;
  r0.z = sqrt(r0.z);
  r0.z = r0.z + r1.w;
  r0.z = max(0, r0.z);
  r0.z = saturate(g_psLight.m_lightSourceParam1.x * r0.z);
  r0.z = r0.z * r0.w;
  r0.x = r0.z * r0.y + r0.x;
  r0.x = saturate(-g_psLight.m_lightSourceParam1.w + r0.x);
  r1.x = dot(g_psObject.m_localParam[0].xyzw, r4.xyzw);
  r1.y = dot(g_psObject.m_localParam[1].xyzw, r4.xyzw);
  r0.y = g_CloudTexture.Sample(g_samplerLinear_Wrap_s, r1.xy).x;
  r0.y = saturate(g_psObject.m_localParam[3].w * r0.y);
  r0.x = r0.x * r0.y;
  r0.y = max(g_psLight.m_lightColor1.x, r0.x);
  r0.y = g_psLight.m_lightColor1.y * r0.y;
  r1.xyz = g_NormalTexture.Sample(g_samplerPoint_Wrap_s, r2.zw).xyz;
  r2.xyzw = g_SpecularTexture.Sample(g_samplerPoint_Wrap_s, r2.zw).yxzw;
  r0.zw = r1.xy * float2(2,2) + float2(-1,-1);
  r1.x = dot(r1.zz, r1.zz);
  r1.z = -1 + r1.x;
  r1.w = dot(r0.zw, r0.zw);
  r3.w = -r1.z * r1.z + 1;
  r1.w = r3.w * r1.w + 1.00000001e-007;
  r0.zw = r3.ww * r0.zw;
  r1.w = rsqrt(r1.w);
  r1.xy = r1.ww * r0.zw;
  r0.z = dot(g_psLight.m_lightDir0.xyz, r1.xyz);
  r0.w = -r0.z * r0.z + 1;
  r0.w = r0.w * r2.w + r0.z;
  r0.z = saturate(4 * r0.z);
  r4.yz = float2(0.25,0.75);
  r4.x = r2.z;
  r5.xyzw = g_MaterialTexture.Sample(g_samplerPoint_Clamp_s, r4.xy).xyzw;
  r4.yz = g_MaterialTexture.Sample(g_samplerPoint_Clamp_s, r4.xz).xw;
  r5.xyzw = r5.wxyz * r2.wxxx;
  r0.w = saturate(max(r5.x, r0.w));
  r6.xyz = g_psLight.m_lightColor0.xyz * g_psScene.m_exposure.zzz;
  r7.xyz = r6.xyz * r0.www;
  r5.xyz = r6.xyz * r5.yzw;
  r6.xyz = r7.xyz * r0.xxx;
  r0.x = max(g_psLight.m_lightSourceParam2.x, r0.x);
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = r3.xyz * r0.www;
  r0.w = dot(-r3.xyz, r1.xyz);
  r7.x = saturate(r0.w);
  r0.w = r0.w + r0.w;
  r8.xyz = r1.xyz * -r0.www + -r3.xyz;
  r8.xyz = -g_psLight.m_lightDir0.xyz + -r8.xyz;
  r7.y = 0.0199999996;
  r0.w = g_lut1.Sample(g_samplerLinear_Clamp_s, r7.xy).x;
  r1.w = 1 + -r2.y;
  r0.w = r1.w * r0.w;
  r0.w = r0.w * r2.x;
  r0.w = 0.5 * r0.w;
  r7.xyz = r6.xyz * r0.www;
  o0.xyz = -r7.xyz * r0.yyy + r6.xyz;
  o0.w = 1;
  r1.w = dot(r8.xyz, r8.xyz);
  r1.w = sqrt(r1.w);
  r1.w = saturate(g_psLight.m_lightColor0.w / r1.w);
  r6.xyz = r1.www * r8.xyz + g_psLight.m_lightDir0.xyz;
  r1.w = dot(r6.xyz, r6.xyz);
  r1.w = rsqrt(r1.w);
  r6.xyz = r6.xyz * r1.www + -r3.xyz;
  r1.w = dot(r6.xyz, r6.xyz);
  r1.w = rsqrt(r1.w);
  r6.xyz = r6.xyz * r1.www;
  r2.x = saturate(dot(r6.xyz, r1.xyz));
  r4.x = dot(r6.xyz, g_psLight.m_lightDir0.xyz);
  r2.z = r4.z;
  r1.w = g_lut1.Sample(g_samplerLinear_Clamp_s, r4.xy).x;
  r2.xyz = r2.xyz * r2.xyz;
  r2.xyz = r2.xyz * float3(0.984375,0.9375,0.9375) + float3(0.0078125,0.03125,0.03125);
  r2.xy = g_lut2.Sample(g_samplerLinear_Clamp_s, r2.xyz).xy;
  r2.xy = r2.xy * r2.xy;
  r2.x = r2.x / r2.y;
  r1.w = r2.x * r1.w;
  r0.z = r1.w * r0.z;
  r2.xyz = r5.xyz * r0.zzz;
  r0.z = dot(r3.xyz, r1.xyz);
  r0.z = r0.z + r0.z;
  r1.xyz = r1.xyz * -r0.zzz + r3.xyz;
  r1.xy = r1.xy * float2(-0.4921875,-0.4921875) + float2(0.5,0.5);
  r0.z = cmp(0 < r1.z);
  r1.zw = r0.zz ? float2(1.048576e+009,0) : 0;
  r1.xy = r1.xy * float2(0.25,0.125) + r1.zw;
  r1.xyz = g_SkyReflectTexture.Sample(g_samplerLinear_Clamp_s, r1.xy).xyz;
  r1.xyz = r1.xyz * r0.www;
  r0.yzw = r1.xyz * r0.yyy;
  o1.xyz = r2.xyz * r0.xxx + r0.yzw;
  o1.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.25 on Wed Jan 20 11:37:39 2016
//
//
// Buffer Definitions: 
//
// cbuffer cPSScene
// {
//
//   struct PSScene
//   {
//       
//       float4x4 m_projectionView;     // Offset:    0
//       float4x4 m_projection;         // Offset:   64
//       float4x4 m_view;               // Offset:  128
//       float4x4 m_shadowProjection;   // Offset:  192
//       float4x4 m_shadowProjection2;  // Offset:  256
//       float4 m_eyepos;               // Offset:  320
//       float4 m_projectionParam;      // Offset:  336
//       float4 m_viewportSize;         // Offset:  352
//       float4 m_exposure;             // Offset:  368
//       float4 m_fogParam[3];          // Offset:  384
//       float4 m_fogColor;             // Offset:  432
//       float4 m_cameraCenterOffset;   // Offset:  448
//       float4 m_shadowMapResolutions; // Offset:  464
//
//   } g_psScene;                       // Offset:    0 Size:   480
//
// }
//
// cbuffer cPSObject
// {
//
//   struct PSObject
//   {
//       
//       float4x4 m_viewWorld;          // Offset:    0
//       float4x4 m_world;              // Offset:   64
//       float4 m_useWeightCount;       // Offset:  128
//       float4 m_localParam[4];        // Offset:  144
//
//   } g_psObject;                      // Offset:    0 Size:   208
//
// }
//
// cbuffer cPSLight
// {
//
//   struct PSLight
//   {
//       
//       float4 m_lightDir0;            // Offset:    0
//       float4 m_lightColor0;          // Offset:   16
//       float4 m_lightColor1;          // Offset:   32
//       float4 m_lightSourcePos;       // Offset:   48
//       float4 m_lightSourceColor;     // Offset:   64
//       float4 m_lightSourceDir;       // Offset:   80
//       float4 m_lightSourceParam1;    // Offset:   96
//       float4 m_lightSourceParam2;    // Offset:  112
//       float4 m_lightSourceParam3;    // Offset:  128
//       float4 m_lightPos0;            // Offset:  144
//       float4 m_lightParam2;          // Offset:  160
//
//   } g_psLight;                       // Offset:    0 Size:   176
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_samplerPoint_Wrap               sampler      NA          NA    8        1
// g_samplerPoint_Clamp              sampler      NA          NA    9        1
// g_samplerLinear_Wrap              sampler      NA          NA   10        1
// g_samplerLinear_Clamp             sampler      NA          NA   11        1
// g_samplerComparisonLess_Linear_Clmap  sampler_c      NA          NA   15        1
// g_NormalTexture                   texture  float4          2d    0        1
// g_SpecularTexture                 texture  float4          2d    1        1
// g_DepthTexture                    texture  float4          2d    2        1
// g_ShadowTexture                   texture  float4          2d    3        1
// g_CloudTexture                    texture  float4          2d    4        1
// g_lut2                            texture  float4          3d    8        1
// g_lut1                            texture  float4          2d    9        1
// g_MaterialTexture                 texture  float4          2d   10        1
// g_WorldShadowMask                 texture  float4          2d   13        1
// g_SkyReflectTexture               texture  float4          2d   15        1
// cPSScene                          cbuffer      NA          NA    2        1
// cPSLight                          cbuffer      NA          NA    3        1
// cPSObject                         cbuffer      NA          NA    5        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy  
// TEXCOORD                 0   xyzw        1     NONE   float   xy w
// TEXCOORD                 1   xyzw        2     NONE   float   xy w
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                1   xyzw        1   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb2[30], immediateIndexed
dcl_constantbuffer cb5[13], immediateIndexed
dcl_constantbuffer cb3[9], immediateIndexed
dcl_sampler s8, mode_default
dcl_sampler s9, mode_default
dcl_sampler s10, mode_default
dcl_sampler s11, mode_default
dcl_sampler s15, mode_comparison
dcl_resource_texture2d (float,float,float,float) t0
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_resource_texture2d (float,float,float,float) t4
dcl_resource_texture3d (float,float,float,float) t8
dcl_resource_texture2d (float,float,float,float) t9
dcl_resource_texture2d (float,float,float,float) t10
dcl_resource_texture2d (float,float,float,float) t13
dcl_resource_texture2d (float,float,float,float) t15
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xyw
dcl_input_ps linear v2.xyw
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 9
round_ni r0.xyzw, v0.xyxy
mad r0.xyzw, r0.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000), l(0.100000, 0.100000, 0.100000, 0.100000)
frc r0.xyzw, r0.xyzw
ge r0.xyzw, r0.xyzw, l(0.300000, 0.300000, 0.300000, 0.300000)
movc r0.xyzw, r0.xyzw, l(0.625000,0.625000,-0.375000,-0.375000), l(0.375000,0.375000,-0.625000,-0.625000)
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), cb2[29].x
div r1.y, l(0.500000), cb2[29].x
add r1.z, -r1.y, l(0.500000)
div r2.xy, v1.xyxx, v1.wwww
add r2.xy, r2.xyxx, -cb2[28].xyxx
mul r2.xy, r2.xyxx, cb2[21].xyxx
div r2.zw, v2.xxxy, v2.wwww
sample_indexable(texture2d)(float,float,float,float) r1.w, r2.zwzz, t2.yzwx, s8
add r1.w, r1.w, -cb2[21].w
div r3.z, cb2[21].z, r1.w
mul r3.xy, r2.xyxx, r3.zzzz
mov r4.xy, r3.xyxx
add r4.z, r3.z, cb2[19].w
mov r4.w, l(1.000000)
dp4 r2.x, r4.xyzw, cb2[12].xyzw
dp4 r2.y, r4.xyzw, cb2[13].xyzw
max r5.xyzw, r1.yyyy, r2.xyxy
min r5.xyzw, r1.zzzz, r5.xyzw
add r5.xyzw, r5.xyzw, cb3[3].xyxy
mad r6.xyzw, r0.xyzy, r1.xxxx, r5.zwzw
mad r0.xyzw, r0.xwzw, r1.xxxx, r5.xyzw
dp4 r1.x, r4.xyzw, cb2[14].xyzw
add r1.x, r1.x, l(1.000000)
mul r1.x, r1.x, cb2[16].w
sample_c_indexable(texture2d)(float,float,float,float) r1.y, r6.xyxx, t3.xxxx, s15, r1.x
sample_c_indexable(texture2d)(float,float,float,float) r1.z, r6.zwzz, t3.xxxx, s15, r1.x
add r1.y, r1.z, r1.y
sample_c_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t3.xxxx, s15, r1.x
sample_c_indexable(texture2d)(float,float,float,float) r0.y, r0.zwzz, t3.xxxx, s15, r1.x
add r0.x, r0.x, r1.y
add r0.x, r0.y, r0.x
mad r0.x, -r0.x, l(0.250000), l(1.000000)
dp4 r1.x, r4.xyzw, cb2[8].xyzw
dp4 r1.y, r4.xyzw, cb2[10].xyzw
mad r0.yz, r1.xxyx, cb3[3].zzwz, l(0.000000, 0.500000, 0.500000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r0.y, r0.yzyy, t13.yxzw, s10
mad r0.y, -r0.x, r0.x, r0.y
mul r0.x, r0.x, r0.x
mov r1.xy, l(-0.000000,-0.000000,0,0)
mov r1.zw, -cb3[8].xxxy
add r1.xyz, r1.xyzx, r4.xyzx
dp3 r0.z, r1.xyzx, r1.xyzx
ge r0.w, r1.z, l(0.000000)
and r0.w, r0.w, l(0x3f800000)
sqrt r0.z, r0.z
add r0.z, r1.w, r0.z
max r0.z, r0.z, l(0.000000)
mul_sat r0.z, r0.z, cb3[6].x
mul r0.z, r0.w, r0.z
mad r0.x, r0.z, r0.y, r0.x
add_sat r0.x, r0.x, -cb3[6].w
dp4 r1.x, cb5[9].xyzw, r4.xyzw
dp4 r1.y, cb5[10].xyzw, r4.xyzw
sample_indexable(texture2d)(float,float,float,float) r0.y, r1.xyxx, t4.yxzw, s10
mul_sat r0.y, r0.y, cb5[12].w
mul r0.x, r0.y, r0.x
max r0.y, r0.x, cb3[2].x
mul r0.y, r0.y, cb3[2].y
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r2.zwzz, t0.xyzw, s8
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.zwzz, t1.yxzw, s8
mad r0.zw, r1.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
dp2 r1.x, r1.zzzz, r1.zzzz
add r1.z, r1.x, l(-1.000000)
dp2 r1.w, r0.zwzz, r0.zwzz
mad r3.w, -r1.z, r1.z, l(1.000000)
mad r1.w, r3.w, r1.w, l(1.000000012E-007)
mul r0.zw, r0.zzzw, r3.wwww
rsq r1.w, r1.w
mul r1.xy, r0.zwzz, r1.wwww
dp3 r0.z, cb3[0].xyzx, r1.xyzx
mad r0.w, -r0.z, r0.z, l(1.000000)
mad r0.w, r0.w, r2.w, r0.z
mul_sat r0.z, r0.z, l(4.000000)
mov r4.yz, l(0,0.250000,0.750000,0)
mov r4.x, r2.z
sample_indexable(texture2d)(float,float,float,float) r5.xyzw, r4.xyxx, t10.xyzw, s9
sample_indexable(texture2d)(float,float,float,float) r4.yz, r4.xzxx, t10.yxwz, s9
mul r5.xyzw, r2.wxxx, r5.wxyz
max_sat r0.w, r0.w, r5.x
mul r6.xyz, cb2[23].zzzz, cb3[1].xyzx
mul r7.xyz, r0.wwww, r6.xyzx
mul r5.xyz, r5.yzwy, r6.xyzx
mul r6.xyz, r0.xxxx, r7.xyzx
max r0.x, r0.x, cb3[7].x
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, r3.xyzx
dp3 r0.w, -r3.xyzx, r1.xyzx
mov_sat r7.x, r0.w
add r0.w, r0.w, r0.w
mad r8.xyz, r1.xyzx, -r0.wwww, -r3.xyzx
add r8.xyz, -r8.xyzx, -cb3[0].xyzx
mov r7.y, l(0.020000)
sample_indexable(texture2d)(float,float,float,float) r0.w, r7.xyxx, t9.yzwx, s11
add r1.w, -r2.y, l(1.000000)
mul r0.w, r0.w, r1.w
mul r0.w, r2.x, r0.w
mul r0.w, r0.w, l(0.500000)
mul r7.xyz, r0.wwww, r6.xyzx
mad o0.xyz, -r7.xyzx, r0.yyyy, r6.xyzx
mov o0.w, l(1.000000)
dp3 r1.w, r8.xyzx, r8.xyzx
sqrt r1.w, r1.w
div_sat r1.w, cb3[1].w, r1.w
mad r6.xyz, r1.wwww, r8.xyzx, cb3[0].xyzx
dp3 r1.w, r6.xyzx, r6.xyzx
rsq r1.w, r1.w
mad r6.xyz, r6.xyzx, r1.wwww, -r3.xyzx
dp3 r1.w, r6.xyzx, r6.xyzx
rsq r1.w, r1.w
mul r6.xyz, r1.wwww, r6.xyzx
dp3_sat r2.x, r6.xyzx, r1.xyzx
dp3 r4.x, r6.xyzx, cb3[0].xyzx
mov r2.z, r4.z
sample_indexable(texture2d)(float,float,float,float) r1.w, r4.xyxx, t9.yzwx, s11
mul r2.xyz, r2.xyzx, r2.xyzx
mad r2.xyz, r2.xyzx, l(0.984375, 0.937500, 0.937500, 0.000000), l(0.00781250000, 0.031250, 0.031250, 0.000000)
sample_indexable(texture3d)(float,float,float,float) r2.xy, r2.xyzx, t8.xyzw, s11
mul r2.xy, r2.xyxx, r2.xyxx
div r2.x, r2.x, r2.y
mul r1.w, r1.w, r2.x
mul r0.z, r0.z, r1.w
mul r2.xyz, r0.zzzz, r5.xyzx
dp3 r0.z, r3.xyzx, r1.xyzx
add r0.z, r0.z, r0.z
mad r1.xyz, r1.xyzx, -r0.zzzz, r3.xyzx
mad r1.xy, r1.xyxx, l(-0.492187500, -0.492187500, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
lt r0.z, l(0.000000), r1.z
and r1.zw, r0.zzzz, l(0, 0, 0x3e800000, 0)
mad r1.xy, r1.xyxx, l(0.250000, 0.125000, 0.000000, 0.000000), r1.zwzz
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r1.xyxx, t15.xyzw, s11
mul r1.xyz, r0.wwww, r1.xyzx
mul r0.yzw, r0.yyyy, r1.xxyz
mad o1.xyz, r2.xyzx, r0.xxxx, r0.yzwy
mov o1.w, l(1.000000)
ret 
// Approximately 141 instruction slots used

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