// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed e9c5005727d4a353-ps.txt
// 3DMigoto: e9c5005727d4a353 |    Unity headers extracted from Hidden_TerrainEngine_Splatmap_Standard-AddPass
//    Shader "Hidden/TerrainEngine/Splatmap/Standard-AddPass" {
//      Fallback "Hidden/TerrainEngine/Splatmap/Diffuse-AddPass"
//      SubShader 1/1 {
//        Tags { "IGNOREPROJECTOR"="true" "QUEUE"="Geometry-99" "RenderType"="Opaque" }
//        Pass 1/4 {
//          Name "FORWARD"
//          Tags { "IGNOREPROJECTOR"="true" "LIGHTMODE"="FORWARDBASE" "QUEUE"="Geometry-99" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Hidden_TerrainEngine_Splatmap_Standard-AddPass:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 169 8 6
//   undeciphered1a: 13
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_ON" }
//   undeciphered2: 1 10 7 9 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1200
//   Vector 16 [unity_DynamicLightmap_HDR]
//   Vector 32 [_LightColor0]
//   Float 1104 [_Metallic0]
//   Float 1108 [_Metallic1]
//   Float 1112 [_Metallic2]
//   Float 1116 [_Metallic3]
//   Float 1120 [_Smoothness0]
//   Float 1124 [_Smoothness1]
//   Float 1128 [_Smoothness2]
//   Float 1132 [_Smoothness3]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   ConstBuffer "UnityReflectionProbes" 128
//   Vector 0 [unity_SpecCube0_BoxMax]
//   Vector 16 [unity_SpecCube0_BoxMin]
//   Vector 32 [unity_SpecCube0_ProbePosition]
//   Vector 48 [unity_SpecCube0_HDR]
//   Vector 64 [unity_SpecCube1_BoxMax]
//   Vector 80 [unity_SpecCube1_BoxMin]
//   Vector 96 [unity_SpecCube1_ProbePosition]
//   Vector 112 [unity_SpecCube1_HDR]
//   ConstBuffer "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_Control] 2D 4
//   SetTexture 1 [_Splat0] 2D 5
//   SetTexture 2 [_Splat1] 2D 6
//   SetTexture 3 [_Splat2] 2D 7
//   SetTexture 4 [_Splat3] 2D 8
//   SetTexture 5 [_ShadowMapTexture] 2D 3
//   SetTexture 6 [unity_DynamicLightmap] 2D 0
//   SetTexture 7 [unity_SpecCube0] CUBE 1
//   SetTexture 8 [unity_SpecCube1] CUBE -1
//   SetTexture 9 [unity_ProbeVolumeSH] 3D 2
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//   BindCB "UnityReflectionProbes" 5
//   BindCB "UnityProbeVolume" 6
//
// Headers extracted with DarkStarSword's extract_unity55_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sun Apr 21 18:03:42 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// TEXCOORD                 3   xyz         4     NONE   float   xyz
// TEXCOORD                 4   xy          5     NONE   float   xy
// TEXCOORD                 6   xyzw        6     NONE   float   xy w
// TEXCOORD                 7   xyzw        7     NONE   float     zw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[71], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[12], immediateIndexed
dcl_constantbuffer cb5[8], immediateIndexed
dcl_constantbuffer cb6[7], 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_sampler s5, mode_default
dcl_sampler s6, mode_default
dcl_sampler s7, mode_default
dcl_sampler s8, mode_default
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_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texturecube (float,float,float,float) t7
dcl_resource_texturecube (float,float,float,float) t8
dcl_resource_texture3d (float,float,float,float) t9
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyz
dcl_input_ps linear v5.xy
dcl_input_ps linear v6.xyw
dcl_input_ps linear v7.zw
dcl_output o0.xyzw
dcl_temps 15
dcl_constantbuffer cb10[4], immediateIndexed

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125

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


// Unity reflection/specular fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed e9c5005727d4a353-ps.txt

mul r13.w, -r13.x, r13.y
mad r14.xyz, -r13.wwww, cb10[0].xyzw, cb1[4].xyzw

