//Flashlight PS, volumetric.
// ---- Created with 3Dmigoto v1.3.16 on Mon Dec 16 23:49:22 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 cbLightShaft : register(b1)
//{
//  row_major float3x4 InvModelMat : packoffset(c0);
//  row_major float3x4 InvViewModelMat : packoffset(c3);
//  row_major float3x4 InvModelLightMat : packoffset(c6);
//  row_major float3x4 InvLightMat : packoffset(c9);
//  float4 lightPosition : packoffset(c12);
//  float3 lightDirection : packoffset(c13);
//  float lightFalloff : packoffset(c13.w);
//  float4 lightAttenuation : packoffset(c14);
//  float3 lightColor : packoffset(c15);
//  float lightBoundingRadius : packoffset(c15.w);
//  float lightTolerance : packoffset(c16);
//  float fExtinctionCoef : packoffset(c16.y);
//  float fRayleighCoef : packoffset(c16.z);
//  float fMieCoef : packoffset(c16.w);
//  float2 fFovTan : packoffset(c17);
//  float2 fInverseReducedScreenSize : packoffset(c17.z);
//  float fZAttnStart : packoffset(c18);
//  float fZAttnEnd : packoffset(c18.y);
//  float fInvZRange : packoffset(c18.z);
//  float fZOriginDist : packoffset(c18.w);
//  uint indexes : packoffset(c19);
//  uint flags : packoffset(c19.y);
//  float transparency : packoffset(c19.z);
//  float aspect : packoffset(c19.w);
//  uint tilingNum : packoffset(c20);
//  uint lightIndex : packoffset(c20.y);
//}
//
//SamplerState PointClamp_s : register(s0);
//SamplerState BilinearWrap_s : register(s1);
//Texture2D<float> ReadonlyDepth : register(t0);
//Texture2D<float> tMaskMap : register(t1);
//
//
//// 3Dmigoto declarations
//#define cmp -
//Texture1D<float4> IniParams : register(t120);
//Texture2D<float4> StereoParams : register(t125);
//
//
//void main(
//  float4 v0 : SV_Position0,
//  float2 v1 : TEXCOORD0,
//  out float4 o0 : SV_TARGET0)
//{
//  float4 r0,r1,r2,r3,r4;
//  uint4 bitmask, uiDest;
//  float4 fDest;
//
//  r0.xy = (uint2)v0.xy;
//  r0.xy = (uint2)r0.xy;
//  r0.xy = screenInverseSize.xy * r0.xy;
//  r1.xy = r0.xy * float2(2,2) + float2(-1,-1);
//  r1.z = -aspect * r1.y;
//  r0.z = fFovTan.x + fFovTan.y;
//  r0.z = fFovTan.x / r0.z;
//  r0.z = cmp(r0.x < r0.z);
//  if (r0.z != 0) {
//    r1.w = rcp(fFovTan.x);
//    r1.w = -r1.w;
//  } else {
//    r1.w = rcp(fFovTan.y);
//    r1.w = -r1.w;
//  }
//  r2.x = dot(InvViewModelMat._m00_m01_m02, r1.xzw);
//  r2.y = dot(InvViewModelMat._m10_m11_m12, r1.xzw);
//  r2.z = dot(InvViewModelMat._m20_m21_m22, r1.xzw);
//  r0.z = dot(r2.xyz, r2.xyz);
//  r0.z = rsqrt(r0.z);
//  r1.xyz = r2.xyz * r0.zzz;
//  r0.z = -lightAttenuation.w / lightAttenuation.z;
//  r0.w = r0.z * r0.z + -1;
//  r0.w = sqrt(r0.w);
//  r0.z = cmp(0 < r0.z);
//  r0.z = r0.z ? 1 : -1;
//  r0.z = r0.w * r0.z;
//  r0.w = ReadonlyDepth.SampleLevel(PointClamp_s, r0.xy, 0).x;
//  r0.xy = r0.xy * float2(2,-2) + float2(-1,1);
//  r2.xy = projInvElements[0].xy * r0.xy + projInvElements[1].xy;
//  r2.zw = projInvElements[0].zw * r0.ww + projInvElements[1].zw;
//  r2.xyz = r2.xyz / r2.www;
//  r0.x = dot(r2.xyz, r2.xyz);
//  r0.x = sqrt(r0.x);
//  r0.y = 1 / cameraFarPlane;
//  o0.w = saturate(r0.x * r0.y);
//  r2.w = 1;
//  r3.x = dot(InvViewModelMat._m00_m01_m02_m03, r2.xyzw);
//  r3.y = dot(InvViewModelMat._m10_m11_m12_m13, r2.xyzw);
//  r3.z = dot(InvViewModelMat._m20_m21_m22_m23, r2.xyzw);
//  r2.x = InvViewModelMat._m03;
//  r2.y = InvViewModelMat._m13;
//  r2.z = InvViewModelMat._m23;
//  r0.xyw = r3.xyz + -r2.xyz;
//  r0.x = dot(r0.xyw, r0.xyw);
//  r0.x = sqrt(r0.x);
//  r0.y = r0.z * r0.z;
//  r0.z = dot(r1.xz, r1.xz);
//  r0.w = r1.y * r1.y;
//  r0.z = -r0.w * r0.y + r0.z;
//  r0.w = InvViewModelMat._m23 * r1.z;
//  r0.w = InvViewModelMat._m03 * r1.x + r0.w;
//  r1.w = InvViewModelMat._m13 * r1.y;
//  r0.w = -r1.w * r0.y + r0.w;
//  r1.w = r0.w + r0.w;
//  r2.w = InvViewModelMat._m23 * InvViewModelMat._m23;
//  r2.w = InvViewModelMat._m03 * InvViewModelMat._m03 + r2.w;
//  r3.x = InvViewModelMat._m13 * InvViewModelMat._m13;
//  r0.y = -r3.x * r0.y + r2.w;
//  r2.w = r0.y * r0.z;
//  r2.w = 4 * r2.w;
//  r2.w = r1.w * r1.w + -r2.w;
//  r3.x = cmp(r2.w < 0);
//  if (r3.x != 0) {
//    r3.yz = float2(0,0);
//  }
//  if (r3.x == 0) {
//    r3.x = cmp(0 < r0.w);
//    r0.w = cmp(r0.w < 0);
//    r0.w = (int)-r3.x + (int)r0.w;
//    r0.w = (int)r0.w;
//    r2.w = sqrt(r2.w);
//    r0.w = r0.w * r2.w + r1.w;
//    r0.w = -0.5 * r0.w;
//    r3.z = r0.w / r0.z;
//    r3.y = r0.y / r0.w;
//    r0.y = cmp(r3.y < r3.z);
//    if (r0.y != 0) {
//      r3.yz = r3.zy;
//    }
//  }
//  r0.y = r1.y * r3.z + InvViewModelMat._m13;
//  r0.zw = cmp(r3.zy == float2(0,0));
//  r0.z = r0.w ? r0.z : 0;
//  if (r0.z != 0) {
//    r0.z = r3.z;
//    r0.w = -1;
//  } else {
//    r1.w = r1.y * r3.y + InvViewModelMat._m13;
//    r2.w = cmp(0 < r0.y);
//    r3.x = cmp(r1.w < -lightBoundingRadius);
//    r3.w = r2.w ? r3.x : 0;
//    r4.x = cmp(r0.y < -lightBoundingRadius);
//    r4.y = cmp(0 < r1.w);
//    r3.x = (int)r3.x | (int)r4.y;
//    r3.x = r3.x ? r4.x : 0;
//    r3.x = (int)r3.x | (int)r3.w;
//    if (r3.x != 0) {
//      r3.y = 0;
//      r0.zw = float2(0,-1);
//    } else {
//      r3.x = r2.w ? r4.y : 0;
//      if (r3.x != 0) {
//        r3.y = -1;
//        r0.zw = float2(0,-1);
//      } else {
//        r1.w = cmp(r1.w < 0);
//        r1.w = r1.w ? r2.w : 0;
//        if (r1.w != 0) {
//          r0.z = r3.y;
//          r3.y = 10000;
//          r0.w = -1;
//        } else {
//          r1.w = cmp(r0.y < 0);
//          r1.w = r4.y ? r1.w : 0;
//          if (r1.w != 0) {
//            r1.w = -lightBoundingRadius + -InvViewModelMat._m13;
//            r0.z = r1.w / r1.y;
//            r3.y = r3.z;
//            r0.w = -1;
//          } else {
//            r0.w = cmp(r3.z < 0);
//            if (r0.w != 0) {
//              r1.w = -lightBoundingRadius + -InvViewModelMat._m13;
//              r0.z = r1.w / r1.y;
//            } else {
//              r0.z = r3.z;
//            }
//          }
//        }
//      }
//    }
//  }
//  if (r0.w == 0) {
//    r0.y = cmp(r0.y < -lightBoundingRadius);
//    if (r0.y != 0) {
//      r0.y = -lightBoundingRadius + -InvViewModelMat._m13;
//      r0.z = r0.y / r1.y;
//    }
//  }
//  r0.y = cmp(r0.z < r3.y);
//  r0.w = r0.z + -r0.x;
//  r0.w = cmp(-1.1920929e-007 >= r0.w);
//  r0.y = r0.w ? r0.y : 0;
//  if (r0.y != 0) {
//    r2.xyz = r1.xyz * r0.zzz + r2.xyz;
//    r0.x = min(r3.y, r0.x);
//    r0.x = r0.x + -r0.z;
//    r0.x = max(0, r0.x);
//    r2.w = 1;
//    r3.x = dot(InvLightMat._m00_m01_m02_m03, r2.xyzw);
//    r3.y = dot(InvLightMat._m10_m11_m12_m13, r2.xyzw);
//    r3.z = dot(InvLightMat._m20_m21_m22_m23, r2.xyzw);
//    r0.yzw = lightPosition.xyz + -r3.xyz;
//    r1.x = dot(r0.yzw, r0.yzw);
//    r1.z = rsqrt(r1.x);
//    r0.yzw = r1.zzz * r0.yzw;
//    r1.x = r1.x * r1.z;
//    r1.x = r1.x * lightAttenuation.x + 1;
//    r1.x = r1.x * r1.x;
//    r1.x = rcp(r1.x);
//    r1.x = saturate(-lightTolerance + r1.x);
//    r1.z = 1 + -lightTolerance;
//    r1.z = (int)-r1.z + 0x7eef370b;
//    r1.x = r1.x * r1.z;
//    r0.y = dot(-lightDirection.xyz, r0.yzw);
//    r0.y = saturate(r0.y * lightAttenuation.w + lightAttenuation.z);
//    r0.z = 1 / lightFalloff;
//    r0.y = saturate(r0.y * r0.z);
//    r0.z = r0.y * -2 + 3;
//    r0.y = r0.y * r0.y;
//    r0.y = r0.z * r0.y;
//    r0.z = fRayleighCoef + fMieCoef;
//    r0.x = -r0.x * r0.z;
//    r0.x = 1.44269502 * r0.x;
//    r0.x = exp2(r0.x);
//    r0.x = 1 + -r0.x;
//    r1.zw = float2(0.0596831031,0.000198943671) * fRayleighCoef;
//    r0.w = r1.y * r1.y + 1;
//    r1.y = -r1.y * 1.89999998 + 1.90250003;
//    r1.y = log2(r1.y);
//    r1.y = 1.5 * r1.y;
//    r1.y = exp2(r1.y);
//    r1.y = r1.w / r1.y;
//    r0.w = r1.z * r0.w + r1.y;
//    r0.z = r0.w / r0.z;
//    r0.x = r0.z * r0.x;
//    r1.xyz = lightColor.xyz * r1.xxx;
//    r0.yzw = lightColor.xyz * r0.yyy;
//    r0.yzw = float3(0.0795774683,0.0795774683,0.0795774683) * r0.yzw;
//    r0.yzw = r0.yzw / lightBoundingRadius;
//    r0.yzw = r0.yzw / lightBoundingRadius;
//    r0.yzw = r0.yzw * r0.xxx;
//    r0.xyz = r1.xyz * r0.xxx + r0.yzw;
//  } else {
//    r0.xyz = float3(0,0,0);
//  }
//  r1.xy = v1.xy / v0.ww;
//  r0.w = tMaskMap.Sample(BilinearWrap_s, r1.xy).x;
//  r0.w = transparency * r0.w;
//  o0.xyz = r0.xyz * r0.www;
//  return;
//}
//
///*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.16 on Mon Dec 16 23:49:22 2019
//
//
// Buffer Definitions:
//
// cbuffer SceneInfo
// {
//
//   row_major float4x4 viewProjMat;    // Offset:    0 Size:    64 [unused]
//   row_major float3x4 transposeViewMat;// Offset:   64 Size:    48 [unused]
//   row_major float3x4 transposeViewInvMat;// Offset:  112 Size:    48 [unused]
//   float4 projElement[2];             // Offset:  160 Size:    32 [unused]
//   float4 projInvElements[2];         // Offset:  192 Size:    32
//   row_major float4x4 viewProjInvMat; // Offset:  224 Size:    64 [unused]
//   row_major float4x4 prevViewProjMat;// Offset:  288 Size:    64 [unused]
//   float3 ZToLinear;                  // Offset:  352 Size:    12 [unused]
//   float subdivisionLevel;            // Offset:  364 Size:     4 [unused]
//   float2 screenSize;                 // Offset:  368 Size:     8 [unused]
//   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
//   float4 viewFrustum[6];             // Offset:  400 Size:    96 [unused]
//   float4 clipplane;                  // Offset:  496 Size:    16 [unused]
//
// }
//
// cbuffer cbLightShaft
// {
//
//   row_major float3x4 InvModelMat;    // Offset:    0 Size:    48 [unused]
//   row_major float3x4 InvViewModelMat;// Offset:   48 Size:    48
//   row_major float3x4 InvModelLightMat;// Offset:   96 Size:    48 [unused]
//   row_major float3x4 InvLightMat;    // Offset:  144 Size:    48
//   float4 lightPosition;              // Offset:  192 Size:    16
//   float3 lightDirection;             // Offset:  208 Size:    12
//   float lightFalloff;                // Offset:  220 Size:     4
//   float4 lightAttenuation;           // Offset:  224 Size:    16
//   float3 lightColor;                 // Offset:  240 Size:    12
//   float lightBoundingRadius;         // Offset:  252 Size:     4
//   float lightTolerance;              // Offset:  256 Size:     4
//   float fExtinctionCoef;             // Offset:  260 Size:     4 [unused]
//   float fRayleighCoef;               // Offset:  264 Size:     4
//   float fMieCoef;                    // Offset:  268 Size:     4
//   float2 fFovTan;                    // Offset:  272 Size:     8
//   float2 fInverseReducedScreenSize;  // Offset:  280 Size:     8 [unused]
//   float fZAttnStart;                 // Offset:  288 Size:     4 [unused]
//   float fZAttnEnd;                   // Offset:  292 Size:     4 [unused]
//   float fInvZRange;                  // Offset:  296 Size:     4 [unused]
//   float fZOriginDist;                // Offset:  300 Size:     4 [unused]
//   uint indexes;                      // Offset:  304 Size:     4 [unused]
//   uint flags;                        // Offset:  308 Size:     4 [unused]
//   float transparency;                // Offset:  312 Size:     4
//   float aspect;                      // Offset:  316 Size:     4
//   uint tilingNum;                    // Offset:  320 Size:     4 [unused]
//   uint lightIndex;                   // Offset:  324 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PointClamp                        sampler      NA          NA    0        1
// BilinearWrap                      sampler      NA          NA    1        1
// ReadonlyDepth                     texture   float          2d    0        1
// tMaskMap                          texture   float          2d    1        1
// SceneInfo                         cbuffer      NA          NA    0        1
// cbLightShaft                      cbuffer      NA          NA    1        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy w
// TEXCOORD                 0   xy          1     NONE   float   xy
//
//
// 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 cb0[25], immediateIndexed
dcl_constantbuffer cb1[20], immediateIndexed
dcl_constantbuffer cb13[24], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 38
dcl_resource_texture2d (float,float,float,float) t125
dcl_resource_texture1d (float,float,float,float) t120
ld_indexable(texture2d)(float,float,float,float) r25.xyzw, l(0, 0, 0, 0), t125.xyzw
ld_indexable(texture1d)(float,float,float,float) r28.xyzw, l(0, 0, 0, 0), t120.xyzw
ftou r0.xy, v0.xyxx
utof r0.xy, r0.xyxx
mul r0.xy, r0.xyxx, cb0[23].zwzz

