// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 93b1a45bba3765f2-ps.txt
// 3DMigoto: 93b1a45bba3765f2 |    Unity headers extracted from 2DxFX_AL_GrassFX
//    Shader "2DxFX/AL/GrassFX" {
//      Fallback "Transparent/VertexLit"
//      SubShader 1/1 {
//        Tags { "CanUseSpriteAtlas"="true" "IGNOREPROJECTOR"="true" "PreviewType"="Plane" "RenderType"="TransparentCutout" }
//        Pass 1/7 {
//          Name "FORWARD"
//          Tags { "CanUseSpriteAtlas"="true" "IGNOREPROJECTOR"="true" "LIGHTMODE"="FORWARDBASE" "PreviewType"="Plane" "RenderType"="TransparentCutout" "SHADOWSUPPORT"="true" }
//          ZWrite [_Z]
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from 2DxFX_AL_GrassFX:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201708220 31 3 0
//   undeciphered1a: 4
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_ON" "LIGHTMAP_SHADOW_MIXING" }
//   undeciphered2: 1 3 5 3 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 128
//   Vector 0 [unity_Lightmap_HDR]
//   Vector 32 [_LightColor0]
//   Float 64 [_Distortion]
//   Float 68 [_Wind]
//   Float 76 [_Alpha]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 768
//   Vector 0 [_WorldSpaceLightPos0]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   ConstBuffer "UnityPerFrame" 368
//   Vector 352 [unity_ShadowColor]
//   Matrix 144 [unity_MatrixV]
//   SetTexture 0 [_MainTex] 2D 20
//   SetTexture 1 [_ShadowMapTexture] 2D 10
//   SetTexture 2 [unity_Lightmap] 2D 00
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//
// 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.2 on Mon Jan 14 18:56:39 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                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xy
// TEXCOORD                 5   xyzw        6     NONE   float   xy w
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[5], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[23], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, 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_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyzw
dcl_input_ps linear v5.xy
dcl_input_ps linear v6.xyw
dcl_output o0.xyzw
dcl_temps 6
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r4.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 93b1a45bba3765f2-ps.txt

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

div r0.x, v1.y, cb0[4].x
mad r0.x, r0.x, cb0[4].y, v1.x
ge r0.y, |r0.x|, -|r0.x|
frc r0.x, |r0.x|
movc r0.x, r0.y, r0.x, -r0.x
mov r0.y, v1.y
sample r0.xyzw, r0.xyxx, t0.xyzw, s2
mad r0.w, r0.w, v4.w, -cb0[4].w
mul r0.xyz, r0.xyzx, v4.xyzx
mul r0.xyz, r0.wwww, r0.xyzx
add r1.x, r0.w, l(-0.050000)
mov o0.w, r0.w
lt r0.w, r1.x, l(0.000000)
discard_nz r0.w
add r1.xyz, v3.xyzx, -cb3[25].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
sqrt r0.w, r0.w
add r1.xyz, -v3.xyzx, r5.xyzx
mov r2.x, cb4[9].z
mov r2.y, cb4[10].z
mov r2.z, cb4[11].z
dp3 r1.x, r1.xyzx, r2.xyzx
add r0.w, r0.w, -r1.x
mad r0.w, cb3[25].w, r0.w, r1.x
mad_sat r0.w, r0.w, cb3[24].z, cb3[24].w
div r1.xy, v6.xyxx, v6.wwww
sample r1.xyzw, r1.xyxx, t1.xyzw, s1
add_sat r0.w, r0.w, r1.x
add r0.w, -r0.w, l(1.000000)
dp3 r1.x, v2.xyzx, cb2[0].xyzx
max r1.x, r1.x, l(0.000000)
mul r0.w, r0.w, r1.x
sample r1.xyzw, v5.xyxx, t2.xyzw, s0
mul r1.w, r1.w, cb0[0].x
mul r2.xyz, r1.xyzx, r1.wwww
mad r3.xyz, -r0.wwww, cb0[2].xyzx, r2.xyzx
max r3.xyz, r3.xyzx, cb4[22].xyzx
mad r1.xyz, r1.wwww, r1.xyzx, -r3.xyzx
mad r1.xyz, cb3[24].xxxx, r1.xyzx, r3.xyzx
min r1.xyz, r1.xyzx, r2.xyzx
mul o0.xyz, r0.xyzx, r1.xyzx
ret
// Approximately 0 instruction slots used