// MANUALLY DUMPED [ShaderRegex_LightingPS1] P5S water haloing PS 3.
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Thu Mar 17 20:52:59 2022
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 litDir[4];                  // Index:    0 1 2 3          Components:    16
//   float4 litCol[4];                  // Index:    4 5 6 7          Components:    16
//   float4 litOcc;                     // Index:    8.xyzw           Components:     4
//   float4 ambLit;                     // Index:    9.xyzw           Components:     4
//   int nDirLit;                       // Index:   10.x              Components:     1
//   float4 vEye;                       // Index:   11.xyzw           Components:     4
//   float2 vOccRate;                   // Index:   12.xy             Components:     2
//      = 0x3f800000 0x3f800000
//   int rampIndex;                     // Index:   12.z              Components:     1
//      = 0x00000000
//   float4 rampPkPrms[3];              // Index:   13 14 15          Components:    12
//   float3 vCameraPos;                 // Index:   16.xyz            Components:     3
//   float3 vCameraDir;                 // Index:   17.xyz            Components:     3
//   float2 vD2Z;                       // Index:   18.xy             Components:     2
//   float4 mRrW2T[3];                  // Index:   19 20 21          Components:    12
//   row_major float4x4 mV2W;           // Index:   22 23 24 25       Components:    16
//   row_major float4x4 mP2W;           // Index:   26 27 28 29       Components:    16
//   float fAmbMapsDORate;              // Index:   30.x              Components:     1
//      = 0x00000000
//   float4 vAmbDifScl;                 // Index:   31.xyzw           Components:     4
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000
//   int rampTexHeight;                 // Index:   32.x              Components:     1
//   float4 vAmbSpcScl;                 // Index:   33.xyzw           Components:     4
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000
//   float4 vTsbViewPort;               // Index:   34.xyzw           Components:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// __smpsDepthMap                    sampler      NA          NA    0        1
// __smpsGxAmbLut                    sampler      NA          NA    1        1
// __smpsAmbSpc                      sampler      NA          NA    2        1
// __smpsTrnsSpc                     sampler      NA          NA    3        1
// __smpsRamp                        sampler      NA          NA    4        1
// sDepthMap                         texture  float4          2d    0        1
// sGxAmbLut                         texture  float4          2d    1        1
// sAmbSpc                           texture  float4        cube    2        1
// sTrnsSpc                          texture  float4          2d    3        1
// sRamp                             texture  float4          2d    4        1
// sDepth                            texture  float4          2d    5        1
// sGBuf0                            texture  float4          2d    6        1
// sGBuf1                            texture  float4     2darray    7        1
// sGBuf2                            texture  float4          2d    8        1
// sGBuf3                            texture  float4     2darray    9        1
// $Globals                          cbuffer      NA          NA    0        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
//
//
// 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[35], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texturecube (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_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2darray (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t8
dcl_resource_texture2darray (float,float,float,float) t9
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xyw
dcl_output o0.xyzw
dcl_temps 30
dcl_resource_texture2d (float,float,float,float) t125
ftoi r0.xy, v0.xyxx
mov r0.zw, l(0,0,1,0)
ld_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyww, t6.xyzw
ld_indexable(texture2darray)(float,float,float,float) r2.xyzw, r0.xyww, t7.xyzw
ld_indexable(texture2d)(float,float,float,float) r3.xyz, r0.xyww, t8.xyzw
ld_indexable(texture2darray)(float,float,float,float) r4.xyz, r0.xyww, t9.xyzw
ld_indexable(texture2darray)(float,float,float,float) r5.xyz, r0.xyzw, t9.xyzw
mov r0.z, l(3)
ld_indexable(texture2darray)(float,float,float,float) r6.xyz, r0.xyzw, t7.xywz
ld_indexable(texture2d)(float,float,float,float) r0.x, r0.xyww, t5.xyzw