add r0.xyz, -v4.xyzx, r14.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r0.xyzx
sample r2.xyzw, v5.xyxx, t0.xyzw, s4
dp4 r1.w, r2.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
eq r3.x, r1.w, l(0.000000)
discard_nz r3.x
add r3.x, r1.w, l(0.001000)
div r2.xyzw, r2.xyzw, r3.xxxx
sample r3.xyzw, v1.xyxx, t1.xyzw, s5
mul r3.xyzw, r2.xxxx, r3.xyzw
mul r3.w, r3.w, cb0[70].x
sample r4.xyzw, v1.zwzz, t2.xyzw, s6
mul r4.xyzw, r2.yyyy, r4.xyzw
mul r4.w, r4.w, cb0[70].y
add r3.xyzw, r3.xyzw, r4.xyzw
sample r4.xyzw, v2.xyxx, t3.xyzw, s7
mul r4.xyzw, r2.zzzz, r4.xyzw
mul r4.w, r4.w, cb0[70].z
add r3.xyzw, r3.xyzw, r4.xyzw
sample r4.xyzw, v2.zwzz, t4.xyzw, s8
mul r4.xyzw, r2.wwww, r4.xyzw
mul r4.w, r4.w, cb0[70].w
add r3.xyzw, r3.xyzw, r4.xyzw
dp4 r2.x, r2.xyzw, cb0[69].xyzw
mov r4.x, cb4[9].z
mov r4.y, cb4[10].z
mov r4.z, cb4[11].z
dp3 r2.y, r0.xyzx, r4.xyzx
add r4.xyz, v4.xyzx, -cb3[25].xyzx
dp3 r2.z, r4.xyzx, r4.xyzx
sqrt r2.z, r2.z
add r2.z, -r2.y, r2.z
mad r2.y, cb3[25].w, r2.z, r2.y
mad_sat r2.y, r2.y, cb3[24].z, cb3[24].w
eq r2.z, cb6[0].x, l(1.000000)
if_nz r2.z
  eq r2.z, cb6[0].y, l(1.000000)
  mul r4.xyz, v4.yyyy, cb6[2].xyzx
  mad r4.xyz, cb6[1].xyzx, v4.xxxx, r4.xyzx
  mad r4.xyz, cb6[3].xyzx, v4.zzzz, r4.xyzx
  add r4.xyz, r4.xyzx, cb6[4].xyzx
  movc r4.xyz, r2.zzzz, r4.xyzx, v4.xyzx
  add r4.xyz, r4.xyzx, -cb6[6].xyzx
  mul r4.yzw, r4.xxyz, cb6[5].xxyz
  mad r2.z, r4.y, l(0.250000), l(0.750000)
  mad r2.w, cb6[0].z, l(0.500000), l(0.750000)
  max r4.x, r2.w, r2.z
  sample r4.xyzw, r4.xzwx, t9.xyzw, s2
else
  mov r4.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r2.z, r4.xyzw, cb2[45].xyzw
div r4.xy, v6.xyxx, v6.wwww
sample r4.xyzw, r4.xyxx, t5.xyzw, s3
add r2.z, r2.z, -r4.x
mad r2.y, r2.y, r2.z, r4.x
add r2.z, -r3.w, l(1.000000)
dp3 r2.w, -r1.xyzx, v3.xyzx
add r2.w, r2.w, r2.w
mad r4.xyz, v3.xyzx, -r2.wwww, -r1.xyzx
mul r5.xyz, r2.yyyy, cb0[2].xyzx
sample r6.xyzw, v7.zwzz, t6.xyzw, s0
mul r2.y, r6.w, cb0[1].x
mul r6.xyz, r6.xyzx, r2.yyyy
log r6.xyz, r6.xyzx
mul r6.xyz, r6.xyzx, cb0[1].yyyy
exp r6.xyz, r6.xyzx
lt r2.y, l(0.000000), cb5[2].w
if_nz r2.y
  dp3 r2.y, r4.xyzx, r4.xyzx
  rsq r2.y, r2.y
  mul r7.xyz, r2.yyyy, r4.xyzx
  add r8.xyz, -v4.xyzx, cb5[0].xyzx
  div r8.xyz, r8.xyzx, r7.xyzx
  add r9.xyz, -v4.xyzx, cb5[1].xyzx
  div r9.xyz, r9.xyzx, r7.xyzx
  lt r10.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r7.xyzx
  movc r8.xyz, r10.xyzx, r8.xyzx, r9.xyzx
  min r2.y, r8.y, r8.x
  min r2.y, r8.z, r2.y
  add r8.xyz, v4.xyzx, -cb5[2].xyzx
  mad r7.xyz, r7.xyzx, r2.yyyy, r8.xyzx
else
  mov r7.xyz, r4.xyzx
