// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 98c68cf6def34560-ps.txt
// 3DMigoto: 98c68cf6def34560 |    Unity headers extracted from Hidden_TerrainEngine_Splatmap_Standard-Base
//    Shader "Hidden/TerrainEngine/Splatmap/Standard-Base" {
//      Fallback "Diffuse"
//      SubShader 1/1 {
//        LOD 200
//        Tags { "QUEUE"="Geometry-100" "RenderType"="Opaque" }
//        Pass 2/4 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDADD" "QUEUE"="Geometry-100" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Hidden_TerrainEngine_Splatmap_Standard-Base:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 142 5 3
//   undeciphered1a: 10
//   Keywords { "POINT" "SHADOWS_CUBE" }
//   undeciphered2: 1 6 6 6 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1168
//   Vector 32 [_LightColor0]
//   Matrix 1088 [unity_WorldToLight]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   Vector 80 [_ProjectionParams]
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 16 [_LightPositionRange]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   Matrix 272 [unity_MatrixVP]
//   ConstBuffer "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_MainTex] 2D 4
//   SetTexture 1 [_MetallicTex] 2D 5
//   SetTexture 2 [unity_RandomRotation16] 2D 1
//   SetTexture 3 [_LightTexture0] 2D 3
//   SetTexture 4 [unity_ProbeVolumeSH] 3D 0
//   SetTexture 5 [_ShadowMapTexture] CUBE 2
//   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:59:22 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   float   xy
// TEXCOORD                 3     zw        1     NONE   float
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyz         3     NONE   float   xyz
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_immediateConstantBuffer { { -0.635181785, 0.217271104, 0, 0},
                              { -0.149960607, 0.232067496, 0, 0},
                              { -0.679780, 0.688492417, 0, 0},
                              { -0.775864720, -0.253409, 0, 0},
                              { -0.473191589, -0.283272296, 0, 0},
                              { -0.333007902, 0.643005908, 0, 0},
                              { -0.138415098, -0.0983022526, 0, 0},
                              { -0.818232715, -0.564593911, 0, 0},
                              { -0.919847190, 0.0654980168, 0, 0},
                              { -0.142208502, -0.487210900, 0, 0},
                              { -0.498083293, -0.588559926, 0, 0},
                              { -0.332615912, -0.849614799, 0, 0},
                              { 0.306673586, -0.140199706, 0, 0},
                              { 0.114831701, 0.374455, 0, 0},
                              { -0.0388568006, 0.807132900, 0, 0},
                              { 0.410288513, 0.696029484, 0, 0},
                              { 0.556387722, 0.337537706, 0, 0},
                              { -0.0178657603, -0.887376487, 0, 0},
                              { 0.234991, -0.455843806, 0, 0},
                              { 0.620677471, -0.155100495, 0, 0},
                              { 0.664064229, -0.569142699, 0, 0},
                              { 0.731272578, 0.583016813, 0, 0},
                              { 0.887970686, 0.0571521297, 0, 0},
                              { 0.312829614, -0.830803, 0, 0},
                              { 0.868976414, -0.339797288, 0, 0} }
dcl_constantbuffer cb0[72], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[24], 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_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_texture3d (float,float,float,float) t4
dcl_resource_texturecube (float,float,float,float) t5
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyz
dcl_output o0.xyzw
dcl_temps 12
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r10.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 98c68cf6def34560-ps.txt

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