ld_indexable(texture2d)(float,float,float,float) r25.xyzw, l(0, 0, 0, 0), t125.xyzw
mov r26.x, v1.x
mul r27.xyzw, v1.yyyy, cb0[27].xyzw
mad r27.xyzw, r26.xxxx, cb0[26].xyzw, r27.xyzw
mad r27.xyzw, r0.xxxx, cb0[28].xyzw, r27.xyzw
add r27.xyzw, r27.xyzw, cb0[29].xyzw
add r26.x, -r25.x, r26.x
mul r28.xyzw, v1.yyyy, cb0[27].xyzw
mad r28.xyzw, r26.xxxx, cb0[26].xyzw, r28.xyzw
mad r28.xyzw, r0.xxxx, cb0[28].xyzw, r28.xyzw
add r28.xyzw, r28.xyzw, cb0[29].xyzw
div r28.xyz, r28.xyzx, r28.wwww
mul r29.w, r25.y, r27.w
mad r26.x, r25.x, r29.w, r26.x
mul r7.xyzw, v1.yyyy, cb0[27].xyzw
mad r7.xyzw, r26.xxxx, cb0[26].xyzw, r7.xyzw
mad r0.xyzw, r0.xxxx, cb0[28].xyzw, r7.xyzw
add r0.xyzw, r0.xyzw, cb0[29].xyzw
div r0.xyz, r0.xyzx, r0.wwww
add r7.xyz, -r28.xyzx, cb0[11].xyzx
dp3 r0.w, r7.xyzx, r7.xyzx
rsq r0.w, r0.w
mul r8.xyz, r0.wwww, r7.xyzx
add r3.w, r2.w, r2.w
mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
add r9.xyz, -|r3.xyxx|, l(1.000000, 1.000000, 1.000000, 0.000000)
add r10.z, -|r3.y|, r9.x
ge r4.w, r10.z, l(0.000000)
ge r9.xw, r3.xxxy, l(0.000000, 0.000000, 0.000000, 0.000000)
movc r9.xw, r9.xxxw, l(1.000000,0,0,1.000000), l(-1.000000,0,0,-1.000000)
mul r9.xy, r9.xwxx, r9.yzyy
movc r10.xy, r4.wwww, r3.xyxx, r9.xyxx
dp3 r3.x, r10.xyzx, r10.xyzx
rsq r3.x, r3.x
mul r9.xyz, r3.xxxx, r10.xyzx
mul r10.xyz, r9.yyyy, cb0[23].xyzx
mad r9.xyw, r9.xxxx, cb0[22].xyxz, r10.xyxz
mad r9.xyz, r9.zzzz, cb0[24].xyzx, r9.xywx
mul r3.x, r3.z, l(65535.000000)
ftou r3.x, r3.x
ushr r3.x, r3.x, l(8)
utof r3.x, r3.x
mul r3.y, r3.x, l(0.00392156886)
mad r3.x, r3.x, l(0.00392156886), l(1.000000)

