Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.0 KiB

  1. // UNITY_SHADER_NO_UPGRADE
  2. Shader "UI/Overlay"
  3. {
  4. Properties
  5. {
  6. [PerRendererData] _MainTex("Font Texture", 2D) = "white" {}
  7. _Color("Tint", Color) = (1,1,1,1)
  8. _StencilComp("Stencil Comparison", Float) = 8
  9. _Stencil("Stencil ID", Float) = 0
  10. _StencilOp("Stencil Operation", Float) = 0
  11. _StencilWriteMask("Stencil Write Mask", Float) = 255
  12. _StencilReadMask("Stencil Read Mask", Float) = 255
  13. _ColorMask("Color Mask", Float) = 15
  14. }
  15. SubShader
  16. {
  17. LOD 100
  18. Tags
  19. {
  20. "Queue" = "Transparent"
  21. "IgnoreProjector" = "True"
  22. "RenderType" = "Transparent"
  23. "PreviewType" = "Plane"
  24. "CanUseSpriteAtlas" = "True"
  25. }
  26. Stencil
  27. {
  28. Ref[_Stencil]
  29. Comp[_StencilComp]
  30. Pass[_StencilOp]
  31. ReadMask[_StencilReadMask]
  32. WriteMask[_StencilWriteMask]
  33. }
  34. Cull Back
  35. Lighting Off
  36. ZWrite Off
  37. ZTest[unity_GUIZTestMode]
  38. Offset -1, -1
  39. Blend SrcAlpha OneMinusSrcAlpha
  40. ColorMask[_ColorMask]
  41. Pass
  42. {
  43. CGPROGRAM
  44. #pragma vertex vert
  45. #pragma fragment frag
  46. #include "UnityCG.cginc"
  47. #include "UnityUI.cginc"
  48. struct appdata_t
  49. {
  50. float4 vertex : POSITION;
  51. float2 texcoord : TEXCOORD0;
  52. float4 color : COLOR;
  53. };
  54. struct v2f
  55. {
  56. float4 vertex : SV_POSITION;
  57. half2 texcoord : TEXCOORD0;
  58. fixed4 color : COLOR;
  59. };
  60. sampler2D _MainTex;
  61. float4 _MainTex_ST;
  62. fixed4 _Color;
  63. fixed4 _TextureSampleAdd;
  64. v2f vert(appdata_t v)
  65. {
  66. v2f o;
  67. #if UNITY_VERSION >= 560
  68. o.vertex = UnityObjectToClipPos(v.vertex);
  69. #else
  70. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  71. #endif
  72. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  73. o.color = v.color * _Color;
  74. #ifdef UNITY_HALF_TEXEL_OFFSET
  75. o.vertex.xy += (_ScreenParams.zw - 1.0)*float2(-1,1);
  76. #endif
  77. return o;
  78. }
  79. fixed4 frag(v2f i) : SV_Target
  80. {
  81. fixed4 col = (tex2D(_MainTex, i.texcoord) + _TextureSampleAdd) * i.color;
  82. clip(col.a - 0.01);
  83. return col;
  84. }
  85. ENDCG
  86. }
  87. }
  88. }