ld_indexable(texture2d)(float,float,float,float) r13.xyzw, l(0, 0, 0, 0), t125.xyzw

//Early copy of depth.
sample_l_indexable(texture2d)(float,float,float,float) r0.w, r0.xyxx, t0.yzwx, s0, l(0.000000)

mov r15.xy, r0.xy
mul r14.x, r13.y, r0.w
mul r14.x, r14.x, l(-100.0)
add r14.x, r14.x, l(1.0)
mul r14.x, r14.x, l(0.5)
mad r15.x, -r13.x, r14.x, r15.x

mad r1.xy, r15.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r1.z, r1.y, -cb1[19].w
add r0.z, cb1[17].y, cb1[17].x
div r0.z, cb1[17].x, r0.z
lt r0.z, r0.x, r0.z
if_nz r0.z
  rcp r1.w, cb1[17].x
  mov r1.w, -r1.w
else
  rcp r1.w, cb1[17].y
  mov r1.w, -r1.w
endif
dp3 r2.x, cb1[3].xyzx, r1.xzwx
dp3 r2.y, cb1[4].xyzx, r1.xzwx
dp3 r2.z, cb1[5].xyzx, r1.xzwx



dp3 r0.z, r2.xyzx, r2.xyzx
rsq r0.z, r0.z