add r0.xyz, -v3.xyzx, cb2[0].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r0.xyzx
add r2.xyz, -v3.xyzx, r11.xyzx
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r1.w, r1.w
mul r3.xyz, r1.wwww, r2.xyzx
sample r4.xyzw, v1.xyxx, t0.xyzw, s4
sample r5.xyzw, v1.xyxx, t1.xyzw, s5
mul r5.yzw, v3.yyyy, cb0[69].xxyz
mad r5.yzw, cb0[68].xxyz, v3.xxxx, r5.yyzw
mad r5.yzw, cb0[70].xxyz, v3.zzzz, r5.yyzw
add r5.yzw, r5.yyzw, cb0[71].xxyz
mov r6.x, cb4[9].z
mov r6.y, cb4[10].z
mov r6.z, cb4[11].z
dp3 r1.w, r2.xyzx, r6.xyzx
add r2.xyz, v3.xyzx, -cb3[25].xyzx
dp3 r2.x, r2.xyzx, r2.xyzx
sqrt r2.x, r2.x
add r2.x, -r1.w, r2.x
mad r1.w, cb3[25].w, r2.x, r1.w
mad_sat r1.w, r1.w, cb3[24].z, cb3[24].w
eq r2.x, cb5[0].x, l(1.000000)
if_nz r2.x
  eq r2.x, cb5[0].y, l(1.000000)
  mul r2.yzw, v3.yyyy, cb5[2].xxyz
  mad r2.yzw, cb5[1].xxyz, v3.xxxx, r2.yyzw
  mad r2.yzw, cb5[3].xxyz, v3.zzzz, r2.yyzw
  add r2.yzw, r2.yyzw, cb5[4].xxyz
  movc r2.xyz, r2.xxxx, r2.yzwy, v3.xyzx
  add r2.xyz, r2.xyzx, -cb5[6].xyzx
  mul r2.yzw, r2.xxyz, cb5[5].xxyz
  mad r2.y, r2.y, l(0.250000), l(0.750000)
  mad r3.w, cb5[0].z, l(0.500000), l(0.750000)
  max r2.x, r2.y, r3.w
  sample r2.xyzw, r2.xzwx, t4.xyzw, s0
else
  mov r2.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r2.x, r2.xyzw, cb2[45].xyzw
add r2.yzw, v3.xxyz, -cb2[1].xxyz
dp3 r3.w, r2.yzwy, r2.yzwy
sqrt r3.w, r3.w
mul r6.xyz, v3.yyyy, cb4[18].xywx
mad r6.xyz, cb4[17].xywx, v3.xxxx, r6.xyzx
mad r6.xyz, cb4[19].xywx, v3.zzzz, r6.xyzx
add r6.xyz, r6.xyzx, cb4[20].xywx
mul r7.xz, r6.xxzx, l(0.500000, 0.000000, 0.500000, 0.000000)
mul r6.x, r6.y, cb1[5].x
mul r7.w, r6.x, l(0.500000)
add r6.xy, r7.zzzz, r7.xwxx
div r6.xy, r6.xyxx, r6.zzzz
sample r6.xyzw, r6.xyxx, t2.xyzw, s1
mul r7.xyz, r6.xyzx, l(45.543201, 12.989800, 78.233002, 0.000000)
mad r6.xyz, r6.zxyz, l(12.989800, 78.233002, 45.543201, 0.000000), -r7.xyzx
sincos r6.xyz, null, r6.xyzx
mul r6.xyz, r6.xyzx, l(43758.546875, 43758.546875, 43758.546875, 0.000000)
frc r6.xyz, r6.xyzx
mad r6.xyz, r6.xyzx, l(10.000000, 10.000000, 10.000000, 0.000000), l(0.000100, 0.000100, 0.000100, 0.000000)
mul r7.xyz, r2.wyzw, r6.xyzx
mad r6.xyz, r2.zwyz, r6.yzxy, -r7.xyzx
dp3 r6.w, r6.xyzx, r6.xyzx
rsq r6.w, r6.w
mul r6.xyz, r6.wwww, r6.xyzx
mul r7.xyz, r2.wyzw, r6.yzxy
mad r7.xyz, r2.zwyz, r6.zxyz, -r7.xyzx
dp3 r6.w, r7.xyzx, r7.xyzx
rsq r6.w, r6.w
mul r7.xyz, r6.wwww, r7.xyzx
add r6.w, -cb3[24].x, l(1.000000)
mul r6.w, r6.w, l(0.100000)
mul r6.xyz, r6.wwww, r6.xyzx
mul r7.xyz, r6.wwww, r7.xyzx
mul r6.w, cb2[1].w, l(0.015000)
mov r7.w, l(0)
mov r8.x, l(0)
loop
  itof r8.y, r8.x
  ge r8.y, r8.y, l(25.000000)
  breakc_nz r8.y
  mul r8.yzw, r7.xxyz, icb[r8.x + 0].yyyy
  mad r8.yzw, r6.xxyz, icb[r8.x + 0].xxxx, r8.yyzw
  add r8.yzw, r2.yyzw, r8.yyzw
  sample_l r9.xyzw, r8.yzwy, t5.xyzw, s2, l(0.000000)
  mad r8.y, r3.w, cb2[1].w, -r9.x
  div_sat r8.y, r8.y, r6.w
  add r8.y, -r8.y, l(1.000000)
  add r7.w, r7.w, r8.y
  iadd r8.x, r8.x, l(1)
endloop
mul r2.y, r7.w, l(0.040000)
mad r2.x, -r7.w, l(0.040000), r2.x
mad r1.w, r1.w, r2.x, r2.y
dp3 r2.x, r5.yzwy, r5.yzwy
sample r2.xyzw, r2.xxxx, t3.xyzw, s3
mul r1.w, r1.w, r2.x
mul r2.xyz, r1.wwww, cb0[2].xyzx
dp3 r1.w, v2.xyzx, v2.xyzx
rsq r1.w, r1.w
mul r5.yzw, r1.wwww, v2.xxyz
add r6.xyz, r4.xyzx, l(-0.040000, -0.040000, -0.040000, 0.000000)
mad r6.xyz, r5.xxxx, r6.xyzx, l(0.040000, 0.040000, 0.040000, 0.000000)
mad r1.w, -r5.x, l(0.960000), l(0.960000)
mul r4.xyz, r1.wwww, r4.xyzx
add r1.w, -r4.w, l(1.000000)
mad r0.xyz, r0.xyzx, r0.wwww, r3.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, r5.yzwy, r3.xyzx
dp3_sat r2.w, r5.yzwy, r1.xyzx
dp3_sat r3.x, r5.yzwy, r0.xyzx
dp3_sat r0.x, r1.xyzx, r0.xyzx
mul r0.y, r0.x, r0.x
dp2 r0.y, r0.yyyy, r1.wwww
add r0.y, r0.y, l(-0.500000)
add r0.z, -r2.w, l(1.000000)
mul r1.x, r0.z, r0.z
mul r1.x, r1.x, r1.x
mul r0.z, r0.z, r1.x
mad r0.z, r0.y, r0.z, l(1.000000)
add r1.x, -|r0.w|, l(1.000000)
mul r1.y, r1.x, r1.x
mul r1.y, r1.y, r1.y
mul r1.x, r1.x, r1.y
mad r0.y, r0.y, r1.x, l(1.000000)
mul r0.y, r0.y, r0.z
mul r0.z, r1.w, r1.w
mad r1.x, -r1.w, r1.w, l(1.000000)
mad r1.y, |r0.w|, r1.x, r0.z
mad r1.x, r2.w, r1.x, r0.z
mul r0.w, |r0.w|, r1.x
mad r0.w, r2.w, r1.y, r0.w
add r0.w, r0.w, l(0.000010)
div r0.w, l(0.500000), r0.w
mul r0.z, r0.z, r0.z
mad r1.x, r3.x, r0.z, -r3.x
mad r1.x, r1.x, r3.x, l(1.000000)
mul r0.z, r0.z, l(0.318309873)
mad r1.x, r1.x, r1.x, l(1.000000012E-007)
div r0.z, r0.z, r1.x
mul r0.z, r0.z, r0.w
mul r0.z, r0.z, l(3.14159274)
mul r0.yz, r2.wwww, r0.yyzy
max r0.z, r0.z, l(0.000000)
dp3 r0.w, r6.xyzx, r6.xyzx
ne r0.w, r0.w, l(0.000000)
and r0.w, r0.w, l(0x3f800000)
mul r0.z, r0.w, r0.z
mul r1.xyz, r0.yyyy, r2.xyzx
mul r0.yzw, r2.xxyz, r0.zzzz
add r0.x, -r0.x, l(1.000000)
mul r1.w, r0.x, r0.x
mul r1.w, r1.w, r1.w
mul r0.x, r0.x, r1.w
add r2.xyz, -r6.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r2.xyz, r2.xyzx, r0.xxxx, r6.xyzx
mul r0.xyz, r0.yzwy, r2.xyzx
mad o0.xyz, r4.xyzx, r1.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used