10
0

ViveMovementBorder.shader 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Custom/Vive Movement Border"
  3. {
  4. Properties
  5. {
  6. _MainTex ("Texture", 2D) = "white" {}
  7. _Color ("Color", Color) = (1, 1, 1, 1)
  8. _BackColor ("Color Behind Objects", Color) = (0.5,0.5,0.5,1)
  9. _Alpha ("Total Alpha (Transparency)", Float) = 1.0
  10. }
  11. SubShader
  12. {
  13. Tags{ "Queue" = "Overlay" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  14. CGINCLUDE
  15. #pragma vertex vert
  16. #pragma fragment frag
  17. #include "UnityCG.cginc"
  18. struct appdata
  19. {
  20. float4 vertex : POSITION;
  21. float2 uv : TEXCOORD0;
  22. };
  23. struct v2f
  24. {
  25. float2 uv : TEXCOORD0;
  26. float4 vertex : SV_POSITION;
  27. };
  28. sampler2D _MainTex;
  29. fixed4 _Color;
  30. fixed4 _BackColor;
  31. fixed _Alpha;
  32. v2f vert(appdata v)
  33. {
  34. v2f o;
  35. o.vertex = UnityObjectToClipPos(v.vertex);
  36. o.uv = v.uv;
  37. return o;
  38. }
  39. ENDCG
  40. Pass
  41. {
  42. Blend SrcAlpha OneMinusSrcAlpha
  43. ZTest Greater
  44. ZWrite Off
  45. CGPROGRAM
  46. fixed4 frag (v2f i) : SV_Target
  47. {
  48. fixed4 col = tex2D(_MainTex, i.uv) * _BackColor;
  49. col.a *= _Alpha;
  50. return col;
  51. }
  52. ENDCG
  53. }
  54. Pass
  55. {
  56. Blend SrcAlpha OneMinusSrcAlpha
  57. ZTest LEqual
  58. ZWrite Off
  59. CGPROGRAM
  60. fixed4 frag(v2f i) : SV_Target
  61. {
  62. fixed4 col = tex2D(_MainTex, i.uv) * _Color;
  63. col.a *= _Alpha;
  64. return col;
  65. }
  66. ENDCG
  67. }
  68. }
  69. }