1
0

ControllerButtonHints.shader 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. #if UNITY_VERSION >= 201810
  39. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  40. struct VertexInput
  41. {
  42. float4 vertex : POSITION;
  43. UNITY_VERTEX_INPUT_INSTANCE_ID
  44. };
  45. struct VertexOutput
  46. {
  47. float4 vertex : SV_POSITION;
  48. UNITY_VERTEX_OUTPUT_STEREO
  49. };
  50. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  51. UNITY_INSTANCING_BUFFER_START( Props )
  52. UNITY_DEFINE_INSTANCED_PROP( float4, _SceneTint )
  53. UNITY_INSTANCING_BUFFER_END( Props )
  54. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  55. VertexOutput MainVS( VertexInput i )
  56. {
  57. VertexOutput o;
  58. UNITY_SETUP_INSTANCE_ID( i );
  59. UNITY_INITIALIZE_OUTPUT( VertexOutput, o );
  60. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
  61. o.vertex = UnityObjectToClipPos(i.vertex);
  62. return o;
  63. }
  64. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  65. float4 MainPS( VertexOutput i ) : SV_Target
  66. {
  67. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( i );
  68. return UNITY_ACCESS_INSTANCED_PROP( Props, _SceneTint.rgba );
  69. }
  70. #else
  71. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  72. struct VertexInput
  73. {
  74. float4 vertex : POSITION;
  75. };
  76. struct VertexOutput
  77. {
  78. float4 vertex : SV_POSITION;
  79. };
  80. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  81. float4 _SceneTint;
  82. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  83. VertexOutput MainVS( VertexInput i )
  84. {
  85. VertexOutput o;
  86. #if UNITY_VERSION >= 540
  87. o.vertex = UnityObjectToClipPos(i.vertex);
  88. #else
  89. o.vertex = mul(UNITY_MATRIX_MVP, i.vertex);
  90. #endif
  91. return o;
  92. }
  93. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  94. float4 MainPS( VertexOutput i ) : SV_Target
  95. {
  96. return _SceneTint.rgba;
  97. }
  98. #endif
  99. ENDCG
  100. }
  101. Pass
  102. {
  103. // Render State ---------------------------------------------------------------------------------------------------------------------------------------------
  104. Blend SrcAlpha OneMinusSrcAlpha // Alpha blending
  105. Cull Off
  106. ZWrite Off
  107. ZTest Always
  108. CGPROGRAM
  109. #pragma vertex MainVS
  110. #pragma fragment MainPS
  111. // Includes -------------------------------------------------------------------------------------------------------------------------------------------------
  112. #include "UnityCG.cginc"
  113. #if UNITY_VERSION >= 201810
  114. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  115. struct VertexInput
  116. {
  117. float4 vertex : POSITION;
  118. float2 uv : TEXCOORD0;
  119. UNITY_VERTEX_INPUT_INSTANCE_ID
  120. };
  121. struct VertexOutput
  122. {
  123. float2 uv : TEXCOORD0;
  124. float4 vertex : SV_POSITION;
  125. UNITY_VERTEX_OUTPUT_STEREO
  126. };
  127. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  128. UNITY_INSTANCING_BUFFER_START( Props )
  129. UNITY_DEFINE_INSTANCED_PROP( sampler2D, _MainTex )
  130. UNITY_DEFINE_INSTANCED_PROP( float4, _MainTex_ST )
  131. UNITY_DEFINE_INSTANCED_PROP( float4, _Color )
  132. UNITY_INSTANCING_BUFFER_END( Props )
  133. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  134. VertexOutput MainVS( VertexInput i )
  135. {
  136. VertexOutput o;
  137. UNITY_SETUP_INSTANCE_ID( i );
  138. UNITY_INITIALIZE_OUTPUT( VertexOutput, o );
  139. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
  140. o.vertex = UnityObjectToClipPos(i.vertex);
  141. o.uv = TRANSFORM_TEX( i.uv, UNITY_ACCESS_INSTANCED_PROP( Props, _MainTex ) );
  142. return o;
  143. }
  144. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  145. float4 MainPS( VertexOutput i ) : SV_Target
  146. {
  147. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( i );
  148. float4 vColor;
  149. vColor.rgb = lerp( tex2D( UNITY_ACCESS_INSTANCED_PROP( Props, _MainTex ), i.uv).rgb, UNITY_ACCESS_INSTANCED_PROP( Props, _Color.rgb ), UNITY_ACCESS_INSTANCED_PROP( Props, _Color.a ) );
  150. vColor.a = UNITY_ACCESS_INSTANCED_PROP( Props, _Color.a );
  151. return vColor.rgba;
  152. }
  153. #else
  154. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  155. struct VertexInput
  156. {
  157. float4 vertex : POSITION;
  158. float2 uv : TEXCOORD0;
  159. };
  160. struct VertexOutput
  161. {
  162. float2 uv : TEXCOORD0;
  163. float4 vertex : SV_POSITION;
  164. };
  165. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  166. sampler2D _MainTex;
  167. float4 _MainTex_ST;
  168. float4 _Color;
  169. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  170. VertexOutput MainVS( VertexInput i )
  171. {
  172. VertexOutput o;
  173. #if UNITY_VERSION >= 540
  174. o.vertex = UnityObjectToClipPos(i.vertex);
  175. #else
  176. o.vertex = mul(UNITY_MATRIX_MVP, i.vertex);
  177. #endif
  178. o.uv = TRANSFORM_TEX( i.uv, _MainTex );
  179. return o;
  180. }
  181. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  182. float4 MainPS( VertexOutput i ) : SV_Target
  183. {
  184. float4 vColor;
  185. vColor.rgb = lerp( tex2D(_MainTex, i.uv).rgb, _Color.rgb, _Color.a );
  186. vColor.a = _Color.a;
  187. return vColor.rgba;
  188. }
  189. #endif
  190. ENDCG
  191. }
  192. }
  193. }