endif
mad r2.y, -r2.z, l(0.700000), l(1.700000)
mul r2.y, r2.y, r2.z
mul r2.y, r2.y, l(6.000000)
sample_l r7.xyzw, r7.xyzx, t7.xyzw, s1, r2.y
add r2.w, r7.w, l(-1.000000)
mad r2.w, cb5[3].w, r2.w, l(1.000000)
log r2.w, r2.w
mul r2.w, r2.w, cb5[3].y
exp r2.w, r2.w
mul r2.w, r2.w, cb5[3].x
mul r8.xyz, r7.xyzx, r2.wwww
lt r4.w, cb5[1].w, l(0.999990)
if_nz r4.w
  lt r4.w, l(0.000000), cb5[6].w
  if_nz r4.w
    dp3 r4.w, r4.xyzx, r4.xyzx
    rsq r4.w, r4.w
    mul r9.xyz, r4.wwww, r4.xyzx
    add r10.xyz, -v4.xyzx, cb5[4].xyzx
    div r10.xyz, r10.xyzx, r9.xyzx
    add r11.xyz, -v4.xyzx, cb5[5].xyzx
    div r11.xyz, r11.xyzx, r9.xyzx
    lt r12.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r9.xyzx
    movc r10.xyz, r12.xyzx, r10.xyzx, r11.xyzx
    min r4.w, r10.y, r10.x
    min r4.w, r10.z, r4.w
    add r10.xyz, v4.xyzx, -cb5[6].xyzx
    mad r4.xyz, r9.xyzx, r4.wwww, r10.xyzx
  endif
  sample_l r4.xyzw, r4.xyzx, t8.xyzw, s1, r2.y
  add r2.y, r4.w, l(-1.000000)
  mad r2.y, cb5[7].w, r2.y, l(1.000000)
  log r2.y, r2.y
  mul r2.y, r2.y, cb5[7].y
  exp r2.y, r2.y
  mul r2.y, r2.y, cb5[7].x
  mul r4.xyz, r4.xyzx, r2.yyyy
  mad r7.xyz, r2.wwww, r7.xyzx, -r4.xyzx
  mad r8.xyz, cb5[1].wwww, r7.xyzx, r4.xyzx
endif
dp3 r2.y, v3.xyzx, v3.xyzx
rsq r2.y, r2.y
mul r4.xyz, r2.yyyy, v3.xyzx
add r7.xyz, r3.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r7.xyz, r2.xxxx, r7.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r2.x, -r2.x, l(0.960000), l(0.960000)
mul r3.xyz, r2.xxxx, r3.xyzx
mad r0.xyz, r0.xyzx, r0.wwww, cb2[0].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
max r0.w, r0.w, l(0.001000)
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
dp3 r0.w, r4.xyzx, r1.xyzx
dp3_sat r1.x, r4.xyzx, cb2[0].xyzx
dp3_sat r1.y, r4.xyzx, r0.xyzx
dp3_sat r0.x, cb2[0].xyzx, r0.xyzx
mul r0.y, r0.x, r0.x
dp2 r0.y, r0.yyyy, r2.zzzz
add r0.y, r0.y, l(-0.500000)
add r0.z, -r1.x, l(1.000000)
mul r1.z, r0.z, r0.z
mul r1.z, r1.z, r1.z
mul r0.z, r0.z, r1.z
mad r0.z, r0.y, r0.z, l(1.000000)
add r1.z, -|r0.w|, l(1.000000)
mul r2.y, r1.z, r1.z
mul r2.y, r2.y, r2.y
mul r1.z, r1.z, r2.y
mad r0.y, r0.y, r1.z, l(1.000000)
mul r0.y, r0.y, r0.z
mul r0.z, r2.z, r2.z
mad r2.y, -r2.z, r2.z, l(1.000000)
mad r2.z, |r0.w|, r2.y, r0.z
mad r2.y, r1.x, r2.y, r0.z
mul r0.w, |r0.w|, r2.y
mad r0.w, r1.x, r2.z, r0.w
add r0.w, r0.w, l(0.000010)
div r0.w, l(0.500000), r0.w
mul r2.y, r0.z, r0.z
mad r2.z, r1.y, r2.y, -r1.y
mad r1.y, r2.z, r1.y, l(1.000000)
mul r2.y, r2.y, l(0.318309873)
mad r1.y, r1.y, r1.y, l(1.000000012E-007)
div r1.y, r2.y, r1.y
mul r0.w, r0.w, r1.y
mul r0.w, r0.w, l(3.14159274)
mul r0.yw, r1.xxxx, r0.yyyw
max r0.w, r0.w, l(0.000000)
mad r0.z, r0.z, r0.z, l(1.000000)
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
dp3 r1.x, r7.xyzx, r7.xyzx
ne r1.x, r1.x, l(0.000000)
and r1.x, r1.x, l(0x3f800000)
mul r0.w, r0.w, r1.x
add r1.x, -r2.x, r3.w
add_sat r1.x, r1.x, l(1.000000)
mad r2.xyz, r5.xyzx, r0.yyyy, r6.xyzx
mul r4.xyz, r5.xyzx, r0.wwww
add r0.x, -r0.x, l(1.000000)
mul r0.y, r0.x, r0.x
mul r0.y, r0.y, r0.y
mul r0.x, r0.x, r0.y
add r5.xyz, -r7.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r0.xyw, r5.xyxz, r0.xxxx, r7.xyxz
mul r0.xyw, r0.xyxw, r4.xyxz
mad r0.xyw, r3.xyxz, r2.xyxz, r0.xyxw
mul r2.xyz, r8.xyzx, r0.zzzz
add r3.xyz, -r7.xyzx, r1.xxxx
mad r1.xyz, r1.zzzz, r3.xyzx, r7.xyzx
mad r0.xyz, r2.xyzx, r1.xyzx, r0.xywx
mul o0.xyz, r1.wwww, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used