Skip to content

Commit 54a99cd

Browse files
committed
Add patch for Amazing Wireframe Shader normals
1 parent 368a071 commit 54a99cd

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ diff -urwb Assets/UnityTestTools/Examples/UnitTestExamples/Editor/SampleTests.cs
3333
```
3434

3535
* The Amazing Wireframe Shader (Note that this takes 30 minutes to compile on a 6700k i7 with 32 gb of ram. I have no idea why. It's a good asset otherwise.)
36+
Note that I've included a patch to The Amazing Wireframe Shader that adds face normals. To install:
37+
```bash
38+
patch -p2 --binary < VacuumShaders_Add_Face_Normals.patch
39+
```
3640
* TheLabRenderer (I'm pretty sure we're not using this, but it may be required by the scene)
3741
* Free Sunset skybox (skyb1)
3842

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
diff -Nruwb '--exclude=*.unity' '--exclude=*.mat' '--exclude=*.anim' '--exclude=*.prefab' "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Diffuse.shader" "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Diffuse.shader"
2+
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Diffuse.shader" 2017-07-08 00:40:20.795537100 -0400
3+
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Diffuse.shader" 2017-04-17 10:37:04.014921000 -0400
4+
@@ -7,6 +7,11 @@
5+
{
6+
Properties
7+
{
8+
+//Wire Normal Options
9+
+_NColor("Color", color) = (0, 0, 0, 1)
10+
+_NHeight("Height", float) = 0.1
11+
+_NScale("Scale", float) = 0.01
12+
+
13+
//Tag
14+
[V_WIRE_Tag] _V_WIRE_Tag("", float) = 0
15+
16+
@@ -998,7 +1003,7 @@
17+
18+
}
19+
20+
-
21+
+UsePass "GeometryNormal/MAIN"
22+
23+
}
24+
25+
diff -Nruwb '--exclude=*.unity' '--exclude=*.mat' '--exclude=*.anim' '--exclude=*.prefab' "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader" "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader"
26+
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader" 1969-12-31 19:00:00.000000000 -0500
27+
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader" 2017-04-07 19:12:41.107563500 -0400
28+
@@ -0,0 +1,134 @@
29+
+Shader "GeometryNormal"
30+
+{
31+
+Properties
32+
+{
33+
+_NColor("Color", color) = (0, 1 ,0, 1)
34+
+_NHeight("Hight", float) = 0.1
35+
+_NScale("Scale", float) = 0.01
36+
+}
37+
+
38+
+SubShader
39+
+{
40+
+Tags { "RenderType"="Opaque" }
41+
+LOD 100
42+
+
43+
+Pass
44+
+{
45+
+Name "Main"
46+
+
47+
+CGPROGRAM
48+
+#pragma vertex vert
49+
+#pragma geometry geom
50+
+#pragma fragment frag
51+
+
52+
+#include "UnityCG.cginc"
53+
+#pragma target 4.6
54+
+
55+
+
56+
+struct appdata
57+
+{
58+
+float4 vertex : POSITION;
59+
+};
60+
+
61+
+struct v2f
62+
+{
63+
+float4 vertex : SV_POSITION;
64+
+float4 color : COLOR;
65+
+};
66+
+
67+
+
68+
+v2f vert (appdata v)
69+
+{
70+
+v2f o;
71+
+
72+
+o.vertex = v.vertex;
73+
+o.color = 1;
74+
+
75+
+return o;
76+
+}
77+
+
78+
+
79+
+fixed4 _NColor;
80+
+float _NHeight;
81+
+float _NScale;
82+
+
83+
+
84+
+[maxvertexcount(9)]
85+
+void geom(triangle v2f input[3], inout TriangleStream<v2f> triStream)
86+
+{
87+
+
88+
+float3 v0 = input[0].vertex.xyz;
89+
+float3 v1 = input[1].vertex.xyz;
90+
+float3 v2 = input[2].vertex.xyz;
91+
+
92+
+float3 centerPoint = (v0 + v1 + v2) / 3.0;
93+
+float3 normal = normalize(cross((v1 - v0), (v2 - v0)));
94+
+
95+
+
96+
+float3 heightPoint = centerPoint + normal * _NHeight;
97+
+
98+
+
99+
+float3 a = centerPoint + normalize(v0 - centerPoint) * _NScale;
100+
+float3 b = centerPoint + normalize(v1 - centerPoint) * _NScale;
101+
+float3 c = centerPoint + normalize(v2 - centerPoint) * _NScale;
102+
+
103+
+float4 A = UnityObjectToClipPos(a);
104+
+float4 B = UnityObjectToClipPos(b);
105+
+float4 C = UnityObjectToClipPos(c);
106+
+float4 HP = UnityObjectToClipPos(heightPoint);
107+
+
108+
+
109+
+v2f output;
110+
+output.color = _NColor; //float4(UnityObjectToWorldNormal(normal), 1);
111+
+
112+
+//#1/////////////////////////////////////////////////////
113+
+output.vertex = A;
114+
+triStream.Append(output);
115+
+
116+
+output.vertex = B;
117+
+triStream.Append(output);
118+
+
119+
+output.vertex = HP;
120+
+triStream.Append(output);
121+
+
122+
+
123+
+triStream.RestartStrip();
124+
+
125+
+
126+
+//#2/////////////////////////////////////////////////////
127+
+output.vertex = C;
128+
+triStream.Append(output);
129+
+
130+
+output.vertex = A;
131+
+triStream.Append(output);
132+
+
133+
+output.vertex = HP;
134+
+triStream.Append(output);
135+
+
136+
+
137+
+triStream.RestartStrip();
138+
+
139+
+
140+
+//#3/////////////////////////////////////////////////////
141+
+output.vertex = B;
142+
+triStream.Append(output);
143+
+
144+
+output.vertex = C;
145+
+triStream.Append(output);
146+
+
147+
+output.vertex = HP;
148+
+triStream.Append(output);
149+
+
150+
+
151+
+triStream.RestartStrip();
152+
+}
153+
+
154+
+
155+
+fixed4 frag (v2f i) : SV_Target
156+
+{
157+
+return i.color;
158+
+}
159+
+ENDCG
160+
+}
161+
+}
162+
+}
163+
diff -Nruwb '--exclude=*.unity' '--exclude=*.mat' '--exclude=*.anim' '--exclude=*.prefab' "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader.meta" "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader.meta"
164+
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader.meta" 1969-12-31 19:00:00.000000000 -0500
165+
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader.meta" 2017-04-07 19:15:57.728403500 -0400
166+
@@ -0,0 +1,9 @@
167+
+fileFormatVersion: 2
168+
+guid: acf591d6f40c25b45ac03bf36a833ddc
169+
+timeCreated: 1491606957
170+
+licenseType: Free
171+
+ShaderImporter:
172+
+ defaultTextures: []
173+
+ userData:
174+
+ assetBundleName:
175+
+ assetBundleVariant:
176+
diff -Nruwb '--exclude=*.unity' '--exclude=*.mat' '--exclude=*.anim' '--exclude=*.prefab' "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Transparent Simple Diffuse.shader" "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Transparent Simple Diffuse.shader"
177+
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Transparent Simple Diffuse.shader" 2017-07-08 00:59:51.230802900 -0400
178+
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Transparent Simple Diffuse.shader" 2017-04-17 10:37:04.084078100 -0400
179+
@@ -7,6 +7,11 @@
180+
{
181+
Properties
182+
{
183+
+//Wire Normal Options
184+
+_NColor("Color", color) = (0, 0, 0, 1)
185+
+_NHeight("Height", float) = 0.1
186+
+_NScale("Scale", float) = 0.01
187+
+
188+
//Tag
189+
[V_WIRE_Tag] _V_WIRE_Tag("", float) = 0
190+
191+
@@ -572,6 +577,8 @@
192+
193+
}
194+
195+
+UsePass "GeometryNormal/MAIN"
196+
+
197+
}
198+
199+
FallBack "Hidden/VacuumShaders/The Amazing Wireframe/Mobile/Vertex Lit/Transparent/Full"
200+
diff -Nruwb '--exclude=*.unity' '--exclude=*.mat' '--exclude=*.anim' '--exclude=*.prefab' "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders.meta" "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders.meta"
201+
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders.meta" 2017-04-02 04:30:06.000000000 -0400
202+
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders.meta" 2017-04-14 08:56:26.967531100 -0400
203+
@@ -1,5 +1,9 @@
204+
fileFormatVersion: 2
205+
-guid: 71a0d8c1b29021542af555a9f9bde133
206+
+guid: c6ccb5fd68f77f44ea6f589aab678547
207+
folderAsset: yes
208+
+timeCreated: 1492174586
209+
+licenseType: Free
210+
DefaultImporter:
211+
userData:
212+
+ assetBundleName:
213+
+ assetBundleVariant:

0 commit comments

Comments
 (0)