-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathVacuumShaders_Add_Face_Normals.patch
186 lines (177 loc) · 5.18 KB
/
VacuumShaders_Add_Face_Normals.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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"
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Diffuse.shader" 2017-07-08 00:40:20.795537100 -0400
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Diffuse.shader" 2017-04-17 10:37:04.014921000 -0400
@@ -7,6 +7,11 @@
{
Properties
{
+ //Wire Normal Options
+ _NColor("Color", color) = (0, 0, 0, 1)
+ _NHeight("Height", float) = 0.1
+ _NScale("Scale", float) = 0.01
+
//Tag
[V_WIRE_Tag] _V_WIRE_Tag("", float) = 0
@@ -998,7 +1003,7 @@
}
-
+ UsePass "GeometryNormal/MAIN"
}
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"
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader" 1969-12-31 19:00:00.000000000 -0500
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/GeometryNormal.shader" 2017-04-07 19:12:41.107563500 -0400
@@ -0,0 +1,134 @@
+Shader "GeometryNormal"
+{
+ Properties
+ {
+ _NColor("Color", color) = (0, 1 ,0, 1)
+ _NHeight("Hight", float) = 0.1
+ _NScale("Scale", float) = 0.01
+ }
+
+ SubShader
+ {
+ Tags { "RenderType"="Opaque" }
+ LOD 100
+
+ Pass
+ {
+ Name "Main"
+
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma geometry geom
+ #pragma fragment frag
+
+ #include "UnityCG.cginc"
+ #pragma target 4.6
+
+
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ };
+
+ struct v2f
+ {
+ float4 vertex : SV_POSITION;
+ float4 color : COLOR;
+ };
+
+
+ v2f vert (appdata v)
+ {
+ v2f o;
+
+ o.vertex = v.vertex;
+ o.color = 1;
+
+ return o;
+ }
+
+
+ fixed4 _NColor;
+ float _NHeight;
+ float _NScale;
+
+
+ [maxvertexcount(9)]
+ void geom(triangle v2f input[3], inout TriangleStream<v2f> triStream)
+ {
+
+ float3 v0 = input[0].vertex.xyz;
+ float3 v1 = input[1].vertex.xyz;
+ float3 v2 = input[2].vertex.xyz;
+
+ float3 centerPoint = (v0 + v1 + v2) / 3.0;
+ float3 normal = normalize(cross((v1 - v0), (v2 - v0)));
+
+
+ float3 heightPoint = centerPoint + normal * _NHeight;
+
+
+ float3 a = centerPoint + normalize(v0 - centerPoint) * _NScale;
+ float3 b = centerPoint + normalize(v1 - centerPoint) * _NScale;
+ float3 c = centerPoint + normalize(v2 - centerPoint) * _NScale;
+
+ float4 A = UnityObjectToClipPos(a);
+ float4 B = UnityObjectToClipPos(b);
+ float4 C = UnityObjectToClipPos(c);
+ float4 HP = UnityObjectToClipPos(heightPoint);
+
+
+ v2f output;
+ output.color = _NColor; //float4(UnityObjectToWorldNormal(normal), 1);
+
+ //#1/////////////////////////////////////////////////////
+ output.vertex = A;
+ triStream.Append(output);
+
+ output.vertex = B;
+ triStream.Append(output);
+
+ output.vertex = HP;
+ triStream.Append(output);
+
+
+ triStream.RestartStrip();
+
+
+ //#2/////////////////////////////////////////////////////
+ output.vertex = C;
+ triStream.Append(output);
+
+ output.vertex = A;
+ triStream.Append(output);
+
+ output.vertex = HP;
+ triStream.Append(output);
+
+
+ triStream.RestartStrip();
+
+
+ //#3/////////////////////////////////////////////////////
+ output.vertex = B;
+ triStream.Append(output);
+
+ output.vertex = C;
+ triStream.Append(output);
+
+ output.vertex = HP;
+ triStream.Append(output);
+
+
+ triStream.RestartStrip();
+ }
+
+
+ fixed4 frag (v2f i) : SV_Target
+ {
+ return i.color;
+ }
+ ENDCG
+ }
+ }
+}
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"
--- "Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Transparent Simple Diffuse.shader" 2017-07-08 00:59:51.230802900 -0400
+++ "../Mesh Maker VR/Assets/VacuumShaders/The Amazing Wireframe Shader/Shaders/Geometry Shader/Transparent Simple Diffuse.shader" 2017-04-17 10:37:04.084078100 -0400
@@ -7,6 +7,11 @@
{
Properties
{
+ //Wire Normal Options
+ _NColor("Color", color) = (0, 0, 0, 1)
+ _NHeight("Height", float) = 0.1
+ _NScale("Scale", float) = 0.01
+
//Tag
[V_WIRE_Tag] _V_WIRE_Tag("", float) = 0
@@ -572,6 +577,8 @@
}
+ UsePass "GeometryNormal/MAIN"
+
}
FallBack "Hidden/VacuumShaders/The Amazing Wireframe/Mobile/Vertex Lit/Transparent/Full"