File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ //Shader uses screen-space partial derivatives, works the best with terrain meshes.
2
+
3
+ Shader "Wireframe"
4
+ {
5
+ Properties
6
+ {
7
+ [Header (Settings)] [Toggle ] _transparency ( "Transparency" , Float ) = 1
8
+ }
9
+ Subshader
10
+ {
11
+ Pass
12
+ {
13
+ Cull Off
14
+ CGPROGRAM
15
+ #pragma vertex vertex_shader
16
+ #pragma fragment pixel_shader
17
+ #pragma target 3.0
18
+
19
+ struct structure
20
+ {
21
+ float4 gl_Position : SV_POSITION ;
22
+ float3 vertex : TEXCOORD0 ;
23
+ };
24
+
25
+ float _transparency;
26
+
27
+ structure vertex_shader (float4 vertex:POSITION )
28
+ {
29
+ structure vs;
30
+ vs.gl_Position = UnityObjectToClipPos (vertex);
31
+ vs.vertex = vertex;
32
+ return vs;
33
+ }
34
+
35
+ float4 pixel_shader (structure ps) : COLOR
36
+ {
37
+ float2 p = ps.vertex.xz;
38
+ float2 g = abs (frac (p - 0.5 ) - 0.5 ) / fwidth (p);
39
+ float s = min (g.x, g.y);
40
+ float4 c = float4 (s,s,s, 1.0 );
41
+ if (c.r<1.0 )
42
+ return 1.0 -c;
43
+ else
44
+ {
45
+ if (_transparency==1 ) discard ;
46
+ return 0 ;
47
+ }
48
+ }
49
+ ENDCG
50
+ }
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments