// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed f99666dcf0874489-ps.txt
// 3DMigoto: f99666dcf0874489 |    Unity headers extracted from Nature_Terrain_Diffuse
//    Shader "Nature/Terrain/Diffuse" {
//      Fallback "Diffuse"
//      SubShader 1/2 {
//        Tags { "QUEUE"="Geometry-99" "RenderType"="Opaque" }
//        Pass 1/6 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDBASE" "QUEUE"="Geometry-99" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Nature_Terrain_Diffuse:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 60 13 2
//   undeciphered1a: 5
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "_TERRAIN_NORMAL_MAP" }
//   undeciphered2: 1 13 6 12 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1168
//   Vector 16 [unity_DynamicLightmap_HDR]
//   Vector 32 [_LightColor0]
//   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 "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_Control] 2D 3
//   SetTexture 1 [_Splat0] 2D 4
//   SetTexture 2 [_Splat1] 2D 5
//   SetTexture 3 [_Splat2] 2D 6
//   SetTexture 4 [_Splat3] 2D 7
//   SetTexture 5 [_Normal0] 2D 8
//   SetTexture 6 [_Normal1] 2D 9
//   SetTexture 7 [_Normal2] 2D 10
//   SetTexture 8 [_Normal3] 2D 11
//   SetTexture 9 [_ShadowMapTexture] 2D 2
//   SetTexture 10 [unity_DynamicLightmap] 2D 0
//   SetTexture 11 [unity_DynamicDirectionality] 2D -1
//   SetTexture 12 [unity_ProbeVolumeSH] 3D 1
//   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 18:04:35 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   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xy          6     NONE   float   xy
// TEXCOORD                 7   xyzw        7     NONE   float   xy w
// TEXCOORD                 8   xyzw        8     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[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_sampler s7, mode_default
dcl_sampler s8, mode_default
dcl_sampler s9, mode_default
dcl_sampler s10, mode_default
dcl_sampler s11, 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_texture2d (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t8
dcl_resource_texture2d (float,float,float,float) t9
dcl_resource_texture2d (float,float,float,float) t10
dcl_resource_texture2d (float,float,float,float) t11
dcl_resource_texture3d (float,float,float,float) t12
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.xy
dcl_input_ps linear v7.xyw
dcl_input_ps linear v8.zw
dcl_output o0.xyzw
dcl_temps 7
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r5.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 f99666dcf0874489-ps.txt

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

sample r0.xyzw, v6.xyxx, t0.xyzw, s3
dp4 r1.x, r0.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
add r1.y, r1.x, l(0.001000)
div r0.xyzw, r0.xyzw, r1.yyyy
sample r2.xyzw, v1.xyxx, t1.xyzw, s4
sample r3.xyzw, v1.zwzz, t2.xyzw, s5
mul r1.yzw, r0.yyyy, r3.xxyz
mad r1.yzw, r0.xxxx, r2.xxyz, r1.yyzw
sample r2.xyzw, v2.xyxx, t3.xyzw, s6
mad r1.yzw, r0.zzzz, r2.xxyz, r1.yyzw
sample r2.xyzw, v2.zwzz, t4.xyzw, s7
mad r1.yzw, r0.wwww, r2.xxyz, r1.yyzw
sample r2.xyzw, v1.xyxx, t5.xyzw, s8
sample r3.xyzw, v1.zwzz, t6.xyzw, s9
mul r2.xz, r0.yyyy, r3.wwyw
mad r0.xy, r0.xxxx, r2.wyww, r2.xzxx
sample r2.xyzw, v2.xyxx, t7.xyzw, s10
mad r0.xy, r0.zzzz, r2.wyww, r0.xyxx
sample r2.xyzw, v2.zwzz, t8.xyzw, s11
mad r0.xy, r0.wwww, r2.wyww, r0.xyxx
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r0.w, r0.xyxx, r0.xyxx
min r0.w, r0.w, l(1.000000)
add r0.w, -r0.w, l(1.000000)
sqrt r0.z, r0.w
mov r2.y, v3.w
mov r2.z, v4.w
mov r2.w, v5.w
add r3.xyz, -r2.yzwy, r6.xyzx
mov r4.x, cb4[9].z
mov r4.y, cb4[10].z
mov r4.z, cb4[11].z
dp3 r0.w, r3.xyzx, r4.xyzx
add r3.xyz, r2.yzwy, -cb3[25].xyzx
dp3 r2.x, r3.xyzx, r3.xyzx
sqrt r2.x, r2.x
add r2.x, -r0.w, r2.x
mad r0.w, cb3[25].w, r2.x, r0.w
mad_sat r0.w, r0.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 r3.xyz, v4.wwww, cb5[2].xyzx
  mad r3.xyz, cb5[1].xyzx, v3.wwww, r3.xyzx
  mad r3.xyz, cb5[3].xyzx, v5.wwww, r3.xyzx
  add r3.xyz, r3.xyzx, cb5[4].xyzx
  movc r2.xyz, r2.xxxx, r3.xyzx, r2.yzwy
  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.x, cb5[0].z, l(0.500000), l(0.750000)
  max r2.x, r2.y, r3.x
  sample r2.xyzw, r2.xzwx, t12.xyzw, s1
else
  mov r2.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r2.x, r2.xyzw, cb2[45].xyzw
div r2.yz, v7.xxyx, v7.wwww
sample r3.xyzw, r2.yzyy, t9.xyzw, s2
add r2.x, r2.x, -r3.x
mad r0.w, r0.w, r2.x, r3.x
dp3 r2.x, v3.xyzx, r0.xyzx
dp3 r2.y, v4.xyzx, r0.xyzx
dp3 r2.z, v5.xyzx, r0.xyzx
mul r0.xyz, r0.wwww, cb0[2].xyzx
sample r3.xyzw, v8.zwzz, t10.xyzw, s0
mul r0.w, r3.w, cb0[1].x
mul r3.xyz, r3.xyzx, r0.wwww
log r3.xyz, r3.xyzx
mul r3.xyz, r3.xyzx, cb0[1].yyyy
exp r3.xyz, r3.xyzx
sample r4.xyzw, v8.zwzz, t11.xyzw, s0
add r4.xyz, r4.xyzx, l(-0.500000, -0.500000, -0.500000, 0.000000)
dp3 r0.w, r2.xyzx, r4.xyzx
add r0.w, r0.w, l(0.500000)
mul r3.xyz, r0.wwww, r3.xyzx
max r0.w, r4.w, l(0.000100)
div r3.xyz, r3.xyzx, r0.wwww
dp3 r0.w, r2.xyzx, cb2[0].xyzx
max r0.w, r0.w, l(0.000000)
mul r0.xyz, r0.xyzx, r1.yzwy
mul r1.yzw, r1.yyzw, r3.xxyz
mad r0.xyz, r0.xyzx, r0.wwww, r1.yzwy
mul o0.xyz, r1.xxxx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used