ViveMovementGrid.shader 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Custom/Vive Movement Grid"
  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. _TexScale ("Texture Scale", Float) = 1.0
  11. }
  12. SubShader
  13. {
  14. Tags{ "Queue" = "Overlay" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  15. CGINCLUDE
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #include "UnityCG.cginc"
  19. struct appdata
  20. {
  21. float4 vertex : POSITION;
  22. };
  23. struct v2f
  24. {
  25. float2 uv : TEXCOORD0;
  26. float4 vertex : SV_POSITION;
  27. };
  28. sampler2D _MainTex;
  29. float _TexScale;
  30. fixed4 _Color;
  31. fixed4 _BackColor;
  32. fixed _Alpha;
  33. v2f vert(appdata v)
  34. {
  35. v2f o;
  36. o.vertex = UnityObjectToClipPos(v.vertex);
  37. float3 worldPos = mul(unity_ObjectToWorld, v.vertex);
  38. o.uv = worldPos.xz / _TexScale;
  39. return o;
  40. }
  41. ENDCG
  42. Pass
  43. {
  44. Blend SrcAlpha OneMinusSrcAlpha
  45. ZTest Greater
  46. ZWrite Off
  47. CGPROGRAM
  48. fixed4 frag (v2f i) : SV_Target
  49. {
  50. fixed4 col = tex2D(_MainTex, i.uv) * _BackColor;
  51. col.a *= _Alpha;
  52. return col;
  53. }
  54. ENDCG
  55. }
  56. Pass
  57. {
  58. Blend SrcAlpha OneMinusSrcAlpha
  59. ZTest LEqual
  60. ZWrite Off
  61. CGPROGRAM
  62. fixed4 frag(v2f i) : SV_Target
  63. {
  64. fixed4 col = tex2D(_MainTex, i.uv) * _Color;
  65. col.a *= _Alpha;
  66. return col;
  67. }
  68. ENDCG
  69. }
  70. }
  71. }