add r10.xyz, -r28.xyzx, cb0[16].xyzx
max r11.xyz, r1.xyzx, l(0.000100, 0.000100, 0.000100, 0.000000)
min r11.xyz, r11.xyzx, l(0.999900, 0.999900, 0.999900, 0.000000)
log r11.xyz, r11.xyzx
mul r11.xyz, r11.xyzx, l(0.693147182, 0.693147182, 0.693147182, 0.000000)
max r5.yw, r5.yyyz, l(0.000000, 0.000100, 0.000000, 0.000000)
div r11.xyz, -r11.xyzx, r5.yyyy
mul r11.xyz, r5.wwww, -r11.xyzx
mul r11.xyz, r11.xyzx, l(1.442695, 1.442695, 1.442695, 0.000000)
exp r11.xyz, r11.xyzx
dp3 r3.z, r9.xyzx, r8.xyzx
mov_sat r4.w, r3.z
add r5.y, r1.w, r4.w
mad r5.y, r5.y, r5.y, r1.w
add_sat r5.y, r5.y, l(-1.000000)
movc r5.w, cb0[12].z, l(1.000000), r6.z
dp3 r12.x, r9.xyzx, -cb0[0].xyzx
lt r6.z, r12.x, l(0.000000)
lt r6.w, l(1.000000), r3.x
and r6.z, r6.w, r6.z
add r7.w, r12.x, r12.x
mad r13.yzw, r9.xxyz, r7.wwww, cb0[0].xxyz
mov r13.x, -r12.x
mul r14.xyz, r11.xyzx, cb0[4].xyzx
mad r15.xyz, r7.xyzx, r0.wwww, -r13.yzwy
dp3 r7.w, r15.xyzx, r15.xyzx
rsq r7.w, r7.w
mul r15.xyz, r7.wwww, r15.xyzx
dp3 r7.w, r8.xyzx, r15.xyzx
lt r8.w, l(0.000000), r7.w
log r9.w, r7.w
mul r9.w, r9.w, cb0[14].z
exp r9.w, r9.w
movc r8.w, r8.w, r9.w, r7.w
mad r8.w, r8.w, cb0[14].w, l(0.500000)
round_z r8.w, r8.w
div r8.w, r8.w, cb0[14].w
movc_sat r7.w, cb0[12].z, r8.w, r7.w
add r15.xyz, -r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
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
mad r16.xyz, r15.xyzx, r7.wwww, r2.xyzx
add r17.xyz, -r16.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
add r3.x, -r3.x, l(2.000000)
mul r18.xyz, r3.xxxx, r17.xyzx
mad r16.xyz, r17.xyzx, r3.xxxx, r16.xyzx
add r16.xyz, -r16.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mul r17.xyz, r3.yyyy, r18.xyzx
movc r16.xyz, r6.zzzz, r16.xyzx, l(-1.000000,-1.000000,-1.000000,0)
movc r17.xyz, r6.zzzz, r17.xyzx, l(-1.000000,-1.000000,-1.000000,0)
movc r14.xyz, r6.zzzz, r14.xyzx, cb0[4].xyzx
mov r12.yzw, cb0[0].xxyz
movc r13.xyzw, r6.zzzz, r13.xyzw, r12.xyzw
mad r13.yzw, r7.xxyz, r0.wwww, -r13.yyzw
dp3 r6.z, r13.yzwy, r13.yzwy
rsq r6.z, r6.z
mul r13.yzw, r6.zzzz, r13.yyzw
dp3 r6.z, r8.xyzx, r13.yzwy
ge r7.w, r16.x, l(0.000000)
lt r8.w, l(0.000000), r6.z
log r9.w, r6.z
mul r9.w, r9.w, cb0[14].z
exp r9.w, r9.w
movc r8.w, r8.w, r9.w, r6.z
mad r8.w, r8.w, cb0[14].w, l(0.500000)
round_z r8.w, r8.w
div r8.w, r8.w, cb0[14].w
movc_sat r8.w, cb0[12].z, r8.w, r6.z
add r8.w, -r8.w, l(1.000000)
mul r9.w, r8.w, r8.w
mul r9.w, r9.w, r9.w
mul r8.w, r8.w, r9.w
mad r18.xyz, r15.xyzx, r8.wwww, r2.xyzx
movc r18.xyz, r7.wwww, r16.xyzx, r18.xyzx
mul r3.w, r3.w, r3.w
mul r8.w, r3.w, r3.w
dp3 r9.w, r9.xyzx, r13.yzwy
mul r10.w, r8.w, r8.w
mul r9.w, r9.w, r9.w
mad r11.w, r8.w, r8.w, l(-1.000000)
mad r9.w, r9.w, r11.w, l(1.000000)
max r9.w, r9.w, l(0.000100)
mul r9.w, r9.w, r9.w
mul r9.w, r9.w, l(4.000000)
div r9.w, r10.w, r9.w
mul r12.z, r8.w, l(0.500000)
mad r8.w, -r8.w, l(0.500000), l(1.000000)
mad r6.z, r6.z, r8.w, r12.z
mul r6.z, r6.z, r6.z
div r6.z, l(1.000000, 1.000000, 1.000000, 1.000000), r6.z
mul r6.z, r6.z, r9.w
mul r13.yzw, r6.zzzz, r18.xxyz
mul r13.yzw, r14.xxyz, r13.yyzw
mov_sat r13.x, r13.x
mul r18.xy, cb0[8].xxxx, cb0[12].yxyy
movc r6.z, cb0[12].z, cb0[14].z, l(1.000000)
mul r18.zw, r6.zzzz, r18.xxxy
mad r18.xy, -r18.xyxx, r6.zzzz, l(1.000000, 1.000000, 0.000000, 0.000000)
mad r9.w, r5.y, r18.z, r18.x
mul r9.w, r9.w, r13.x
mul r13.yzw, r9.wwww, r13.yyzw
mul r14.xyz, r13.xxxx, r14.xyzx
mul r19.xyz, r3.xxxx, r15.xyzx
movc r20.xyz, r7.wwww, r17.xyzx, r19.xyzx
mul r14.xyz, r14.xyzx, r20.xyzx
mad r7.w, r1.w, r18.w, r18.y
mul r14.xyz, r7.wwww, r14.xyzx
mul r14.xyz, r5.wwww, r14.xyzx
mul r13.xyz, r5.wwww, r13.yzwy
ilt r7.w, l(0), cb0[10].x
if_nz r7.w
  dp3 r18.x, r9.xyzx, -cb0[1].xyzx
  lt r7.w, r18.x, l(0.000000)
  and r7.w, r6.w, r7.w
  add r9.w, r18.x, r18.x
  mad r20.yzw, r9.xxyz, r9.wwww, cb0[1].xxyz
  mov r20.x, -r18.x
  mul r21.xyz, r11.xyzx, cb0[5].xyzx
  mad r22.xyz, r7.xyzx, r0.wwww, -r20.yzwy
  dp3 r9.w, r22.xyzx, r22.xyzx
  rsq r9.w, r9.w
  mul r22.xyz, r9.wwww, r22.xyzx
  dp3 r9.w, r8.xyzx, r22.xyzx
  lt r12.w, l(0.000000), r9.w
  log r13.w, r9.w
  mul r13.w, r13.w, cb0[14].z
  exp r13.w, r13.w
  movc r12.w, r12.w, r13.w, r9.w
  mad r12.w, r12.w, cb0[14].w, l(0.500000)
  round_z r12.w, r12.w
  div r12.w, r12.w, cb0[14].w
  movc_sat r9.w, cb0[12].z, r12.w, r9.w
  add r9.w, -r9.w, l(1.000000)
  mul r12.w, r9.w, r9.w
  mul r12.w, r12.w, r12.w
  mul r9.w, r9.w, r12.w
  mad r22.xyz, r15.xyzx, r9.wwww, r2.xyzx
  add r23.xyz, -r22.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mul r24.xyz, r3.xxxx, r23.xyzx
  mad r22.xyz, r23.xyzx, r3.xxxx, r22.xyzx
  add r22.xyz, -r22.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mul r23.xyz, r3.yyyy, r24.xyzx
  mov r16.w, l(-1.000000)
  movc r16.xyz, r7.wwww, r22.xyzx, r16.wyzw
  movc r17.xyz, r7.wwww, r23.xyzx, r17.xyzx
  movc r21.xyz, r7.wwww, r21.xyzx, cb0[5].xyzx
  mov r18.yzw, cb0[1].xxyz
  movc r18.xyzw, r7.wwww, r20.xyzw, r18.xyzw
  mad r18.yzw, r7.xxyz, r0.wwww, -r18.yyzw
  dp3 r7.w, r18.yzwy, r18.yzwy
  rsq r7.w, r7.w
  mul r18.yzw, r7.wwww, r18.yyzw
  dp3 r7.w, r8.xyzx, r18.yzwy
  ge r9.w, r16.x, l(0.000000)
  lt r12.w, l(0.000000), r7.w
  log r13.w, r7.w
  mul r13.w, r13.w, cb0[14].z
  exp r13.w, r13.w
  movc r12.w, r12.w, r13.w, r7.w
  mad r12.w, r12.w, cb0[14].w, l(0.500000)
  round_z r12.w, r12.w
  div r12.w, r12.w, cb0[14].w
  movc_sat r12.w, cb0[12].z, r12.w, r7.w
  add r12.w, -r12.w, l(1.000000)
  mul r13.w, r12.w, r12.w
  mul r13.w, r13.w, r13.w
  mul r12.w, r12.w, r13.w
  mad r20.xyz, r15.xyzx, r12.wwww, r2.xyzx
  movc r20.xyz, r9.wwww, r16.xyzx, r20.xyzx
  dp3 r12.w, r9.xyzx, r18.yzwy
  mul r12.w, r12.w, r12.w
  mad r12.w, r12.w, r11.w, l(1.000000)
  max r12.w, r12.w, l(0.000100)
  mul r12.w, r12.w, r12.w
  mul r12.w, r12.w, l(4.000000)
  div r12.w, r10.w, r12.w
  mad r7.w, r7.w, r8.w, r12.z
  mul r7.w, r7.w, r7.w
  div r7.w, l(1.000000, 1.000000, 1.000000, 1.000000), r7.w
  mul r7.w, r7.w, r12.w
  mul r18.yzw, r7.wwww, r20.xxyz
  mul r18.yzw, r21.xxyz, r18.yyzw
  mov_sat r18.x, r18.x
  mul r20.xy, cb0[8].yyyy, cb0[12].yxyy
  mul r20.zw, r6.zzzz, r20.xxxy
  mad r20.xy, -r20.xyxx, r6.zzzz, l(1.000000, 1.000000, 0.000000, 0.000000)
  mad r7.w, r5.y, r20.z, r20.x
  mul r7.w, r7.w, r18.x
  mad r13.xyz, r18.yzwy, r7.wwww, r13.xyzx
  mul r18.xyz, r18.xxxx, r21.xyzx
  movc r21.xyz, r9.wwww, r17.xyzx, r19.xyzx
  mul r18.xyz, r18.xyzx, r21.xyzx
  mad r7.w, r1.w, r20.w, r20.y
  mad r14.xyz, r18.xyzx, r7.wwww, r14.xyzx
  ilt r7.w, l(1), cb0[10].x
  if_nz r7.w
    dp3 r18.x, r9.xyzx, -cb0[2].xyzx
    lt r7.w, r18.x, l(0.000000)
    and r7.w, r6.w, r7.w
    add r9.w, r18.x, r18.x
    mad r20.yzw, r9.xxyz, r9.wwww, cb0[2].xxyz
    mov r20.x, -r18.x
    mul r21.xyz, r11.xyzx, cb0[6].xyzx
    mad r22.xyz, r7.xyzx, r0.wwww, -r20.yzwy
    dp3 r9.w, r22.xyzx, r22.xyzx
    rsq r9.w, r9.w
    mul r22.xyz, r9.wwww, r22.xyzx
    dp3 r9.w, r8.xyzx, r22.xyzx
    lt r12.w, l(0.000000), r9.w
    log r13.w, r9.w
    mul r13.w, r13.w, cb0[14].z
    exp r13.w, r13.w
    movc r12.w, r12.w, r13.w, r9.w
    mad r12.w, r12.w, cb0[14].w, l(0.500000)
    round_z r12.w, r12.w
    div r12.w, r12.w, cb0[14].w
    movc_sat r9.w, cb0[12].z, r12.w, r9.w
    add r9.w, -r9.w, l(1.000000)
    mul r12.w, r9.w, r9.w
    mul r12.w, r12.w, r12.w
    mul r9.w, r9.w, r12.w
    mad r22.xyz, r15.xyzx, r9.wwww, r2.xyzx
    add r23.xyz, -r22.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
    mul r24.xyz, r3.xxxx, r23.xyzx
    mad r22.xyz, r23.xyzx, r3.xxxx, r22.xyzx
    add r22.xyz, -r22.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
    mul r23.xyz, r3.yyyy, r24.xyzx
    mov r16.w, l(-1.000000)
    movc r16.xyz, r7.wwww, r22.xyzx, r16.wyzw
    movc r17.xyz, r7.wwww, r23.xyzx, r17.xyzx
    movc r21.xyz, r7.wwww, r21.xyzx, cb0[6].xyzx
    mov r18.yzw, cb0[2].xxyz
    movc r18.xyzw, r7.wwww, r20.xyzw, r18.xyzw
    mad r18.yzw, r7.xxyz, r0.wwww, -r18.yyzw
    dp3 r7.w, r18.yzwy, r18.yzwy
    rsq r7.w, r7.w
    mul r18.yzw, r7.wwww, r18.yyzw
    dp3 r7.w, r8.xyzx, r18.yzwy
    ge r9.w, r16.x, l(0.000000)
    lt r12.w, l(0.000000), r7.w
    log r13.w, r7.w
    mul r13.w, r13.w, cb0[14].z
    exp r13.w, r13.w
    movc r12.w, r12.w, r13.w, r7.w
    mad r12.w, r12.w, cb0[14].w, l(0.500000)
    round_z r12.w, r12.w
    div r12.w, r12.w, cb0[14].w
    movc_sat r12.w, cb0[12].z, r12.w, r7.w
    add r12.w, -r12.w, l(1.000000)
    mul r13.w, r12.w, r12.w
    mul r13.w, r13.w, r13.w
    mul r12.w, r12.w, r13.w
    mad r20.xyz, r15.xyzx, r12.wwww, r2.xyzx
    movc r20.xyz, r9.wwww, r16.xyzx, r20.xyzx
    dp3 r12.w, r9.xyzx, r18.yzwy
    mul r12.w, r12.w, r12.w
    mad r12.w, r12.w, r11.w, l(1.000000)
    max r12.w, r12.w, l(0.000100)
    mul r12.w, r12.w, r12.w
    mul r12.w, r12.w, l(4.000000)
    div r12.w, r10.w, r12.w
    mad r7.w, r7.w, r8.w, r12.z
    mul r7.w, r7.w, r7.w
    div r7.w, l(1.000000, 1.000000, 1.000000, 1.000000), r7.w
    mul r7.w, r7.w, r12.w
    mul r18.yzw, r7.wwww, r20.xxyz
    mul r18.yzw, r21.xxyz, r18.yyzw
    mov_sat r18.x, r18.x
    mul r20.xy, cb0[8].zzzz, cb0[12].yxyy
    mul r20.zw, r6.zzzz, r20.xxxy
    mad r20.xy, -r20.xyxx, r6.zzzz, l(1.000000, 1.000000, 0.000000, 0.000000)
    mad r7.w, r5.y, r20.z, r20.x
    mul r7.w, r7.w, r18.x
    mad r13.xyz, r18.yzwy, r7.wwww, r13.xyzx
    mul r18.xyz, r18.xxxx, r21.xyzx
    movc r21.xyz, r9.wwww, r17.xyzx, r19.xyzx
    mul r18.xyz, r18.xyzx, r21.xyzx
    mad r7.w, r1.w, r20.w, r20.y
    mad r14.xyz, r18.xyzx, r7.wwww, r14.xyzx
    ilt r7.w, l(2), cb0[10].x
    if_nz r7.w
      dp3 r18.x, r9.xyzx, -cb0[3].xyzx
      lt r7.w, r18.x, l(0.000000)
      and r7.w, r6.w, r7.w
      add r9.w, r18.x, r18.x
      mad r20.yzw, r9.xxyz, r9.wwww, cb0[3].xxyz
      mov r20.x, -r18.x
      mul r21.xyz, r11.xyzx, cb0[7].xyzx
      mad r22.xyz, r7.xyzx, r0.wwww, -r20.yzwy
      dp3 r9.w, r22.xyzx, r22.xyzx
      rsq r9.w, r9.w
      mul r22.xyz, r9.wwww, r22.xyzx
      dp3 r9.w, r8.xyzx, r22.xyzx
      lt r12.w, l(0.000000), r9.w
      log r13.w, r9.w
      mul r13.w, r13.w, cb0[14].z
      exp r13.w, r13.w
      movc r12.w, r12.w, r13.w, r9.w
      mad r12.w, r12.w, cb0[14].w, l(0.500000)
      round_z r12.w, r12.w
      div r12.w, r12.w, cb0[14].w
      movc_sat r9.w, cb0[12].z, r12.w, r9.w
      add r9.w, -r9.w, l(1.000000)
      mul r12.w, r9.w, r9.w
      mul r12.w, r12.w, r12.w
      mul r9.w, r9.w, r12.w
      mad r22.xyz, r15.xyzx, r9.wwww, r2.xyzx
      add r23.xyz, -r22.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
      mul r24.xyz, r3.xxxx, r23.xyzx
      mad r22.xyz, r23.xyzx, r3.xxxx, r22.xyzx
      add r22.xyz, -r22.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
      mul r23.xyz, r3.yyyy, r24.xyzx
      mov r16.w, l(-1.000000)
      movc r16.xyz, r7.wwww, r22.xyzx, r16.wyzw
      movc r17.xyz, r7.wwww, r23.xyzx, r17.xyzx
      movc r21.xyz, r7.wwww, r21.xyzx, cb0[7].xyzx
      mov r18.yzw, cb0[3].xxyz
      movc r18.xyzw, r7.wwww, r20.xyzw, r18.xyzw
      mad r7.xyz, r7.xyzx, r0.wwww, -r18.yzwy
      dp3 r0.w, r7.xyzx, r7.xyzx
      rsq r0.w, r0.w
      mul r7.xyz, r0.wwww, r7.xyzx
      dp3 r0.w, r8.xyzx, r7.xyzx
      ge r3.y, r16.x, l(0.000000)
      lt r7.w, l(0.000000), r0.w
      log r9.w, r0.w
      mul r9.w, r9.w, cb0[14].z
      exp r9.w, r9.w
      movc r7.w, r7.w, r9.w, r0.w
      mad r7.w, r7.w, cb0[14].w, l(0.500000)
      round_z r7.w, r7.w
      div r7.w, r7.w, cb0[14].w
      movc_sat r7.w, cb0[12].z, r7.w, r0.w
      add r7.w, -r7.w, l(1.000000)
      mul r9.w, r7.w, r7.w
      mul r9.w, r9.w, r9.w
      mul r7.w, r7.w, r9.w
      mad r18.yzw, r15.xxyz, r7.wwww, r2.xxyz
      movc r16.xyz, r3.yyyy, r16.xyzx, r18.yzwy
      dp3 r7.x, r9.xyzx, r7.xyzx
      mul r7.x, r7.x, r7.x
      mad r7.x, r7.x, r11.w, l(1.000000)
      max r7.x, r7.x, l(0.000100)
      mul r7.x, r7.x, r7.x
      mul r7.x, r7.x, l(4.000000)
      div r7.x, r10.w, r7.x
      mad r0.w, r0.w, r8.w, r12.z
      mul r0.w, r0.w, r0.w
      div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
      mul r0.w, r0.w, r7.x
      mul r7.xyz, r0.wwww, r16.xyzx
      mul r7.xyz, r21.xyzx, r7.xyzx
      mov_sat r18.x, r18.x
      mul r12.zw, cb0[8].wwww, cb0[12].yyyx
      mul r16.xy, r6.zzzz, r12.zwzz
      mad r12.zw, -r12.zzzw, r6.zzzz, l(0.000000, 0.000000, 1.000000, 1.000000)
      mad r0.w, r5.y, r16.x, r12.z
      mul r0.w, r0.w, r18.x
      mad r13.xyz, r7.xyzx, r0.wwww, r13.xyzx
      mul r7.xyz, r18.xxxx, r21.xyzx
      movc r16.xzw, r3.yyyy, r17.xxyz, r19.xxyz
      mul r7.xyz, r7.xyzx, r16.xzwx
      mad r0.w, r1.w, r16.y, r12.w
      mad r14.xyz, r7.xyzx, r0.wwww, r14.xyzx
    endif
  endif
