//Water PS.
// ---- Created with 3Dmigoto v1.3.14 on Sun Feb 10 15:42:12 2019

cbuffer SceneInfo : register(b0)
{
  row_major float4x4 viewProjMat : packoffset(c0);
  row_major float3x4 transposeViewMat : packoffset(c4);
  row_major float3x4 transposeViewInvMat : packoffset(c7);
  float4 projElement[2] : packoffset(c10);
  float4 projInvElements[2] : packoffset(c12);
  row_major float4x4 viewProjInvMat : packoffset(c14);
  row_major float4x4 prevViewProjMat : packoffset(c18);
  float3 ZToLinear : packoffset(c22);
  float subdivisionLevel : packoffset(c22.w);
  float2 screenSize : packoffset(c23);
  float2 screenInverseSize : packoffset(c23.z);
  float2 cullingHelper : packoffset(c24);
  float cameraNearPlane : packoffset(c24.z);
  float cameraFarPlane : packoffset(c24.w);
  float4 viewFrustum[6] : packoffset(c25);
  float4 clipplane : packoffset(c31);
}

cbuffer EnvironmentInfo : register(b1)
{
  uint timeMillisecond : packoffset(c0);
  uint frameCount : packoffset(c0.y);
  uint isOddFrame : packoffset(c0.z);
  uint reserveEnvironmentInfo : packoffset(c0.w);
  row_major float4x4 userGlobalParams : packoffset(c1);
  float breakingPBRSpecularIntensity : packoffset(c5);
  float breakingPBRIBLReflectanceBias : packoffset(c5.y);
  float breakingPBRIBLIntensity : packoffset(c5.z);
  float breakingPBR_Reserved : packoffset(c5.w);
}

cbuffer UserMaterial : register(b2)
{
  float4 VAR_ColorParam : packoffset(c0);
  float VAR_RefractiveIndex : packoffset(c1);
  float VAR_Transparent : packoffset(c1.y);
  float VAR_VolumeBlend : packoffset(c1.z);
  float VAR_VolumeBlend_INV : packoffset(c1.w);
  float VAR_UVOfs_U : packoffset(c2);
  float VAR_UVOfs_V : packoffset(c2.y);
  float VAR_UVScroll_U : packoffset(c2.z);
  float VAR_UVScroll_V : packoffset(c2.w);
  float VAR_UVScale_U : packoffset(c3);
  float VAR_UVScale_V : packoffset(c3.y);
  float VAR_UVOfs_U_AlphaMap : packoffset(c3.z);
  float VAR_UVOfs_V_AlphaMap : packoffset(c3.w);
  float VAR_UVScroll_U_AlphaMap : packoffset(c4);
  float VAR_UVScroll_V_AlphaMap : packoffset(c4.y);
  float VAR_UVScale_U_AlphaMap : packoffset(c4.z);
  float VAR_UVScale_V_AlphaMap : packoffset(c4.w);
  float VAR_UseReflect : packoffset(c5);
  float VAR_UseFakeReflect : packoffset(c5.y);
  float VAR_ReflectBrightnessScale : packoffset(c5.z);
  float VAR_Fresnel_min : packoffset(c5.w);
  float VAR_Fresnel_max : packoffset(c6);
  float CAPCOM_MATERIAL_RESERVE0 : packoffset(c6.y);
  float CAPCOM_MATERIAL_RESERVE1 : packoffset(c6.z);
  float CAPCOM_MATERIAL_RESERVE2 : packoffset(c6.w);
}

SamplerState BilinearWrap_s : register(s0);
Texture2D<float> ReadonlyDepth : register(t0);
TextureCube<float4> DynamicCubeMap : register(t1);
Texture2D<float4> DynamicTransparentHDR : register(t2);
Texture2D<float4> ColorMap : register(t3);
Texture2D<float4> NormalMap : register(t4);
Texture2D<float4> AlphaMap : register(t5);


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