//Fix here.
mul r26.xyz, r13.yyyy, cb0[14].zyxx
mul r26.xyz, r26.xyzx, l(0.5)
mul r26.xyz, r26.xyzx, r0.zzzz
//mad r2.xyz, r13.xxxx, r26.xyzx, r2.xyzx



mul r1.xyz, r0.zzzz, r2.xyzx

mov r17.xyzw, r1.xyzw
mul r26.x, r25.y, l(1.0)
mul r26.x, r26.x, l(-0.25)
//mad r17.x, r25.x, r26.x, r17.x

div r0.z, -cb1[14].w, cb1[14].z
mad r0.w, r0.z, r0.z, l(-1.000000)
sqrt r0.w, r0.w
lt r0.z, l(0.000000), r0.z
movc r0.z, r0.z, l(1.000000), l(-1.000000)
mul r0.z, r0.z, r0.w
sample_l_indexable(texture2d)(float,float,float,float) r0.w, r0.xyxx, t0.yzwx, s0, l(0.000000)
//Fix here.
mad r0.xy, r15.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
mad r2.xy, cb0[12].xyxx, r0.xyxx, cb0[13].xyxx
mad r2.zw, cb0[12].zzzw, r0.wwww, cb0[13].zzzw
div r2.xyz, r2.xyzx, r2.wwww
dp3 r0.x, r2.xyzx, r2.xyzx
sqrt r0.x, r0.x
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[24].w
mul_sat o0.w, r0.y, r0.x
mov r2.w, l(1.000000)
dp4 r3.x, cb1[3].xyzw, r2.xyzw
dp4 r3.y, cb1[4].xyzw, r2.xyzw
dp4 r3.z, cb1[5].xyzw, r2.xyzw
mov r2.x, cb1[3].w
mov r2.y, cb1[4].w
mov r2.z, cb1[5].w