endif
ne r0.w, cb0[30].x, l(0.000000)
dp3 r3.y, -r8.xyzx, r9.xyzx
add r3.y, r3.y, r3.y
mad r7.xyz, r9.xyzx, -r3.yyyy, -r8.xyzx
mov r8.x, -r9.y
mov r8.y, -r7.y
mov_sat r8.xy, r8.xyxx
dp3_sat r12.y, r7.xyzx, -cb0[0].xyzx
mov_sat r12.x, r12.x
add r8.xy, r8.xyxx, r12.xyxx
mul_sat r8.xy, r8.xyxx, cb0[30].xxxx
add r3.y, r5.w, l(-1.000000)
mad r8.xy, r8.xyxx, r3.yyyy, l(1.000000, 1.000000, 0.000000, 0.000000)
movc r8.xy, r0.wwww, r8.xyxx, l(1.000000,1.000000,0,0)
sample_l_indexable(texturecube)(float,float,float,float) r12.xyz, r9.xyzx, t2.xyzw, s2, l(6.000000)
mul r8.xzw, r8.xxxx, r12.xxyz
mad r8.xzw, r8.xxzw, cb0[31].xxyz, cb0[9].xxyz
add r0.w, -cb0[31].w, l(1.000000)
mad r0.w, r1.w, cb0[31].w, r0.w
add r0.w, r0.w, l(-1.000000)
mad r0.w, r6.z, r0.w, l(1.000000)
add r6.xy, -r6.yxyy, l(1.000000, 1.000000, 0.000000, 0.000000)
mul r3.y, r0.w, r6.x
mul r8.xzw, r3.yyyy, r8.xxzw
mad r8.xzw, r8.xxzw, r19.xxyz, r14.xxyz
mul r3.y, r3.w, l(6.000000)
max r7.w, |r7.y|, l(0.008749)
sample_l_indexable(texturecube)(float,float,float,float) r7.xyz, r7.xwzx, t2.xyzw, s2, r3.y
mul r7.xyz, r8.yyyy, r7.xyzx
if_nz cb0[12].z
  add r12.x, -r4.w, l(1.000000)
  itof r3.y, cb0[12].z
  add r3.y, r3.y, l(-0.500000)
  itof r3.w, cb0[32].x
  div r12.y, r3.y, r3.w
  sample_l_indexable(texture2d)(float,float,float,float) r12.xyz, r12.xyxx, t4.xyzw, s4, l(0.000000)
  mad r12.xyz, r12.xyzx, cb0[15].yyyy, -r7.xyzx
  mad r7.xyz, cb0[15].xxxx, r12.xyzx, r7.xyzx