void main(
  float4 v0 : SV_POSITION0,
  float4 v1 : INTERPOLATOR0,
  float4 v2 : INTERPOLATOR1,
  float4 v3 : INTERPOLATOR2,
  out float4 o0 : SV_TARGET0,
  out float o1 : SV_TARGET1)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 stereo = StereoParams.Load(0);
  float4 iniparams = IniParams.Load(0);
  
  r0.x = dot(v1.xyz, v1.xyz);
  r0.x = rsqrt(r0.x);
  r0.xyz = v1.xyz * r0.xxx;
  r0.w = dot(v2.yzw, v2.yzw);
  r0.w = rsqrt(r0.w);
  r1.xyz = v2.yzw * r0.www;
  
  
  
  r2.xyz = r1.yzx * r0.zxy;
  r2.xyz = r0.yzx * r1.zxy + -r2.xyz;
  r0.w = cmp(v3.x < 0);
  r2.xyz = r0.www ? -r2.xyz : r2.xyz;
  r3.x = -transposeViewInvMat._m03;
  r3.y = -transposeViewInvMat._m13;
  r3.z = -transposeViewInvMat._m23;
  r3.xyz = v3.yzw + r3.xyz;
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = r3.xyz * r0.www;
  
  r4.xy = cmp(float2(0,0) < abs(VAR_UVScroll_U));
  if (r4.x != 0) {
    r0.w = 1000 / VAR_UVScroll_U;
    r1.w = timeMillisecond;
    r0.w = r1.w / r0.w;
    r5.x = frac(r0.w);
  } else {
    r5.x = 0;
  }
  if (r4.y != 0) {
    r0.w = 1000 / VAR_UVScroll_V;
    r1.w = timeMillisecond;
    r0.w = r1.w / r0.w;
    r5.y = frac(r0.w);
  } else {
    r5.y = 0;
  }
  r4.x = v1.w;
  r4.y = v2.x;
  r4.zw = VAR_UVOfs_U + r5.xy;
  r4.zw = r4.xy * VAR_UVScale_U + r4.zw;
  r5.xy = cmp(float2(0,0) < abs(VAR_UVScroll_U_AlphaMap));
  if (r5.x != 0) {
    r0.w = 1000 / VAR_UVScroll_U_AlphaMap;
    r1.w = timeMillisecond;
    r0.w = r1.w / r0.w;
    r6.x = frac(r0.w);
  } else {
    r6.x = 0;
  }
  if (r5.y != 0) {
    r0.w = 1000 / VAR_UVScroll_V_AlphaMap;
    r1.w = timeMillisecond;
    r0.w = r1.w / r0.w;
    r6.y = frac(r0.w);
  } else {
    r6.y = 0;
  }
  r5.xy = VAR_UVOfs_U_AlphaMap + r6.xy;
  r4.xy = r4.xy * VAR_UVScale_U_AlphaMap + r5.xy;
  r5.xyz = NormalMap.Sample(BilinearWrap_s, r4.zw).xyz;
  r6.xyzw = ColorMap.Sample(BilinearWrap_s, r4.zw).xyzw;
  r5.xyz = r5.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = r2.xyz * r0.www;
  
  //r5.x-=stereo.x*r5.z*iniparams.x;
  
  r2.xyz = r5.yyy * r2.xyz;
  r1.xyz = r5.xxx * r1.xyz + r2.xyz;
  r0.xyz = r5.zzz * r0.xyz + r1.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r0.w = AlphaMap.Sample(BilinearWrap_s, r4.xy).x;
  r1.x = VAR_ColorParam.w * r6.w;
  r0.w = r1.x * r0.w;
  r1.x = cmp(0 < VAR_VolumeBlend);
  if (r1.x != 0) {
    r1.xy = (int2)v0.xy;
    r1.zw = float2(0,0);
    r1.x = ReadonlyDepth.Load(r1.xyz).x;
    r1.x = -r1.x * ZToLinear.y + ZToLinear.x;
    r1.y = -v0.z * ZToLinear.y + ZToLinear.x;
    r1.xy = ZToLinear.zz / r1.xy;
    r1.x = r1.x + -r1.y;
    r1.y = 1 / VAR_VolumeBlend;
    r1.x = saturate(r1.x * r1.y);
    r1.y = 1 + -r1.x;
    r1.y = min(r1.x, r1.y);
    r1.y = r1.y * 2 + -r1.x;
    r1.x = VAR_VolumeBlend_INV * r1.y + r1.x;
    r1.x = max(9.99999997e-007, r1.x);
    r1.x = log2(r1.x);
    r1.x = 2.20000005 * r1.x;
    r1.xyz = exp2(r1.xxx);
  } else {
    r1.xyz = float3(1,1,1);
  }
  r1.w = 9.99999975e-005 * screenSize.x;
  r1.w = r1.w / v0.w;
  r2.x = -1 + VAR_RefractiveIndex;
  r1.w = r2.x * r1.w;
  r1.w = r1.w * r0.w;
  r2.xyz = VAR_ColorParam.xyz * r6.xyz + float3(-1,-1,-1);
  r2.xyz = r2.xyz * r0.www;
  r4.xw = r1.ww * r1.xy;
  r5.x = dot(r3.xyz, transposeViewMat._m00_m01_m02);
  r5.y = dot(r3.xyz, transposeViewMat._m10_m11_m12);
  r5.z = dot(r3.xyz, transposeViewMat._m20_m21_m22);
  r6.x = dot(r0.xyz, transposeViewMat._m00_m01_m02);
  r6.y = dot(r0.xyz, transposeViewMat._m10_m11_m12);
  r6.z = dot(r0.xyz, transposeViewMat._m20_m21_m22);
  r1.w = dot(r5.xyz, r5.xyz);
  r1.w = rsqrt(r1.w);
  r7.xyz = r5.xyz * r1.www;
  r2.w = dot(r6.xyz, r6.xyz);
  r2.w = rsqrt(r2.w);
  r6.xyz = r6.xyz * r2.www;
  r5.xy = r5.xy * r1.ww + -r6.xy;
  r4.y = dot(r6.xyz, r7.xyz);
  r4.z = 1;
  r5.xy = r4.zy * r5.xy;
  r4.zw = r5.xy * r4.yw;
  r4.y = -1;
  r4.xy = r4.zw * r4.xy;
  r4.xy = screenInverseSize.xy * v0.xy + r4.xy;
  r4.xyz = DynamicTransparentHDR.Sample(BilinearWrap_s, r4.xy).xyz;
  r2.xyz = r1.xyz * r2.xyz + float3(1,1,1);
  r2.xyz = r2.xyz * r4.xyz;
  r1.w = VAR_Transparent * r0.w;
  r1.w = r1.w * r1.x;
  r2.w = cmp(0 < VAR_UseReflect);
  if (r2.w != 0) {
    r2.w = cmp(0 < VAR_UseFakeReflect);
    if (r2.w != 0) {
      r2.w = dot(r3.xyz, r0.xyz);
      r2.w = r2.w + r2.w;
      r4.xyz = -r2.www * r0.zxy + r3.zxy;
      r2.w = min(abs(r4.x), abs(r4.y));
      r3.w = max(abs(r4.x), abs(r4.y));
      r3.w = 1 / r3.w;
      r2.w = r3.w * r2.w;
      r3.w = r2.w * r2.w;
      r4.w = r3.w * 0.0208350997 + -0.0851330012;
      r4.w = r3.w * r4.w + 0.180141002;
      r4.w = r3.w * r4.w + -0.330299497;
      r3.w = r3.w * r4.w + 0.999866009;
      r4.w = r3.w * r2.w;
      r5.x = cmp(abs(r4.y) < abs(r4.x));
      r4.w = r4.w * -2 + 1.57079637;
      r4.w = r5.x ? r4.w : 0;
      r2.w = r2.w * r3.w + r4.w;
      r5.xy = cmp(r4.yz < -r4.yz);
      r3.w = r5.x ? -3.141593 : 0;
      r2.w = r3.w + r2.w;
      r3.w = min(r4.x, r4.y);
      r4.x = max(r4.x, r4.y);
      r3.w = cmp(r3.w < -r3.w);
      r4.x = cmp(r4.x >= -r4.x);
      r3.w = r3.w ? r4.x : 0;
      r2.w = r3.w ? -r2.w : r2.w;
      r2.w = 0.159154937 * r2.w;
      r4.x = frac(r2.w);
      r2.w = 1 + -abs(r4.z);
      r2.w = sqrt(r2.w);
      r3.w = abs(r4.z) * -0.0187292993 + 0.0742610022;
      r3.w = r3.w * abs(r4.z) + -0.212114394;
      r3.w = r3.w * abs(r4.z) + 1.57072878;
      r4.z = r3.w * r2.w;
      r4.z = r4.z * -2 + 3.14159274;
      r4.z = r5.y ? r4.z : 0;
      r2.w = r3.w * r2.w + r4.z;
      r4.y = 0.318309873 * r2.w;
      r4.xyz = DynamicTransparentHDR.Sample(BilinearWrap_s, r4.xy).xyz;
      r4.xyz = VAR_ReflectBrightnessScale * r4.xyz;
    } else {
      r2.w = dot(r3.xyz, r0.xyz);
      r2.w = r2.w + r2.w;
      r5.xyz = -r2.www * r0.xyz + r3.xyz;
      r5.xyz = DynamicCubeMap.SampleLevel(BilinearWrap_s, r5.xyz, 0).xyz;
      r5.xyz = VAR_ReflectBrightnessScale * r5.xyz;
      r4.xyz = r5.xyz * r0.www;
    }
    r0.x = dot(r0.xyz, -r3.xyz);
    r0.y = -VAR_Fresnel_max + VAR_Fresnel_min;
    r0.x = -VAR_Fresnel_max + r0.x;
    r0.y = 1 / r0.y;
    r0.x = saturate(r0.x * r0.y);
    r0.y = r0.x * -2 + 3;
    r0.x = r0.x * r0.x;
    r0.x = r0.y * r0.x;
    r0.xyz = r4.xyz * r0.xxx;
    r2.xyz = r0.xyz * r1.xyz + r2.xyz;
  }
  o0.xyz = r2.xyz * r1.www;
  o0.w = r1.w;
  o1.x = r1.w;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.14 on Sun Feb 10 15:42:12 2019
