forked from framefield/tooll_operators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
15967e2c-3696-4752-b589-f66a45090455.mop
306 lines (306 loc) · 10.8 KB
/
15967e2c-3696-4752-b589-f66a45090455.mop
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
{
"Name": "Visibility",
"_id": "15967e2c-3696-4752-b589-f66a45090455",
"Namespace": "lib.3d.material",
"Description": "Controls the visibility with a float value.\r\nIf Visibility reaches zero, subtree is no longer evaluated in RenderPass.",
"Inputs": [
{
"Name": "Code",
"MetaInstanceID": "9db50e62-672c-4337-8cdc-3aff756fc88f",
"DefaultValue": {
"Type": "Text",
"Value": [
"float4x4 worldToCameraMatrix;\r",
"float4x4 projMatrix;\r",
"float4x4 textureMatrix;\r",
"\r",
"float4 ColorMul;",
"\r",
"Texture2D txDiffuse;\r",
"\r",
"SamplerState samLinear\r",
"{\r",
" Filter = MIN_MAG_MIP_LINEAR;\r",
" AddressU = Wrap;\r",
" AddressV = Wrap;\r",
"};\r",
"\r",
"struct VS_IN\r",
"{\r",
" float4 pos : POSITION;\r",
" float3 normal: NORMAL;\r",
" float4 col : COLOR;\r",
" float2 texCoord : TEXCOORD;\r",
" float3 tangent: TANGENT;\r",
" float3 binormal: BINORMAL;\r",
"};\r",
"\r",
"struct PS_IN\r",
"{\r",
" \r",
" float4 pos : SV_POSITION;\r",
" float4 col : COLOR;\r",
" float2 texCoord: TEXCOORD0;\r",
"};\r",
"\r",
"PS_IN VS( VS_IN input )\r",
"{\r",
" PS_IN output = (PS_IN)0;\r",
"\r",
" output.pos = mul(input.pos, worldToCameraMatrix);\r",
" output.pos = mul(output.pos, projMatrix);\r",
" output.col = input.col;\r",
" output.texCoord = mul(float4(input.texCoord.xy, 0, 1), textureMatrix).xy;\r",
"\r",
" return output;\r",
"}\r",
"\r",
"float4 PS( PS_IN input ) : SV_Target\r",
"{\r",
" float4 colr=txDiffuse.Sample(samLinear, input.texCoord) * input.col*ColorMul;\r",
"\r",
" return colr;\r",
"}\r",
"\r",
"technique10 Render\r",
"{\r",
" pass P0\r",
" {\r",
" SetGeometryShader( 0 );\r",
" SetVertexShader( CompileShader( vs_4_0, VS() ) );\r",
" SetPixelShader( CompileShader( ps_4_0, PS() ) );\r",
" }\r",
"}\r",
""
]
},
"MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d",
"IsMultiInput": "False",
"Relevance": "Optional",
"Description": "",
"Min": "-100000",
"Max": "100000",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": []
},
{
"Name": "Scene",
"MetaInstanceID": "36e8c5dc-b8fc-4ad3-bf61-9485b86aa080",
"DefaultValue": {
"Type": "Scene",
"Value": "Framefield.Core.Scene"
},
"MetaID": "79122951-7bc4-4c68-b085-866eab828248",
"IsMultiInput": "False",
"Relevance": "Required",
"Description": "",
"Min": "-100000",
"Max": "100000",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": []
},
{
"Name": "Alpha",
"MetaInstanceID": "690b4a2c-6e6f-4cb8-a2bf-a8330b2e833f",
"DefaultValue": {
"Type": "Float",
"Value": "1"
},
"MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
"IsMultiInput": "False",
"Relevance": "Optional",
"Description": "",
"Min": "0",
"Max": "1",
"Scale": "0.01",
"ScaleType": "Linear",
"EnumValues": []
},
{
"Name": "OverrideAlpha",
"MetaInstanceID": "cde80520-3362-4f00-8a36-df41667b3dc8",
"DefaultValue": {
"Type": "Float",
"Value": "0"
},
"MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
"IsMultiInput": "False",
"Relevance": "Optional",
"Description": "",
"Min": "-100000",
"Max": "100000",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": [
{
"Name": "Override",
"Value": "0"
},
{
"Name": "Multiply",
"Value": "1"
}
]
}
],
"Outputs": [
{
"Name": "Scene",
"MetaInstanceID": "ac1d4561-9b09-4c90-8449-12375f9642f1",
"MetaID": "79122951-7bc4-4c68-b085-866eab828248"
}
],
"OperatorParts": [
{
"MetaInstanceID": "d6d04614-b8b8-48e6-bae2-e112cc5098a3",
"MetaID": "eed574eb-5051-4481-898e-96e069c133df",
"Name": "VisibilityFunc",
"Version": "b072430e-24dc-4fef-a48c-92001c15bc0c",
"Type": "Float",
"IsMultiInput": "True",
"Script": [
"using System;",
"using System.Collections.Generic;",
"using System.Runtime.InteropServices;",
"using SharpDX;",
"using SharpDX.Direct3D11;",
"using Framefield.Core.Rendering;",
"using Framefield.Core.OperatorPartTraits;",
"using Buffer = SharpDX.Direct3D11.Buffer;",
"",
"namespace Framefield.Core.IDeed574eb_5051_4481_898e_96e069c133df",
"{",
" public class Class_Visibility : FXSourceCodeFunction, IFXSceneSourceCode, IMaterial, ITraverseModifier",
" {",
"",
" class Renderer : BaseRenderer",
" {",
" }",
"",
" public override void Dispose() {",
" Utilities.DisposeObj(ref _renderer);",
" base.Dispose();",
" }",
"",
" public IEnumerable<OperatorPart> GetRelevantConnections()",
" {",
" List<OperatorPart> connections = new List<OperatorPart>(OperatorPart.Connections);",
"",
" if (_alpha < 0.001f)",
" {",
" connections.RemoveAt(0);",
" } ",
"",
" return connections;",
" }",
"",
" //>>> _inputids",
" private enum InputId",
" {",
" Code = 0,",
" Scene = 1,",
" Alpha = 2,",
" OverrideAlpha = 3",
" }",
" //<<< _inputids",
" bool _firstEval = true;",
" public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx) {",
" //>>> _params",
" var Code = inputs[(int)InputId.Code].Eval(context).Text;",
" var Scene = inputs[(int)InputId.Scene];",
" var Alpha = inputs[(int)InputId.Alpha].Eval(context).Value;",
" var OverrideAlpha = (int) inputs[(int)InputId.OverrideAlpha].Eval(context).Value;",
" //<<< _params",
"",
" _alpha = Alpha;",
" if (_firstEval) {",
" for (int i = 0; i < NumCodes(); ++i)",
" Compile(i);",
" _firstEval = false;",
" Changed = true;",
" }",
"",
" using (new PropertyStasher<OperatorPartContext>(context, \"Effect\", \"Renderer\")) {",
" context.Effect = _effect;",
" context.Renderer = _renderer;",
"",
" var prevMaterial = (IMaterial) context.Objects[OperatorPartContext.MATERIAL_ID];",
" Ambient = prevMaterial.Ambient;",
" Specular = prevMaterial.Specular;",
" Emission = prevMaterial.Emission;",
" Shininess = prevMaterial.Shininess;",
" ",
" var d = prevMaterial.Diffuse;",
" Diffuse = new Color4(d.Red, d.Green, d.Blue, Alpha);",
" ",
" if (OverrideAlpha > 0.5f) ",
" {",
" Alpha *= d.Alpha;",
" Diffuse = new Color4(d.Red, d.Green, d.Blue, Alpha);",
" }",
" ",
" if( Alpha > 0) {",
" context.Objects[OperatorPartContext.MATERIAL_ID] = this;",
" _effect.GetVariableByName(\"ColorMul\").AsVector().Set(Diffuse); ",
" Scene.Eval(context);",
" context.Objects[OperatorPartContext.MATERIAL_ID] = prevMaterial;",
" }",
" ",
" ",
" }",
" return context;",
" }",
"",
" private float _alpha;",
" private Renderer _renderer = new Renderer();",
"",
" public Color4 Ambient { get; private set; }",
" public Color4 Diffuse { get; private set; }",
" public Color4 Specular { get; private set; }",
" public Color4 Emission { get; private set; }",
" public float Shininess { get; private set; }",
" }",
"}",
"",
"",
""
],
"AdditionalAssemblies": []
}
],
"Operators": [],
"Connections": [
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "d6d04614-b8b8-48e6-bae2-e112cc5098a3",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "ac1d4561-9b09-4c90-8449-12375f9642f1"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "9db50e62-672c-4337-8cdc-3aff756fc88f",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "d6d04614-b8b8-48e6-bae2-e112cc5098a3"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "36e8c5dc-b8fc-4ad3-bf61-9485b86aa080",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "d6d04614-b8b8-48e6-bae2-e112cc5098a3"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "690b4a2c-6e6f-4cb8-a2bf-a8330b2e833f",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "d6d04614-b8b8-48e6-bae2-e112cc5098a3"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "cde80520-3362-4f00-8a36-df41667b3dc8",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "d6d04614-b8b8-48e6-bae2-e112cc5098a3"
}
]
}