endif
mul r7.xyz, r7.xyzx, cb0[33].xyzx
lt r3.y, l(0.000000), r3.z
log r3.w, r3.z
mul r3.w, r3.w, cb0[14].z
exp r3.w, r3.w
movc r3.y, r3.y, r3.w, r3.z
mad r3.y, r3.y, cb0[14].w, l(0.500000)
round_z r3.y, r3.y
div r3.y, r3.y, cb0[14].w
movc r3.y, cb0[12].z, r3.y, r3.z
mov r3.z, r2.w
sample_indexable(texture2d)(float,float,float,float) r3.zw, r3.yzyy, t1.zwxy, s1
mad r12.xyz, r2.xyzx, r3.zzzz, r3.wwww
mul r7.xyz, r7.xyzx, r12.xyzx
add r2.w, -cb0[33].w, l(1.000000)
mad r1.w, r1.w, cb0[33].w, r2.w
add r2.w, -r1.w, l(1.000000)
mad r2.w, r5.y, r2.w, r1.w
mad r1.w, r1.w, r2.w, l(-1.000000)
mad r1.w, r6.z, r1.w, l(1.000000)
mul r2.w, r6.y, r1.w
mad r6.xyz, r7.xyzx, r2.wwww, r13.xyzx
div r2.w, l(1.000000, 1.000000, 1.000000, 1.000000), r5.x
dp3 r3.z, r10.xyzx, r10.xyzx
rsq r3.z, r3.z
mul r5.xyw, r3.zzzz, r10.xyxz
dp3_sat r3.z, r9.xyzx, r5.xywx
mad r3.z, -r3.z, r3.z, l(1.000000)
sqrt r3.z, r3.z
mad r3.z, r3.z, r2.w, -r3.z
add r7.xyz, r9.xyzx, l(-0.000000, -1.000000, -0.000000, 0.000000)
mul r5.xyw, r2.wwww, r5.xyxw
mad r5.xyw, r3.zzzz, r7.xyxz, -r5.xyxw
dp3 r2.w, r5.xywx, r5.xywx
rsq r2.w, r2.w
mul r5.xyw, r2.wwww, r5.xyxw
mad r5.xyz, r5.xywx, r5.zzzz, r0.xyzx
mov r5.w, l(1.000000)
dp4 r0.x, r5.xyzw, cb0[19].xyzw
dp4 r0.y, r5.xyzw, cb0[20].xyzw
dp4 r0.z, r5.xyzw, cb0[21].xyzw