add r0.xyw, -r2.xyxz, r3.xyxz
dp3 r0.x, r0.xywx, r0.xywx
sqrt r0.x, r0.x
mul r0.y, r0.z, r0.z
dp2 r0.z, r17.xzxx, r17.xzxx
mul r0.w, r17.y, r17.y
mad r0.z, -r0.w, r0.y, r0.z
mul r0.w, r17.z, cb1[5].w
mad r0.w, cb1[3].w, r17.x, r0.w
mul r1.w, r17.y, cb1[4].w
mad r0.w, -r1.w, r0.y, r0.w
add r1.w, r0.w, r0.w
mul r2.w, cb1[5].w, cb1[5].w
mad r2.w, cb1[3].w, cb1[3].w, r2.w
mul r3.x, cb1[4].w, cb1[4].w
mad r0.y, -r3.x, r0.y, r2.w
mul r2.w, r0.z, r0.y
mul r2.w, r2.w, l(4.000000)
mad r2.w, r1.w, r1.w, -r2.w
lt r3.x, r2.w, l(0.000000)
if_nz r3.x
  mov r3.yz, l(0,0,0,0)
endif
if_z r3.x
  lt r3.x, l(0.000000), r0.w
  lt r0.w, r0.w, l(0.000000)
  iadd r0.w, -r3.x, r0.w
  itof r0.w, r0.w
  sqrt r2.w, r2.w
  mad r0.w, r0.w, r2.w, r1.w
  mul r0.w, r0.w, l(-0.500000)
  div r3.z, r0.w, r0.z
  div r3.y, r0.y, r0.w
  lt r0.y, r3.y, r3.z
  if_nz r0.y
    mov r3.yz, r3.zzyz
  endif
