1
0

SteamVR_Fade.shader 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. // UNITY_SHADER_NO_UPGRADE
  3. Shader "Custom/SteamVR_Fade"
  4. {
  5. SubShader
  6. {
  7. Pass
  8. {
  9. Blend SrcAlpha OneMinusSrcAlpha
  10. ZTest Always
  11. Cull Off
  12. ZWrite Off
  13. CGPROGRAM
  14. #pragma vertex MainVS
  15. #pragma fragment MainPS
  16. // Includes -------------------------------------------------------------------------------------------------------------------------------------------------
  17. #include "UnityCG.cginc"
  18. #if UNITY_VERSION >= 201810
  19. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  20. struct VertexInput
  21. {
  22. float4 vertex : POSITION;
  23. UNITY_VERTEX_INPUT_INSTANCE_ID
  24. };
  25. struct VertexOutput
  26. {
  27. float4 vertex : SV_POSITION;
  28. UNITY_VERTEX_OUTPUT_STEREO
  29. };
  30. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  31. UNITY_INSTANCING_BUFFER_START( Props )
  32. UNITY_DEFINE_INSTANCED_PROP( float4, fadeColor )
  33. UNITY_INSTANCING_BUFFER_END( Props )
  34. VertexOutput MainVS( VertexInput i )
  35. {
  36. VertexOutput o;
  37. UNITY_SETUP_INSTANCE_ID( i );
  38. UNITY_INITIALIZE_OUTPUT( VertexOutput, o );
  39. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
  40. o.vertex = i.vertex;
  41. return o;
  42. }
  43. float4 MainPS( VertexOutput i ) : SV_Target
  44. {
  45. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( i );
  46. return UNITY_ACCESS_INSTANCED_PROP( Props, fadeColor.rgba );
  47. }
  48. #else
  49. float4 fadeColor;
  50. float4 MainVS( float4 vertex : POSITION ) : SV_POSITION
  51. {
  52. return vertex.xyzw;
  53. }
  54. float4 MainPS() : SV_Target
  55. {
  56. return fadeColor.rgba;
  57. }
  58. #endif
  59. ENDCG
  60. }
  61. }
  62. }