//Haloing fix. Related to water PS.
add r25.w, r0.z, -r25.y
mul r25.w, r25.w, l(0.5)
mad r0.x, r25.x, r25.w, r0.x

div r0.xy, r0.xyxx, r0.zzzz
sample_indexable(texture2d)(float,float,float,float) r0.z, r0.xyxx, t0.yzxw, s0
if_nz r6.w
  div r3.zw, v1.xxxy, v1.wwww
  mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 0.500000, -0.500000), l(0.000000, 0.000000, 0.500000, 0.500000)
  dp3 r2.w, -r10.xyzx, cb0[17].xyzx
  mov_sat r3.y, r3.y
  add r3.y, -r3.y, l(1.000000)
  mul r5.x, r3.y, r3.y
  mul r5.x, r5.x, r5.x
  mul r3.y, r3.y, r5.x
  mad r2.xyz, r15.xyzx, r3.yyyy, r2.xyzx
  add r5.xyz, -r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mad r2.xyz, r5.xyzx, r3.xxxx, r2.xyzx
  add r2.xyz, -r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mul r5.xyz, r3.xxxx, r2.xyzx
  mad_sat r0.z, cb0[18].y, r0.z, cb0[18].x
  div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
  lt r0.z, r0.z, r2.w
  movc r0.xy, r0.zzzz, r3.zwzz, r0.xyxx
  mad r0.xy, r0.xyxx, cb0[34].zwzz, cb0[34].xyxx
  sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r0.xyxx, t3.xyzw, s3, l(16.000000)
  mul r3.xyz, r3.xyzx, cb0[31].xyzx
  mul r3.xyz, r0.wwww, r3.xyzx
  mul r3.xyz, r5.xyzx, r3.xyzx
  mad r8.xzw, r3.xxyz, r11.xxyz, r8.xxzw
  sample_l_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t3.xyzw, s3, l(0.000000)
  if_nz cb0[12].z
    add r3.x, -r4.w, l(1.000000)
    itof r0.w, cb0[12].z
    add r0.w, r0.w, l(-0.500000)
    itof r2.w, cb0[32].x
    div r3.y, r0.w, r2.w
    sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r3.xyxx, t4.xyzw, s4, l(0.000000)
    mad r3.xyz, r3.xyzx, cb0[15].yyyy, -r0.xyzx
    mad r0.xyz, cb0[15].xxxx, r3.xyzx, r0.xyzx
  endif
  mul r0.xyz, r0.xyzx, cb0[33].xyzx
  mul r0.xyz, r1.wwww, r0.xyzx
  mul r0.xyz, r2.xyzx, r0.xyzx
  mad r6.xyz, r0.xyzx, r11.xyzx, r6.xyzx
endif
mad r0.xyz, r8.xzwx, r1.xyzx, r4.xyzx
add o0.xyz, r6.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 535 instruction slots used
