// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 5b1afade46bcf518-ps.txt
// 3DMigoto: 5b1afade46bcf518 |    Unity headers extracted from Hidden_TerrainEngine_Splatmap_Diffuse-AddPass
//    Shader "Hidden/TerrainEngine/Splatmap/Diffuse-AddPass" {
// 1:   SubShader 1/2 {
// 2:   SubShader 2/2 {
//        Tags { "IGNOREPROJECTOR"="true" "QUEUE"="Geometry-99" "RenderType"="Opaque" }
//        Pass 1/6 {
//          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_Diffuse-AddPass:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 60 10 4
//   undeciphered1a: 7
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" }
//   undeciphered2: 1 7 6 7 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1168
//   Vector 32 [_LightColor0]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 608 [unity_SHAr]
//   Vector 624 [unity_SHAg]
//   Vector 640 [unity_SHAb]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   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 2
//   SetTexture 1 [_Splat0] 2D 3
//   SetTexture 2 [_Splat1] 2D 4
//   SetTexture 3 [_Splat2] 2D 5
//   SetTexture 4 [_Splat3] 2D 6
//   SetTexture 5 [_ShadowMapTexture] 2D 1
//   SetTexture 6 [unity_ProbeVolumeSH] 3D 0
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//   BindCB "UnityProbeVolume" 5
//
// 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 17:56:03 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                 5   xyz         6     NONE   float   xyz
// TEXCOORD                 6   xyzw        7     NONE   float   xy w
// TEXCOORD                 7   xyzw        8     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[3], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[12], immediateIndexed
dcl_constantbuffer cb5[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_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_texture3d (float,float,float,float) t6
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.xyz
dcl_input_ps linear v7.xyw
dcl_output o0.xyzw
dcl_temps 9
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r7.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 5b1afade46bcf518-ps.txt

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

sample r0.xyzw, v5.xyxx, t0.xyzw, s2
dp4 r1.x, r0.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
eq r1.y, r1.x, l(0.000000)
discard_nz r1.y
add r1.y, r1.x, l(0.001000)
div r0.xyzw, r0.xyzw, r1.yyyy
sample r2.xyzw, v1.xyxx, t1.xyzw, s3
sample r3.xyzw, v1.zwzz, t2.xyzw, s4
mul r1.yzw, r0.yyyy, r3.xxyz
mad r1.yzw, r0.xxxx, r2.xxyz, r1.yyzw
sample r2.xyzw, v2.xyxx, t3.xyzw, s5
mad r0.xyz, r0.zzzz, r2.xyzx, r1.yzwy
sample r2.xyzw, v2.zwzz, t4.xyzw, s6
mad r0.xyz, r0.wwww, r2.xyzx, r0.xyzx
add r1.yzw, -v4.xxyz, r8.xxyz
mov r2.x, cb4[9].z
mov r2.y, cb4[10].z
mov r2.z, cb4[11].z
dp3 r0.w, r1.yzwy, r2.xyzx
add r1.yzw, v4.xxyz, -cb3[25].xxyz
dp3 r1.y, r1.yzwy, r1.yzwy
sqrt r1.y, r1.y
add r1.y, -r0.w, r1.y
mad r0.w, cb3[25].w, r1.y, r0.w
mad_sat r0.w, r0.w, cb3[24].z, cb3[24].w
eq r1.y, cb5[0].x, l(1.000000)
if_nz r1.y
  eq r1.z, cb5[0].y, l(1.000000)
  mul r2.xyz, v4.yyyy, cb5[2].xyzx
  mad r2.xyz, cb5[1].xyzx, v4.xxxx, r2.xyzx
  mad r2.xyz, cb5[3].xyzx, v4.zzzz, r2.xyzx
  add r2.xyz, r2.xyzx, cb5[4].xyzx
  movc r2.xyz, r1.zzzz, r2.xyzx, v4.xyzx
  add r2.xyz, r2.xyzx, -cb5[6].xyzx
  mul r2.yzw, r2.xxyz, cb5[5].xxyz
  mad r1.z, r2.y, l(0.250000), l(0.750000)
  mad r1.w, cb5[0].z, l(0.500000), l(0.750000)
  max r2.x, r1.w, r1.z
  sample r2.xyzw, r2.xzwx, t6.xyzw, s0
else
  mov r2.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r1.z, r2.xyzw, cb2[45].xyzw
div r2.xy, v7.xyxx, v7.wwww
sample r2.xyzw, r2.xyxx, t5.xyzw, s1
add r1.z, r1.z, -r2.x
mad r0.w, r0.w, r1.z, r2.x
mul r2.xyz, r0.wwww, cb0[2].xyzx
if_nz r1.y
  eq r0.w, cb5[0].y, l(1.000000)
  mul r1.yzw, v4.yyyy, cb5[2].xxyz
  mad r1.yzw, cb5[1].xxyz, v4.xxxx, r1.yyzw
  mad r1.yzw, cb5[3].xxyz, v4.zzzz, r1.yyzw
  add r1.yzw, r1.yyzw, cb5[4].xxyz
  movc r1.yzw, r0.wwww, r1.yyzw, v4.xxyz
  add r1.yzw, r1.yyzw, -cb5[6].xxyz
  mul r3.yzw, r1.yyzw, cb5[5].xxyz
  mul r0.w, r3.y, l(0.250000)
  mul r1.y, cb5[0].z, l(0.500000)
  mad r1.z, -cb5[0].z, l(0.500000), l(0.250000)
  max r0.w, r0.w, r1.y
  min r3.x, r1.z, r0.w
  sample r4.xyzw, r3.xzwx, t6.xyzw, s0
  add r1.yzw, r3.xxzw, l(0.000000, 0.250000, 0.000000, 0.000000)
  sample r5.xyzw, r1.yzwy, t6.xyzw, s0
  add r1.yzw, r3.xxzw, l(0.000000, 0.500000, 0.000000, 0.000000)
  sample r3.xyzw, r1.yzwy, t6.xyzw, s0
  mov r6.xyz, v3.xyzx
  mov r6.w, l(1.000000)
  dp4 r4.x, r4.xyzw, r6.xyzw
  dp4 r4.y, r5.xyzw, r6.xyzw
  dp4 r4.z, r3.xyzw, r6.xyzw
else
  mov r3.xyz, v3.xyzx
  mov r3.w, l(1.000000)
  dp4 r4.x, cb2[38].xyzw, r3.xyzw
  dp4 r4.y, cb2[39].xyzw, r3.xyzw
  dp4 r4.z, cb2[40].xyzw, r3.xyzw
endif
add r1.yzw, r4.xxyz, v6.xxyz
max r1.yzw, r1.yyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
dp3 r0.w, v3.xyzx, cb2[0].xyzx
max r0.w, r0.w, l(0.000000)
mul r2.xyz, r0.xyzx, r2.xyzx
mul r0.xyz, r0.xyzx, r1.yzwy
mad r0.xyz, r2.xyzx, r0.wwww, r0.xyzx
mul o0.xyz, r1.xxxx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used