procfunc 0.30.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. procfunc/__init__.py +87 -0
  2. procfunc/color.py +57 -0
  3. procfunc/compute_graph/__init__.py +28 -0
  4. procfunc/compute_graph/compute_graph.py +115 -0
  5. procfunc/compute_graph/node.py +200 -0
  6. procfunc/compute_graph/operators_info.py +92 -0
  7. procfunc/compute_graph/proxy.py +173 -0
  8. procfunc/compute_graph/util.py +282 -0
  9. procfunc/context.py +115 -0
  10. procfunc/control.py +174 -0
  11. procfunc/nodes/__init__.py +66 -0
  12. procfunc/nodes/bindings_util.py +196 -0
  13. procfunc/nodes/bpy_node_info.py +280 -0
  14. procfunc/nodes/compositor.py +2242 -0
  15. procfunc/nodes/execute/construct_nodes.py +571 -0
  16. procfunc/nodes/execute/construct_special_cases.py +246 -0
  17. procfunc/nodes/execute/execute.py +548 -0
  18. procfunc/nodes/execute/infer_runtime_data_type.py +195 -0
  19. procfunc/nodes/execute/util.py +247 -0
  20. procfunc/nodes/func.py +1417 -0
  21. procfunc/nodes/geo.py +4240 -0
  22. procfunc/nodes/manifest.json +8769 -0
  23. procfunc/nodes/math.py +644 -0
  24. procfunc/nodes/node_function.py +160 -0
  25. procfunc/nodes/shader.py +2359 -0
  26. procfunc/nodes/types.py +347 -0
  27. procfunc/ops/__init__.py +35 -0
  28. procfunc/ops/_util.py +275 -0
  29. procfunc/ops/addons.py +59 -0
  30. procfunc/ops/attr.py +426 -0
  31. procfunc/ops/collection.py +90 -0
  32. procfunc/ops/curve.py +18 -0
  33. procfunc/ops/file.py +126 -0
  34. procfunc/ops/manifest.json +39149 -0
  35. procfunc/ops/mesh.py +1510 -0
  36. procfunc/ops/modifier.py +603 -0
  37. procfunc/ops/object.py +258 -0
  38. procfunc/ops/primitives/__init__.py +31 -0
  39. procfunc/ops/primitives/camera.py +45 -0
  40. procfunc/ops/primitives/curve.py +71 -0
  41. procfunc/ops/primitives/light.py +114 -0
  42. procfunc/ops/primitives/mesh.py +358 -0
  43. procfunc/ops/uv.py +271 -0
  44. procfunc/random.py +247 -0
  45. procfunc/tracer/__init__.py +43 -0
  46. procfunc/tracer/decorator.py +121 -0
  47. procfunc/tracer/patch.py +494 -0
  48. procfunc/tracer/proxy.py +127 -0
  49. procfunc/tracer/trace.py +222 -0
  50. procfunc/transforms/__init__.py +49 -0
  51. procfunc/transforms/cleanup.py +214 -0
  52. procfunc/transforms/convert.py +20 -0
  53. procfunc/transforms/distribution.py +191 -0
  54. procfunc/transforms/extract_materials.py +116 -0
  55. procfunc/transforms/infer_distribution.py +326 -0
  56. procfunc/transforms/parameters.py +15 -0
  57. procfunc/transforms/util.py +35 -0
  58. procfunc/transpiler/__init__.py +24 -0
  59. procfunc/transpiler/bpy_to_computegraph.py +1348 -0
  60. procfunc/transpiler/codegen.py +919 -0
  61. procfunc/transpiler/identifiers.py +595 -0
  62. procfunc/transpiler/main.py +299 -0
  63. procfunc/types.py +380 -0
  64. procfunc/util/__init__.py +0 -0
  65. procfunc/util/bpy_info.py +145 -0
  66. procfunc/util/camera.py +0 -0
  67. procfunc/util/keyframe.py +70 -0
  68. procfunc/util/log.py +96 -0
  69. procfunc/util/manifest.py +121 -0
  70. procfunc/util/pytree.py +343 -0
  71. procfunc/util/teardown.py +37 -0
  72. procfunc-0.30.0.dist-info/METADATA +120 -0
  73. procfunc-0.30.0.dist-info/RECORD +76 -0
  74. procfunc-0.30.0.dist-info/WHEEL +5 -0
  75. procfunc-0.30.0.dist-info/licenses/LICENSE.md +11 -0
  76. procfunc-0.30.0.dist-info/top_level.txt +1 -0