endif
mad r0.y, r1.y, r3.z, cb1[4].w
eq r0.zw, r3.zzzy, l(0.000000, 0.000000, 0.000000, 0.000000)
and r0.z, r0.w, r0.z
if_nz r0.z
  mov r0.z, r3.z
  mov r0.w, l(-1)
else
  mad r1.w, r1.y, r3.y, cb1[4].w
  lt r2.w, l(0.000000), r0.y
  lt r3.x, r1.w, -cb1[15].w
  and r3.w, r2.w, r3.x
  lt r4.x, r0.y, -cb1[15].w
  lt r4.y, l(0.000000), r1.w
  or r3.x, r3.x, r4.y
  and r3.x, r3.x, r4.x
  or r3.x, r3.x, r3.w
  if_nz r3.x
    mov r3.y, l(0)
    mov r0.zw, l(0,0,0,-1)
  else
    and r3.x, r2.w, r4.y
    if_nz r3.x
      mov r3.y, l(-1.000000)
      mov r0.zw, l(0,0,0,-1)
    else
      lt r1.w, r1.w, l(0.000000)
      and r1.w, r1.w, r2.w
      if_nz r1.w
        mov r0.z, r3.y
        mov r3.y, l(10000.000000)
        mov r0.w, l(-1)
      else
        lt r1.w, r0.y, l(0.000000)
        and r1.w, r4.y, r1.w
        if_nz r1.w
          add r1.w, -cb1[4].w, -cb1[15].w
          div r0.z, r1.w, r1.y
          mov r3.y, r3.z
          mov r0.w, l(-1)
        else
          lt r0.w, r3.z, l(0.000000)
          if_nz r0.w
            add r1.w, -cb1[4].w, -cb1[15].w
            div r0.z, r1.w, r1.y
          else
            mov r0.z, r3.z
          endif
        endif
      endif
    endif
  endif