//
//
// Buffer Definitions:
//
// cbuffer SceneInfo
// {
//
//   row_major float4x4 viewProjMat;    // Offset:    0 Size:    64 [unused]
//   row_major float3x4 transposeViewMat;// Offset:   64 Size:    48
//   row_major float3x4 transposeViewInvMat;// Offset:  112 Size:    48
//   float4 projElement[2];             // Offset:  160 Size:    32 [unused]
//   float4 projInvElements[2];         // Offset:  192 Size:    32 [unused]
//   row_major float4x4 viewProjInvMat; // Offset:  224 Size:    64 [unused]
//   row_major float4x4 prevViewProjMat;// Offset:  288 Size:    64 [unused]
//   float3 ZToLinear;                  // Offset:  352 Size:    12
//   float subdivisionLevel;            // Offset:  364 Size:     4 [unused]
//   float2 screenSize;                 // Offset:  368 Size:     8
//   float2 screenInverseSize;          // Offset:  376 Size:     8
//   float2 cullingHelper;              // Offset:  384 Size:     8 [unused]
//   float cameraNearPlane;             // Offset:  392 Size:     4 [unused]
//   float cameraFarPlane;              // Offset:  396 Size:     4 [unused]
//   float4 viewFrustum[6];             // Offset:  400 Size:    96 [unused]
//   float4 clipplane;                  // Offset:  496 Size:    16 [unused]
//
// }
//
// cbuffer EnvironmentInfo
// {
//
//   uint timeMillisecond;              // Offset:    0 Size:     4
//   uint frameCount;                   // Offset:    4 Size:     4 [unused]
//   uint isOddFrame;                   // Offset:    8 Size:     4 [unused]
//   uint reserveEnvironmentInfo;       // Offset:   12 Size:     4 [unused]
//   row_major float4x4 userGlobalParams;// Offset:   16 Size:    64 [unused]
//   float breakingPBRSpecularIntensity;// Offset:   80 Size:     4 [unused]
//   float breakingPBRIBLReflectanceBias;// Offset:   84 Size:     4 [unused]
//   float breakingPBRIBLIntensity;     // Offset:   88 Size:     4 [unused]
//   float breakingPBR_Reserved;        // Offset:   92 Size:     4 [unused]
//
// }
//
// cbuffer UserMaterial
// {
//
//   float4 VAR_ColorParam;             // Offset:    0 Size:    16
//   float VAR_RefractiveIndex;         // Offset:   16 Size:     4
//   float VAR_Transparent;             // Offset:   20 Size:     4
//   float VAR_VolumeBlend;             // Offset:   24 Size:     4
//   float VAR_VolumeBlend_INV;         // Offset:   28 Size:     4
//   float VAR_UVOfs_U;                 // Offset:   32 Size:     4
//   float VAR_UVOfs_V;                 // Offset:   36 Size:     4
//   float VAR_UVScroll_U;              // Offset:   40 Size:     4
//   float VAR_UVScroll_V;              // Offset:   44 Size:     4
//   float VAR_UVScale_U;               // Offset:   48 Size:     4
//   float VAR_UVScale_V;               // Offset:   52 Size:     4
//   float VAR_UVOfs_U_AlphaMap;        // Offset:   56 Size:     4
//   float VAR_UVOfs_V_AlphaMap;        // Offset:   60 Size:     4
//   float VAR_UVScroll_U_AlphaMap;     // Offset:   64 Size:     4
//   float VAR_UVScroll_V_AlphaMap;     // Offset:   68 Size:     4
//   float VAR_UVScale_U_AlphaMap;      // Offset:   72 Size:     4
//   float VAR_UVScale_V_AlphaMap;      // Offset:   76 Size:     4
//   float VAR_UseReflect;              // Offset:   80 Size:     4
//   float VAR_UseFakeReflect;          // Offset:   84 Size:     4
//   float VAR_ReflectBrightnessScale;  // Offset:   88 Size:     4
//   float VAR_Fresnel_min;             // Offset:   92 Size:     4
//   float VAR_Fresnel_max;             // Offset:   96 Size:     4
//   float CAPCOM_MATERIAL_RESERVE0;    // Offset:  100 Size:     4 [unused]
//   float CAPCOM_MATERIAL_RESERVE1;    // Offset:  104 Size:     4 [unused]
//   float CAPCOM_MATERIAL_RESERVE2;    // Offset:  108 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// BilinearWrap                      sampler      NA          NA    0        1
// ReadonlyDepth                     texture   float          2d    0        1
// DynamicCubeMap                    texture  float4        cube    1        1
// DynamicTransparentHDR             texture  float4          2d    2        1
// ColorMap                          texture  float4          2d    3        1
// NormalMap                         texture  float4          2d    4        1
// AlphaMap                          texture  float4          2d    5        1
// SceneInfo                         cbuffer      NA          NA    0        1
// EnvironmentInfo                   cbuffer      NA          NA    1        1
// UserMaterial                      cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// INTERPOLATOR             0   xyzw        1     NONE   float   xyzw
// INTERPOLATOR             1   xyzw        2     NONE   float   xyzw
// INTERPOLATOR             2   xyzw        3     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
// SV_TARGET                1   x           1   TARGET   float   x
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[24], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[7], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texturecube (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_texture2d (float,float,float,float) t5
dcl_input_ps_siv linear noperspective v0.xyzw, position
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_output o0.xyzw
dcl_output o1.x
dcl_temps 8
dp3 r0.x, v1.xyzx, v1.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v1.xyzx
dp3 r0.w, v2.yzwy, v2.yzwy
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, v2.yzwy
mul r2.xyz, r0.zxyz, r1.yzxy
mad r2.xyz, r0.yzxy, r1.zxyz, -r2.xyzx
lt r0.w, v3.x, l(0.000000)
movc r2.xyz, r0.wwww, -r2.xyzx, r2.xyzx
mov r3.x, -cb0[7].w
mov r3.y, -cb0[8].w
mov r3.z, -cb0[9].w
add r3.xyz, r3.xyzx, v3.yzwy
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, r3.xyzx
lt r4.xy, l(0.000000, 0.000000, 0.000000, 0.000000), |cb2[2].zwzz|
if_nz r4.x
  div r0.w, l(1000.000000), cb2[2].z
  utof r1.w, cb1[0].x
  div r0.w, r1.w, r0.w
  frc r5.x, r0.w
else
  mov r5.x, l(0)
endif
if_nz r4.y
  div r0.w, l(1000.000000), cb2[2].w
  utof r1.w, cb1[0].x
  div r0.w, r1.w, r0.w
  frc r5.y, r0.w
else
  mov r5.y, l(0)
endif
mov r4.x, v1.w
mov r4.y, v2.x
add r4.zw, r5.xxxy, cb2[2].xxxy
mad r4.zw, r4.xxxy, cb2[3].xxxy, r4.zzzw
lt r5.xy, l(0.000000, 0.000000, 0.000000, 0.000000), |cb2[4].xyxx|
if_nz r5.x
  div r0.w, l(1000.000000), cb2[4].x
  utof r1.w, cb1[0].x
  div r0.w, r1.w, r0.w
  frc r6.x, r0.w
else
  mov r6.x, l(0)
endif
if_nz r5.y
  div r0.w, l(1000.000000), cb2[4].y
  utof r1.w, cb1[0].x
  div r0.w, r1.w, r0.w
  frc r6.y, r0.w
else
  mov r6.y, l(0)
endif
add r5.xy, r6.xyxx, cb2[3].zwzz
mad r4.xy, r4.xyxx, cb2[4].zwzz, r5.xyxx
sample_indexable(texture2d)(float,float,float,float) r5.xyz, r4.zwzz, t4.xyzw, s0
sample_indexable(texture2d)(float,float,float,float) r6.xyzw, r4.zwzz, t3.xyzw, s0
mad r5.xyz, r5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r2.xyzx
mul r2.xyz, r2.xyzx, r5.yyyy
mad r1.xyz, r5.xxxx, r1.xyzx, r2.xyzx
mad r0.xyz, r5.zzzz, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
sample_indexable(texture2d)(float,float,float,float) r0.w, r4.xyxx, t5.yzwx, s0
mul r1.x, r6.w, cb2[0].w
mul r0.w, r0.w, r1.x
lt r1.x, l(0.000000), cb2[1].z
if_nz r1.x
  ftoi r1.xy, v0.xyxx
  mov r1.zw, l(0,0,0,0)
  ld_indexable(texture2d)(float,float,float,float) r1.x, r1.xyzw, t0.xyzw
  mad r1.x, -r1.x, cb0[22].y, cb0[22].x
  mad r1.y, -v0.z, cb0[22].y, cb0[22].x
  div r1.xy, cb0[22].zzzz, r1.xyxx
  add r1.x, -r1.y, r1.x
  div r1.y, l(1.000000, 1.000000, 1.000000, 1.000000), cb2[1].z
  mul_sat r1.x, r1.y, r1.x
  add r1.y, -r1.x, l(1.000000)
  min r1.y, r1.y, r1.x
  mad r1.y, r1.y, l(2.000000), -r1.x
  mad r1.x, cb2[1].w, r1.y, r1.x
  max r1.x, r1.x, l(0.000001)
  log r1.x, r1.x
  mul r1.x, r1.x, l(2.200000)
  exp r1.xyz, r1.xxxx
else
  mov r1.xyz, l(1.000000,1.000000,1.000000,0)
endif
mul r1.w, cb0[23].x, l(0.000100)
div r1.w, r1.w, v0.w
add r2.x, cb2[1].x, l(-1.000000)
mul r1.w, r1.w, r2.x
mul r1.w, r0.w, r1.w
mad r2.xyz, cb2[0].xyzx, r6.xyzx, l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r2.xyz, r0.wwww, r2.xyzx
mul r4.xw, r1.xxxy, r1.wwww
dp3 r5.x, r3.xyzx, cb0[4].xyzx
dp3 r5.y, r3.xyzx, cb0[5].xyzx
dp3 r5.z, r3.xyzx, cb0[6].xyzx
dp3 r6.x, r0.xyzx, cb0[4].xyzx
dp3 r6.y, r0.xyzx, cb0[5].xyzx
dp3 r6.z, r0.xyzx, cb0[6].xyzx
dp3 r1.w, r5.xyzx, r5.xyzx
rsq r1.w, r1.w
mul r7.xyz, r1.wwww, r5.xyzx
dp3 r2.w, r6.xyzx, r6.xyzx
rsq r2.w, r2.w
mul r6.xyz, r2.wwww, r6.xyzx
mad r5.xy, r5.xyxx, r1.wwww, -r6.xyxx
dp3 r4.y, r6.xyzx, r7.xyzx
mov r4.z, l(1.000000)
mul r5.xy, r5.xyxx, r4.zyzz
mul r4.zw, r4.yyyw, r5.xxxy
mov r4.y, l(-1.000000)
mul r4.xy, r4.xyxx, r4.zwzz
mad r4.xy, cb0[23].zwzz, v0.xyxx, r4.xyxx
sample_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyxx, t2.xyzw, s0
mad r2.xyz, r1.xyzx, r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mul r2.xyz, r4.xyzx, r2.xyzx
mul r1.w, r0.w, cb2[1].y
mul r1.w, r1.x, r1.w
lt r2.w, l(0.000000), cb2[5].x
if_nz r2.w
  lt r2.w, l(0.000000), cb2[5].y
  if_nz r2.w
    dp3 r2.w, r3.xyzx, r0.xyzx
    add r2.w, r2.w, r2.w
    mad r4.xyz, -r2.wwww, r0.zxyz, r3.zxyz
    min r2.w, |r4.y|, |r4.x|
    max r3.w, |r4.y|, |r4.x|
    div r3.w, l(1.000000, 1.000000, 1.000000, 1.000000), r3.w
    mul r2.w, r2.w, r3.w
    mul r3.w, r2.w, r2.w
    mad r4.w, r3.w, l(0.0208350997), l(-0.085133)
    mad r4.w, r3.w, r4.w, l(0.180141)
    mad r4.w, r3.w, r4.w, l(-0.330299497)
    mad r3.w, r3.w, r4.w, l(0.999866)
    mul r4.w, r2.w, r3.w
    lt r5.x, |r4.y|, |r4.x|
    mad r4.w, r4.w, l(-2.000000), l(1.57079637)
    and r4.w, r5.x, r4.w
    mad r2.w, r2.w, r3.w, r4.w
    lt r5.xy, r4.yzyy, -r4.yzyy
    and r3.w, r5.x, l(0xc0490fdb)
    add r2.w, r2.w, r3.w
    min r3.w, r4.y, r4.x
    max r4.x, r4.y, r4.x
    lt r3.w, r3.w, -r3.w
    ge r4.x, r4.x, -r4.x
    and r3.w, r3.w, r4.x
    movc r2.w, r3.w, -r2.w, r2.w
    mul r2.w, r2.w, l(0.159154937)
    frc r4.x, r2.w
    add r2.w, -|r4.z|, l(1.000000)
    sqrt r2.w, r2.w
    mad r3.w, |r4.z|, l(-0.0187292993), l(0.074261)
    mad r3.w, r3.w, |r4.z|, l(-0.212114394)
    mad r3.w, r3.w, |r4.z|, l(1.57072878)
    mul r4.z, r2.w, r3.w
    mad r4.z, r4.z, l(-2.000000), l(3.14159274)
    and r4.z, r5.y, r4.z
    mad r2.w, r3.w, r2.w, r4.z
    mul r4.y, r2.w, l(0.318309873)
    sample_indexable(texture2d)(float,float,float,float) r4.xyz, r4.xyxx, t2.xyzw, s0
    mul r4.xyz, r4.xyzx, cb2[5].zzzz
  else
    dp3 r2.w, r3.xyzx, r0.xyzx
    add r2.w, r2.w, r2.w
    mad r5.xyz, -r2.wwww, r0.xyzx, r3.xyzx
    sample_l_indexable(texturecube)(float,float,float,float) r5.xyz, r5.xyzx, t1.xyzw, s0, l(0.000000)
    mul r5.xyz, r5.xyzx, cb2[5].zzzz
    mul r4.xyz, r0.wwww, r5.xyzx
  endif
  dp3 r0.x, r0.xyzx, -r3.xyzx
  add r0.y, cb2[5].w, -cb2[6].x
  add r0.x, r0.x, -cb2[6].x
  div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
  mul_sat r0.x, r0.y, r0.x
  mad r0.y, r0.x, l(-2.000000), l(3.000000)
  mul r0.x, r0.x, r0.x
  mul r0.x, r0.x, r0.y
  mul r0.xyz, r0.xxxx, r4.xyzx
  mad r2.xyz, r0.xyzx, r1.xyzx, r2.xyzx
endif
mul o0.xyz, r1.wwww, r2.xyzx
mov o0.w, r1.w
mov o1.x, r1.w
ret
// Approximately 194 instruction slots used

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