SeeThru.shader 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: Used for objects that can be seen through objects in front of them
  4. //
  5. //=============================================================================
  6. // UNITY_SHADER_NO_UPGRADE
  7. Shader "Valve/VR/SeeThru"
  8. {
  9. Properties
  10. {
  11. _Color( "Color", Color ) = ( 1, 1, 1, 1 )
  12. }
  13. SubShader
  14. {
  15. Tags{ "Queue" = "Geometry+1" "RenderType" = "Transparent" }
  16. LOD 100
  17. Pass
  18. {
  19. // Render State ---------------------------------------------------------------------------------------------------------------------------------------------
  20. Blend SrcAlpha OneMinusSrcAlpha // Alpha blending
  21. Cull Off
  22. ZWrite Off
  23. ZTest Greater
  24. Stencil
  25. {
  26. Ref 2
  27. Comp notequal
  28. Pass replace
  29. Fail keep
  30. }
  31. CGPROGRAM
  32. #pragma target 5.0
  33. #pragma only_renderers d3d11 vulkan glcore
  34. #pragma exclude_renderers gles
  35. #pragma vertex MainVS
  36. #pragma fragment MainPS
  37. // Includes -------------------------------------------------------------------------------------------------------------------------------------------------
  38. #include "UnityCG.cginc"
  39. // Structs --------------------------------------------------------------------------------------------------------------------------------------------------
  40. struct VertexInput
  41. {
  42. float4 vertex : POSITION;
  43. float2 uv : TEXCOORD0;
  44. };
  45. struct VertexOutput
  46. {
  47. float2 uv : TEXCOORD0;
  48. float4 vertex : SV_POSITION;
  49. };
  50. // Globals --------------------------------------------------------------------------------------------------------------------------------------------------
  51. sampler2D _MainTex;
  52. float4 _MainTex_ST;
  53. float4 _Color;
  54. // MainVs ---------------------------------------------------------------------------------------------------------------------------------------------------
  55. VertexOutput MainVS( VertexInput i )
  56. {
  57. VertexOutput o;
  58. #if UNITY_VERSION >= 540
  59. o.vertex = UnityObjectToClipPos(i.vertex);
  60. #else
  61. o.vertex = mul(UNITY_MATRIX_MVP, i.vertex);
  62. #endif
  63. o.uv = TRANSFORM_TEX( i.uv, _MainTex );
  64. return o;
  65. }
  66. // MainPs ---------------------------------------------------------------------------------------------------------------------------------------------------
  67. float4 MainPS( VertexOutput i ) : SV_Target
  68. {
  69. float4 vColor = _Color.rgba;
  70. return vColor.rgba;
  71. }
  72. ENDCG
  73. }
  74. }
  75. }