ControllerButtonHints.shader 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. // UNITY_SHADER_NO_UPGRADE
  7. Shader "Valve/VR/ControllerButtonHints"
  8. {
  9. Properties
  10. {
  11. _MainTex ( "Texture", 2D ) = "white" {}
  12. _Color( "Color", Color ) = ( 1, 1, 1, 1 )
  13. _SceneTint( "SceneTint", Color ) = ( 1, 1, 1, 1 )
  14. }
  15. SubShader
  16. {
  17. Tags{ "Queue" = "Transparent+1" "RenderType" = "Transparent" }
  18. LOD 100
  19. Pass
  20. {
  21. // Render State ---------------------------------------------------------------------------------------------------------------------------------------------
  22. Blend Zero SrcColor // Alpha blending
  23. Cull Off
  24. ZWrite Off
  25. ZTest Off
  26. Stencil
  27. {
  28. Ref 2
  29. Comp notequal
  30. Pass replace
  31. Fail keep
  32. }
  33. CGPROGRAM
  34. #pragma vertex MainVS
  35. #pragma fragment MainPS
  36. // Includes -------------------------------------------------------------------------------------------------------------------------------------------------
  37. #include "UnityCG.cginc"
  38. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  39. struct VertexInput
  40. {
  41. float4 vertex : POSITION;
  42. };
  43. struct VertexOutput
  44. {
  45. float4 vertex : SV_POSITION;
  46. };
  47. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  48. float4 _SceneTint;
  49. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  50. VertexOutput MainVS( VertexInput i )
  51. {
  52. VertexOutput o;
  53. #if UNITY_VERSION >= 540
  54. o.vertex = UnityObjectToClipPos(i.vertex);
  55. #else
  56. o.vertex = mul(UNITY_MATRIX_MVP, i.vertex);
  57. #endif
  58. return o;
  59. }
  60. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  61. float4 MainPS( VertexOutput i ) : SV_Target
  62. {
  63. return _SceneTint.rgba;
  64. }
  65. ENDCG
  66. }
  67. Pass
  68. {
  69. // Render State ---------------------------------------------------------------------------------------------------------------------------------------------
  70. Blend SrcAlpha OneMinusSrcAlpha // Alpha blending
  71. Cull Off
  72. ZWrite Off
  73. ZTest Always
  74. CGPROGRAM
  75. #pragma vertex MainVS
  76. #pragma fragment MainPS
  77. // Includes -------------------------------------------------------------------------------------------------------------------------------------------------
  78. #include "UnityCG.cginc"
  79. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  80. struct VertexInput
  81. {
  82. float4 vertex : POSITION;
  83. float2 uv : TEXCOORD0;
  84. };
  85. struct VertexOutput
  86. {
  87. float2 uv : TEXCOORD0;
  88. float4 vertex : SV_POSITION;
  89. };
  90. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  91. sampler2D _MainTex;
  92. float4 _MainTex_ST;
  93. float4 _Color;
  94. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  95. VertexOutput MainVS( VertexInput i )
  96. {
  97. VertexOutput o;
  98. #if UNITY_VERSION >= 540
  99. o.vertex = UnityObjectToClipPos(i.vertex);
  100. #else
  101. o.vertex = mul(UNITY_MATRIX_MVP, i.vertex);
  102. #endif
  103. o.uv = TRANSFORM_TEX( i.uv, _MainTex );
  104. return o;
  105. }
  106. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  107. float4 MainPS( VertexOutput i ) : SV_Target
  108. {
  109. float4 vColor;
  110. vColor.rgb = lerp( tex2D(_MainTex, i.uv).rgb, _Color.rgb, _Color.a );
  111. vColor.a = _Color.a;
  112. return vColor.rgba;
  113. }
  114. ENDCG
  115. }
  116. }
  117. }