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.

64 lines
1.2 KiB

  1. // Small tweak to a basic unlit shader to cheat crosshair depth to render on top of targets.
  2. Shader "Custom/CrosshairZCheat"
  3. {
  4. Properties
  5. {
  6. _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
  7. _Color ("Main Color", Color) = (0.5,0.5,0.5,0.5)
  8. }
  9. SubShader
  10. {
  11. Tags { "Queue" = "Transparent" }
  12. Cull Off
  13. Lighting Off
  14. ZTest Off
  15. Blend SrcAlpha OneMinusSrcAlpha
  16. Pass
  17. {
  18. CGPROGRAM
  19. #pragma vertex vert
  20. #pragma fragment frag
  21. #include "UnityCG.cginc"
  22. struct appdata
  23. {
  24. float4 vertex : POSITION;
  25. float2 texcoord : TEXCOORD0;
  26. fixed4 color : COLOR;
  27. };
  28. struct v2f
  29. {
  30. float4 vertex : SV_POSITION;
  31. half2 texcoord : TEXCOORD0;
  32. fixed4 color : COLOR;
  33. };
  34. sampler2D _MainTex;
  35. float4 _MainTex_ST;
  36. fixed4 _Color;
  37. v2f vert (appdata v)
  38. {
  39. // Cheat the post-mvp transformed z towards the camera.
  40. v2f o;
  41. o.vertex = UnityObjectToClipPos(v.vertex);
  42. o.vertex.z -= 0.01;
  43. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  44. o.color = v.color;
  45. return o;
  46. }
  47. fixed4 frag (v2f i) : COLOR
  48. {
  49. fixed4 col = tex2D(_MainTex, i.texcoord) * i.color * _Color;
  50. return col;
  51. }
  52. ENDCG
  53. }
  54. }
  55. }