procfunc/nodes/math.py ADDED
@@ -0,0 +1,644 @@
1
+ """
2
+ Math and Vector Math Node bindings for Blender
3
+ """
4
+
5
+ from typing import Literal
6
+
7
+ from procfunc import types as pt
8
+ from procfunc.nodes import types as nt
9
+
10
+
11
+ def clamp(
12
+ value: nt.SocketOrVal[float] = 1.0,
13
+ min: nt.SocketOrVal[float] = 0.0,
14
+ max: nt.SocketOrVal[float] = 1.0,
15
+ clamp_type: Literal["MINMAX", "RANGE"] = "MINMAX",
16
+ ) -> nt.ProcNode[float]:
17
+ """
18
+ Uses a Clamp Shader Node.
19
+
20
+ See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/clamp.html
21
+ """
22
+ return nt.ProcNode.from_nodetype(
23
+ node_type="ShaderNodeClamp",
24
+ inputs={"Value": value, "Min": min, "Max": max},
25
+ attrs={"clamp_type": clamp_type},
26
+ )
27
+
28
+
29
+ # Math Nodes
30
+
31
+
32
+ def _math(
33
+ a: nt.SocketOrVal[float] = None,
34
+ b: nt.SocketOrVal[float] = None,
35
+ value_2: nt.SocketOrVal[float] = None,
36
+ operation: str = "ADD",
37
+ ) -> nt.ProcNode[float]:
38
+ """
39
+ Uses a Math Shader Node.
40
+
41
+ Procfunc does NOT support the inline clamp option - use pf.nodes.math.clamp() on the output instead.
42
+
43
+ See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/math.html
44
+ """
45
+
46
+ return nt.ProcNode.from_nodetype(
47
+ node_type="ShaderNodeMath",
48
+ inputs={("Value", 0): a, ("Value", 1): b, ("Value", 2): value_2},
49
+ attrs={
50
+ "operation": operation,
51
+ "use_clamp": False, # not supported by procfunc
52
+ },
53
+ )
54
+
55
+
56
+ # Basic Math Operations
57
+ def add(
58
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
59
+ ) -> nt.ProcNode[float]:
60
+ return _math(a, b, operation="ADD")
61
+
62
+
63
+ def subtract(
64
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
65
+ ) -> nt.ProcNode[float]:
66
+ return _math(a, b, operation="SUBTRACT")
67
+
68
+
69
+ def multiply(
70
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
71
+ ) -> nt.ProcNode[float]:
72
+ return _math(a, b, operation="MULTIPLY")
73
+
74
+
75
+ def multiply_add(
76
+ a: nt.SocketOrVal[float] = 0.5,
77
+ b: nt.SocketOrVal[float] = 0.5,
78
+ addend: nt.SocketOrVal[float] = 0.0,
79
+ ) -> nt.ProcNode[float]:
80
+ return _math(a, b, addend, operation="MULTIPLY_ADD")
81
+
82
+
83
+ def divide(
84
+ numerator: nt.SocketOrVal[float] = 0.5, denominator: nt.SocketOrVal[float] = 0.5
85
+ ) -> nt.ProcNode[float]:
86
+ return _math(numerator, denominator, operation="DIVIDE")
87
+
88
+
89
+ def power(
90
+ base: nt.SocketOrVal[float] = 0.5, exponent: nt.SocketOrVal[float] = 0.5
91
+ ) -> nt.ProcNode[float]:
92
+ return _math(base, exponent, operation="POWER")
93
+
94
+
95
+ def logarithm(
96
+ value: nt.SocketOrVal[float] = 0.5, base: nt.SocketOrVal[float] = 0.5
97
+ ) -> nt.ProcNode[float]:
98
+ return _math(value, base, operation="LOGARITHM")
99
+
100
+
101
+ def sqrt(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
102
+ return _math(value, operation="SQRT")
103
+
104
+
105
+ def inverse_sqrt(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
106
+ return _math(value, operation="INVERSE_SQRT")
107
+
108
+
109
+ def absolute(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
110
+ return _math(value, operation="ABSOLUTE")
111
+
112
+
113
+ def exponent(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
114
+ return _math(value, operation="EXPONENT")
115
+
116
+
117
+ # Comparison Operations
118
+ def minimum(
119
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
120
+ ) -> nt.ProcNode[float]:
121
+ return _math(a, b, operation="MINIMUM")
122
+
123
+
124
+ def maximum(
125
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
126
+ ) -> nt.ProcNode[float]:
127
+ return _math(a, b, operation="MAXIMUM")
128
+
129
+
130
+ def less_than(
131
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
132
+ ) -> nt.ProcNode[float]:
133
+ return _math(a, b, operation="LESS_THAN")
134
+
135
+
136
+ def greater_than(
137
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
138
+ ) -> nt.ProcNode[float]:
139
+ return _math(a, b, operation="GREATER_THAN")
140
+
141
+
142
+ def sign(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
143
+ return _math(value, operation="SIGN")
144
+
145
+
146
+ def compare(
147
+ a: nt.SocketOrVal[float] = 0.5,
148
+ b: nt.SocketOrVal[float] = 0.5,
149
+ epsilon: nt.SocketOrVal[float] = 0.001,
150
+ ) -> nt.ProcNode[float]:
151
+ return _math(a, b, epsilon, operation="COMPARE")
152
+
153
+
154
+ def smooth_minimum(
155
+ a: nt.SocketOrVal[float] = 0.5,
156
+ b: nt.SocketOrVal[float] = 0.5,
157
+ distance: nt.SocketOrVal[float] = 0.0,
158
+ ) -> nt.ProcNode[float]:
159
+ return _math(a, b, distance, operation="SMOOTH_MIN")
160
+
161
+
162
+ def smooth_maximum(
163
+ a: nt.SocketOrVal[float] = 0.5,
164
+ b: nt.SocketOrVal[float] = 0.5,
165
+ distance: nt.SocketOrVal[float] = 0.0,
166
+ ) -> nt.ProcNode[float]:
167
+ return _math(a, b, distance, operation="SMOOTH_MAX")
168
+
169
+
170
+ def round(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
171
+ return _math(value, operation="ROUND")
172
+
173
+
174
+ def floor(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
175
+ return _math(value, operation="FLOOR")
176
+
177
+
178
+ def ceil(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
179
+ return _math(value, operation="CEIL")
180
+
181
+
182
+ def truncate(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
183
+ return _math(value, operation="TRUNC")
184
+
185
+
186
+ def fraction(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
187
+ return _math(value, operation="FRACT")
188
+
189
+
190
+ def modulo(
191
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
192
+ ) -> nt.ProcNode[float]:
193
+ return _math(a, b, operation="MODULO")
194
+
195
+
196
+ def floor_mod(
197
+ a: nt.SocketOrVal[float] = 0.5, b: nt.SocketOrVal[float] = 0.5
198
+ ) -> nt.ProcNode[float]:
199
+ return _math(a, b, operation="FLOORED_MODULO")
200
+
201
+
202
+ def wrap(
203
+ value: nt.SocketOrVal[float] = 0.5,
204
+ max_val: nt.SocketOrVal[float] = 1.0,
205
+ min_val: nt.SocketOrVal[float] = 0.0,
206
+ ) -> nt.ProcNode[float]:
207
+ return _math(value, max_val, min_val, operation="WRAP")
208
+
209
+
210
+ def snap(
211
+ value: nt.SocketOrVal[float] = 0.5, increment: nt.SocketOrVal[float] = 1.0
212
+ ) -> nt.ProcNode[float]:
213
+ return _math(value, increment, operation="SNAP")
214
+
215
+
216
+ def pingpong(
217
+ value: nt.SocketOrVal[float] = 0.5, scale: nt.SocketOrVal[float] = 1.0
218
+ ) -> nt.ProcNode[float]:
219
+ return _math(value, scale, operation="PINGPONG")
220
+
221
+
222
+ # Trigonometric Operations
223
+ def sin(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
224
+ return _math(value, operation="SINE")
225
+
226
+
227
+ def cos(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
228
+ return _math(value, operation="COSINE")
229
+
230
+
231
+ def tan(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
232
+ return _math(value, operation="TANGENT")
233
+
234
+
235
+ def asin(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
236
+ return _math(value, operation="ARCSINE")
237
+
238
+
239
+ def acos(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
240
+ return _math(value, operation="ARCCOSINE")
241
+
242
+
243
+ def atan(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
244
+ return _math(value, operation="ARCTANGENT")
245
+
246
+
247
+ def atan2(
248
+ y: nt.SocketOrVal[float] = 0.5, x: nt.SocketOrVal[float] = 0.5
249
+ ) -> nt.ProcNode[float]:
250
+ return _math(y, x, operation="ARCTAN2")
251
+
252
+
253
+ def sinh(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
254
+ return _math(value, operation="SINH")
255
+
256
+
257
+ def cosh(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
258
+ return _math(value, operation="COSH")
259
+
260
+
261
+ def tanh(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
262
+ return _math(value, operation="TANH")
263
+
264
+
265
+ # Conversion Operations
266
+ def deg_to_rad(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
267
+ return _math(value, operation="RADIANS")
268
+
269
+
270
+ def rad_to_deg(value: nt.SocketOrVal[float] = 0.5) -> nt.ProcNode[float]:
271
+ return _math(value, operation="DEGREES")
272
+
273
+
274
+ # Vector Math Operations
275
+ def vector_add(
276
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
277
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
278
+ ) -> nt.ProcNode[pt.Vector]:
279
+ """Add two vectors."""
280
+
281
+ return nt.ProcNode.from_nodetype(
282
+ node_type="ShaderNodeVectorMath",
283
+ inputs={("Vector", 0): a, ("Vector", 1): b},
284
+ attrs={"operation": "ADD"},
285
+ )
286
+
287
+
288
+ def vector_subtract(
289
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
290
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
291
+ ) -> nt.ProcNode[pt.Vector]:
292
+ return nt.ProcNode.from_nodetype(
293
+ node_type="ShaderNodeVectorMath",
294
+ inputs={("Vector", 0): a, ("Vector", 1): b},
295
+ attrs={"operation": "SUBTRACT"},
296
+ )
297
+
298
+
299
+ def vector_multiply(
300
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
301
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
302
+ ) -> nt.ProcNode[pt.Vector]:
303
+ return nt.ProcNode.from_nodetype(
304
+ node_type="ShaderNodeVectorMath",
305
+ inputs={("Vector", 0): a, ("Vector", 1): b},
306
+ attrs={"operation": "MULTIPLY"},
307
+ )
308
+
309
+
310
+ def vector_multiply_add(
311
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
312
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
313
+ addend: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
314
+ ) -> nt.ProcNode[pt.Vector]:
315
+ return nt.ProcNode.from_nodetype(
316
+ node_type="ShaderNodeVectorMath",
317
+ attrs={"operation": "MULTIPLY_ADD"},
318
+ inputs={("Vector", 0): a, ("Vector", 1): b, ("Vector", 2): addend},
319
+ )
320
+
321
+
322
+ def vector_divide(
323
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
324
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
325
+ ) -> nt.ProcNode[pt.Vector]:
326
+ return nt.ProcNode.from_nodetype(
327
+ node_type="ShaderNodeVectorMath",
328
+ inputs={("Vector", 0): a, ("Vector", 1): b},
329
+ attrs={"operation": "DIVIDE"},
330
+ )
331
+
332
+
333
+ def vector_cross_product(
334
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
335
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
336
+ ) -> nt.ProcNode[pt.Vector]:
337
+ return nt.ProcNode.from_nodetype(
338
+ node_type="ShaderNodeVectorMath",
339
+ inputs={("Vector", 0): a, ("Vector", 1): b},
340
+ attrs={"operation": "CROSS_PRODUCT"},
341
+ )
342
+
343
+
344
+ def vector_project(
345
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
346
+ onto: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
347
+ ) -> nt.ProcNode[float]:
348
+ return nt.ProcNode.from_nodetype(
349
+ node_type="ShaderNodeVectorMath",
350
+ inputs={("Vector", 0): vector, ("Vector", 1): onto},
351
+ attrs={"operation": "PROJECT"},
352
+ )
353
+
354
+
355
+ def vector_reflect(
356
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
357
+ normal: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
358
+ ) -> nt.ProcNode[pt.Vector]:
359
+ return nt.ProcNode.from_nodetype(
360
+ node_type="ShaderNodeVectorMath",
361
+ inputs={("Vector", 0): a, ("Vector", 1): normal},
362
+ attrs={"operation": "REFLECT"},
363
+ )
364
+
365
+
366
+ def vector_refract(
367
+ incident: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
368
+ normal: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
369
+ ior: nt.SocketOrVal[float] = 1.0,
370
+ ) -> nt.ProcNode[pt.Vector]:
371
+ return nt.ProcNode.from_nodetype(
372
+ node_type="ShaderNodeVectorMath",
373
+ inputs={("Vector", 0): incident, ("Vector", 1): normal, ("Scale", 2): ior},
374
+ attrs={"operation": "REFRACT"},
375
+ )
376
+
377
+
378
+ def vector_faceforward(
379
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
380
+ surface: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
381
+ normal: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
382
+ ) -> nt.ProcNode[pt.Vector]:
383
+ return nt.ProcNode.from_nodetype(
384
+ node_type="ShaderNodeVectorMath",
385
+ inputs={
386
+ ("Vector", 0): vector,
387
+ ("Vector", 1): surface,
388
+ ("Vector", 2): normal,
389
+ },
390
+ attrs={"operation": "FACEFORWARD"},
391
+ )
392
+
393
+
394
+ def vector_dot_product(
395
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
396
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
397
+ ) -> nt.ProcNode[pt.Vector]:
398
+ return nt.ProcNode.from_nodetype(
399
+ node_type="ShaderNodeVectorMath",
400
+ inputs={("Vector", 0): a, ("Vector", 1): b},
401
+ attrs={"operation": "DOT_PRODUCT"},
402
+ )
403
+
404
+
405
+ def vector_distance(
406
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
407
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
408
+ ) -> nt.ProcNode[pt.Vector]:
409
+ return nt.ProcNode.from_nodetype(
410
+ node_type="ShaderNodeVectorMath",
411
+ inputs={("Vector", 0): a, ("Vector", 1): b},
412
+ attrs={"operation": "DISTANCE"},
413
+ )
414
+
415
+
416
+ def vector_length(vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0)) -> nt.ProcNode[float]:
417
+ return nt.ProcNode.from_nodetype(
418
+ node_type="ShaderNodeVectorMath",
419
+ inputs={("Vector", 0): vector},
420
+ attrs={"operation": "LENGTH"},
421
+ )
422
+
423
+
424
+ def vector_scale(
425
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0), scale: nt.SocketOrVal[float] = 1.0
426
+ ) -> nt.ProcNode[pt.Vector]:
427
+ return nt.ProcNode.from_nodetype(
428
+ node_type="ShaderNodeVectorMath",
429
+ inputs={("Vector", 0): vector, ("Scale", 0): scale},
430
+ attrs={"operation": "SCALE"},
431
+ )
432
+
433
+
434
+ def vector_normalize(
435
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
436
+ ) -> nt.ProcNode[pt.Vector]:
437
+ return nt.ProcNode.from_nodetype(
438
+ node_type="ShaderNodeVectorMath",
439
+ inputs={("Vector", 0): vector},
440
+ attrs={"operation": "NORMALIZE"},
441
+ )
442
+
443
+
444
+ def vector_wrap(
445
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
446
+ max_val: nt.SocketOrVal[pt.Vector] = (1, 1, 1),
447
+ min_val: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
448
+ ) -> nt.ProcNode[pt.Vector]:
449
+ return nt.ProcNode.from_nodetype(
450
+ node_type="ShaderNodeVectorMath",
451
+ inputs={("Vector", 0): vector, ("Vector", 1): max_val, ("Vector", 2): min_val},
452
+ attrs={"operation": "WRAP"},
453
+ )
454
+
455
+
456
+ def vector_snap(
457
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
458
+ b: nt.SocketOrVal[pt.Vector] = (1, 1, 1),
459
+ ) -> nt.ProcNode[pt.Vector]:
460
+ return nt.ProcNode.from_nodetype(
461
+ node_type="ShaderNodeVectorMath",
462
+ inputs={("Vector", 0): a, ("Vector", 1): b},
463
+ attrs={"operation": "SNAP"},
464
+ )
465
+
466
+
467
+ def vector_floor(
468
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
469
+ ) -> nt.ProcNode[pt.Vector]:
470
+ return nt.ProcNode.from_nodetype(
471
+ node_type="ShaderNodeVectorMath",
472
+ inputs={("Vector", 0): vector},
473
+ attrs={"operation": "FLOOR"},
474
+ )
475
+
476
+
477
+ def vector_ceil(
478
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
479
+ ) -> nt.ProcNode[pt.Vector]:
480
+ return nt.ProcNode.from_nodetype(
481
+ node_type="ShaderNodeVectorMath",
482
+ inputs={("Vector", 0): vector},
483
+ attrs={"operation": "CEIL"},
484
+ )
485
+
486
+
487
+ def vector_modulo(
488
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
489
+ b: nt.SocketOrVal[pt.Vector] = (1, 1, 1),
490
+ ) -> nt.ProcNode[pt.Vector]:
491
+ return nt.ProcNode.from_nodetype(
492
+ node_type="ShaderNodeVectorMath",
493
+ inputs={("Vector", 0): a, ("Vector", 1): b},
494
+ attrs={"operation": "MODULO"},
495
+ )
496
+
497
+
498
+ def vector_fraction(
499
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
500
+ ) -> nt.ProcNode[pt.Vector]:
501
+ return nt.ProcNode.from_nodetype(
502
+ node_type="ShaderNodeVectorMath",
503
+ inputs={("Vector", 0): vector},
504
+ attrs={"operation": "FRACTION"},
505
+ )
506
+
507
+
508
+ def vector_round(
509
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
510
+ ) -> nt.ProcNode[pt.Vector]:
511
+ return nt.ProcNode.from_nodetype(
512
+ node_type="ShaderNodeVectorMath",
513
+ inputs={("Vector", 0): vector},
514
+ attrs={"operation": "ROUND"},
515
+ )
516
+
517
+
518
+ def vector_truncate(
519
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
520
+ ) -> nt.ProcNode[pt.Vector]:
521
+ return nt.ProcNode.from_nodetype(
522
+ node_type="ShaderNodeVectorMath",
523
+ inputs={("Vector", 0): vector},
524
+ attrs={"operation": "TRUNC"},
525
+ )
526
+
527
+
528
+ def vector_absolute(
529
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
530
+ ) -> nt.ProcNode[pt.Vector]:
531
+ return nt.ProcNode.from_nodetype(
532
+ node_type="ShaderNodeVectorMath",
533
+ inputs={("Vector", 0): vector},
534
+ attrs={"operation": "ABSOLUTE"},
535
+ )
536
+
537
+
538
+ def vector_minimum(
539
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
540
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
541
+ ) -> nt.ProcNode[pt.Vector]:
542
+ return nt.ProcNode.from_nodetype(
543
+ node_type="ShaderNodeVectorMath",
544
+ inputs={("Vector", 0): a, ("Vector", 1): b},
545
+ attrs={"operation": "MINIMUM"},
546
+ )
547
+
548
+
549
+ def vector_maximum(
550
+ a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
551
+ b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
552
+ ) -> nt.ProcNode[pt.Vector]:
553
+ return nt.ProcNode.from_nodetype(
554
+ node_type="ShaderNodeVectorMath",
555
+ inputs={("Vector", 0): a, ("Vector", 1): b},
556
+ attrs={"operation": "MAXIMUM"},
557
+ )
558
+
559
+
560
+ def vector_sine(
561
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
562
+ ) -> nt.ProcNode[pt.Vector]:
563
+ return nt.ProcNode.from_nodetype(
564
+ node_type="ShaderNodeVectorMath",
565
+ inputs={("Vector", 0): vector},
566
+ attrs={"operation": "SINE"},
567
+ )
568
+
569
+
570
+ def vector_cosine(
571
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
572
+ ) -> nt.ProcNode[pt.Vector]:
573
+ return nt.ProcNode.from_nodetype(
574
+ node_type="ShaderNodeVectorMath",
575
+ inputs={("Vector", 0): vector},
576
+ attrs={"operation": "COSINE"},
577
+ )
578
+
579
+
580
+ def vector_tangent(
581
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
582
+ ) -> nt.ProcNode[pt.Vector]:
583
+ return nt.ProcNode.from_nodetype(
584
+ node_type="ShaderNodeVectorMath",
585
+ inputs={("Vector", 0): vector},
586
+ attrs={"operation": "TANGENT"},
587
+ )
588
+
589
+
590
+ def vector_rotate_axis_angle(
591
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
592
+ center: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
593
+ axis: nt.SocketOrVal[pt.Vector] = (0, 0, 1),
594
+ angle: nt.SocketOrVal[float] = 0.0,
595
+ invert: bool = False,
596
+ ) -> nt.ProcNode[pt.Vector]:
597
+ """
598
+ Uses a VectorRotate Shader Node.
599
+
600
+ See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/vector/vector_rotate.html
601
+ """
602
+ return nt.ProcNode.from_nodetype(
603
+ node_type="ShaderNodeVectorRotate",
604
+ inputs={"Vector": vector, "Center": center, "Axis": axis, "Angle": angle},
605
+ attrs={"invert": invert, "rotation_type": "AXIS_ANGLE"},
606
+ )
607
+
608
+
609
+ def vector_rotate_euler(
610
+ vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
611
+ center: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
612
+ rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
613
+ invert: bool = False,
614
+ ) -> nt.ProcNode[pt.Vector]:
615
+ return nt.ProcNode.from_nodetype(
616
+ node_type="ShaderNodeVectorRotate",
617
+ inputs={"Vector": vector, "Center": center, "Rotation": rotation},
618
+ attrs={"invert": invert, "rotation_type": "EULER_XYZ"},
619
+ )
620
+
621
+
622
+ # NOTE: mode XYZ have been dropped. transpiler specialcases will map these back to vector_rotate_euler calls.
623
+
624
+
625
+ def vector_transform(
626
+ vector: nt.SocketOrVal[pt.Vector] = (0.5, 0.5, 0.5),
627
+ convert_from: Literal["WORLD", "OBJECT", "CAMERA"] = "WORLD",
628
+ convert_to: Literal["WORLD", "OBJECT", "CAMERA"] = "OBJECT",
629
+ vector_type: Literal["POINT", "VECTOR", "NORMAL"] = "VECTOR",
630
+ ) -> nt.ProcNode[pt.Vector]:
631
+ """
632
+ Uses a VectorTransform Shader Node.
633
+
634
+ See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/vector/transform.html
635
+ """
636
+ return nt.ProcNode.from_nodetype(
637
+ node_type="ShaderNodeVectorTransform",
638
+ inputs={"Vector": vector},
639
+ attrs={
640
+ "convert_from": convert_from,
641
+ "convert_to": convert_to,
642
+ "vector_type": vector_type,
643
+ },
644
+ )