BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / SampleFramework / Usage / DistanceGrab / Materials / CrosshairZCheat.shader

CrosshairZCheat.shader

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
CrosshairZCheat.shader 1.2 KiB Download Raw
1// Small tweak to a basic unlit shader to cheat crosshair depth to render on top of targets.
2Shader "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
10 SubShader
11 {
12 Tags { "Queue" = "Transparent" }
13 Cull Off
14 Lighting Off
15 ZTest Off
16 Blend SrcAlpha OneMinusSrcAlpha
17
18 Pass
19 {
20 CGPROGRAM
21 #pragma vertex vert
22 #pragma fragment frag
23
24 #include "UnityCG.cginc"
25
26 struct appdata
27 {
28 float4 vertex : POSITION;
29 float2 texcoord : TEXCOORD0;
30 fixed4 color : COLOR;
31 };
32
33 struct v2f
34 {
35 float4 vertex : SV_POSITION;
36 half2 texcoord : TEXCOORD0;
37 fixed4 color : COLOR;
38 };
39
40 sampler2D _MainTex;
41 float4 _MainTex_ST;
42 fixed4 _Color;
43
44 v2f vert (appdata v)
45 {
46 // Cheat the post-mvp transformed z towards the camera.
47 v2f o;
48 o.vertex = UnityObjectToClipPos(v.vertex);
49 o.vertex.z -= 0.01;
50 o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
51 o.color = v.color;
52 return o;
53 }
54
55 fixed4 frag (v2f i) : COLOR
56 {
57 fixed4 col = tex2D(_MainTex, i.texcoord) * i.color * _Color;
58 return col;
59 }
60 ENDCG
61 }
62 }
63}
64