endif
if_z r0.w
  lt r0.y, r0.y, -cb1[15].w
  if_nz r0.y
    add r0.y, -cb1[4].w, -cb1[15].w
    div r0.z, r0.y, r1.y
  endif
endif
lt r0.y, r0.z, r3.y
add r0.w, -r0.x, r0.z
ge r0.w, l(-1.192092896E-007), r0.w
and r0.y, r0.w, r0.y
if_nz r0.y
  mad r2.xyz, r1.xyzx, r0.zzzz, r2.xyzx
  min r0.x, r0.x, r3.y
  add r0.x, -r0.z, r0.x
  max r0.x, r0.x, l(0.000000)
  mov r2.w, l(1.000000)
  dp4 r3.x, cb1[9].xyzw, r2.xyzw
  dp4 r3.y, cb1[10].xyzw, r2.xyzw
  dp4 r3.z, cb1[11].xyzw, r2.xyzw
  
  //Fix here.
  mul r26.xyzx, r13.yyyy, cb0[14].xyzx
  mul r26.xyzx, r26.xyzx, l(1.0)
  //mad r3.xyzx, r13.xxxx, r26.xyzx, r3.xyzx
  
  add r0.yzw, -r3.xxyz, cb1[12].xxyz
  dp3 r1.x, r0.yzwy, r0.yzwy
  rsq r1.z, r1.x
  mul r0.yzw, r0.yyzw, r1.zzzz
  mul r1.x, r1.z, r1.x
  mad r1.x, r1.x, cb1[14].x, l(1.000000)
  mul r1.x, r1.x, r1.x
  rcp r1.x, r1.x
  add_sat r1.x, r1.x, -cb1[16].x
  add r1.z, -cb1[16].x, l(1.000000)
  iadd r1.z, -r1.z, l(0x7eef370b)
  mul r1.x, r1.z, r1.x
  dp3 r0.y, -cb1[13].xyzx, r0.yzwy
  mad_sat r0.y, r0.y, cb1[14].w, cb1[14].z
  div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), cb1[13].w
  mul_sat r0.y, r0.z, r0.y
  mad r0.z, r0.y, l(-2.000000), l(3.000000)
  mul r0.y, r0.y, r0.y
  mul r0.y, r0.y, r0.z
  add r0.z, cb1[16].w, cb1[16].z
  mul r0.x, r0.z, -r0.x
  mul r0.x, r0.x, l(1.442695)
  exp r0.x, r0.x
  add r0.x, -r0.x, l(1.000000)
  mul r1.zw, cb1[16].zzzw, l(0.000000, 0.000000, 0.0596831031, 0.000198943671)
  mad r0.w, r1.y, r1.y, l(1.000000)
  mad r1.y, -r1.y, l(1.900000), l(1.902500)
  log r1.y, r1.y
  mul r1.y, r1.y, l(1.500000)
  exp r1.y, r1.y
  div r1.y, r1.w, r1.y
  mad r0.w, r1.z, r0.w, r1.y
  div r0.z, r0.w, r0.z
  mul r0.x, r0.x, r0.z
  mul r1.xyz, r1.xxxx, cb1[15].xyzx
  mul r0.yzw, r0.yyyy, cb1[15].xxyz
  mul r0.yzw, r0.yyzw, l(0.000000, 0.0795774683, 0.0795774683, 0.0795774683)
  div r0.yzw, r0.yyzw, cb1[15].wwww
  div r0.yzw, r0.yyzw, cb1[15].wwww
  mul r0.yzw, r0.xxxx, r0.yyzw
  mad r0.xyz, r1.xyzx, r0.xxxx, r0.yzwy
else
  mov r0.xyz, l(0,0,0,0)
endif

//mov r21.xy, v1.xyxx
//mad r21.x, r13.x, v0.w, r21.x

div r1.xy, v1.xyxx, v0.wwww
sample_indexable(texture2d)(float,float,float,float) r0.w, r1.xyxx, t1.yzwx, s1
mul r0.w, r0.w, cb1[19].z
mul o0.xyz, r0.wwww, r0.xyzx
ret
// Approximately 202 instruction slots used
