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.
- procfunc/__init__.py +87 -0
- procfunc/color.py +57 -0
- procfunc/compute_graph/__init__.py +28 -0
- procfunc/compute_graph/compute_graph.py +115 -0
- procfunc/compute_graph/node.py +200 -0
- procfunc/compute_graph/operators_info.py +92 -0
- procfunc/compute_graph/proxy.py +173 -0
- procfunc/compute_graph/util.py +282 -0
- procfunc/context.py +115 -0
- procfunc/control.py +174 -0
- procfunc/nodes/__init__.py +66 -0
- procfunc/nodes/bindings_util.py +196 -0
- procfunc/nodes/bpy_node_info.py +280 -0
- procfunc/nodes/compositor.py +2242 -0
- procfunc/nodes/execute/construct_nodes.py +571 -0
- procfunc/nodes/execute/construct_special_cases.py +246 -0
- procfunc/nodes/execute/execute.py +548 -0
- procfunc/nodes/execute/infer_runtime_data_type.py +195 -0
- procfunc/nodes/execute/util.py +247 -0
- procfunc/nodes/func.py +1417 -0
- procfunc/nodes/geo.py +4240 -0
- procfunc/nodes/manifest.json +8769 -0
- procfunc/nodes/math.py +644 -0
- procfunc/nodes/node_function.py +160 -0
- procfunc/nodes/shader.py +2359 -0
- procfunc/nodes/types.py +347 -0
- procfunc/ops/__init__.py +35 -0
- procfunc/ops/_util.py +275 -0
- procfunc/ops/addons.py +59 -0
- procfunc/ops/attr.py +426 -0
- procfunc/ops/collection.py +90 -0
- procfunc/ops/curve.py +18 -0
- procfunc/ops/file.py +126 -0
- procfunc/ops/manifest.json +39149 -0
- procfunc/ops/mesh.py +1510 -0
- procfunc/ops/modifier.py +603 -0
- procfunc/ops/object.py +258 -0
- procfunc/ops/primitives/__init__.py +31 -0
- procfunc/ops/primitives/camera.py +45 -0
- procfunc/ops/primitives/curve.py +71 -0
- procfunc/ops/primitives/light.py +114 -0
- procfunc/ops/primitives/mesh.py +358 -0
- procfunc/ops/uv.py +271 -0
- procfunc/random.py +247 -0
- procfunc/tracer/__init__.py +43 -0
- procfunc/tracer/decorator.py +121 -0
- procfunc/tracer/patch.py +494 -0
- procfunc/tracer/proxy.py +127 -0
- procfunc/tracer/trace.py +222 -0
- procfunc/transforms/__init__.py +49 -0
- procfunc/transforms/cleanup.py +214 -0
- procfunc/transforms/convert.py +20 -0
- procfunc/transforms/distribution.py +191 -0
- procfunc/transforms/extract_materials.py +116 -0
- procfunc/transforms/infer_distribution.py +326 -0
- procfunc/transforms/parameters.py +15 -0
- procfunc/transforms/util.py +35 -0
- procfunc/transpiler/__init__.py +24 -0
- procfunc/transpiler/bpy_to_computegraph.py +1348 -0
- procfunc/transpiler/codegen.py +919 -0
- procfunc/transpiler/identifiers.py +595 -0
- procfunc/transpiler/main.py +299 -0
- procfunc/types.py +380 -0
- procfunc/util/__init__.py +0 -0
- procfunc/util/bpy_info.py +145 -0
- procfunc/util/camera.py +0 -0
- procfunc/util/keyframe.py +70 -0
- procfunc/util/log.py +96 -0
- procfunc/util/manifest.py +121 -0
- procfunc/util/pytree.py +343 -0
- procfunc/util/teardown.py +37 -0
- procfunc-0.30.0.dist-info/METADATA +120 -0
- procfunc-0.30.0.dist-info/RECORD +76 -0
- procfunc-0.30.0.dist-info/WHEEL +5 -0
- procfunc-0.30.0.dist-info/licenses/LICENSE.md +11 -0
- procfunc-0.30.0.dist-info/top_level.txt +1 -0
procfunc/nodes/func.py
ADDED
|
@@ -0,0 +1,1417 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Auto-generated Function Node bindings for Blender
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import Any, Literal, NamedTuple, TypeVar
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from procfunc import types as pt
|
|
11
|
+
from procfunc.nodes import types as nt
|
|
12
|
+
from procfunc.nodes.bindings_util import (
|
|
13
|
+
ContextualNode,
|
|
14
|
+
RuntimeResolveDataType,
|
|
15
|
+
raise_io_error,
|
|
16
|
+
)
|
|
17
|
+
from procfunc.nodes.bpy_node_info import NodeDataType
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
TConstant = TypeVar("TConstant", int, float, bool, pt.Vector, pt.Euler, pt.Color)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def constant(
|
|
25
|
+
value: TConstant,
|
|
26
|
+
) -> nt.ProcNode[TConstant]:
|
|
27
|
+
"""
|
|
28
|
+
Replaces all nodes which just store a constant
|
|
29
|
+
e.g. ShaderNodeValue, ShaderNodeRGB, FunctionNodeInput*, etc
|
|
30
|
+
"""
|
|
31
|
+
if isinstance(value, (float, int)):
|
|
32
|
+
return nt.ProcNode.from_nodetype(
|
|
33
|
+
node_type="ShaderNodeValue", inputs={}, attrs={"value": value}
|
|
34
|
+
)
|
|
35
|
+
elif isinstance(value, (pt.Vector, pt.Euler, tuple)):
|
|
36
|
+
x, y, z = value
|
|
37
|
+
return combine_xyz(x=float(x), y=float(y), z=float(z))
|
|
38
|
+
elif isinstance(value, bool):
|
|
39
|
+
return nt.ProcNode.from_nodetype(
|
|
40
|
+
node_type="FunctionNodeBoolean", inputs={}, attrs={"boolean": value}
|
|
41
|
+
)
|
|
42
|
+
elif isinstance(value, pt.Color):
|
|
43
|
+
return nt.ProcNode.from_nodetype(
|
|
44
|
+
node_type="ShaderNodeRGB", inputs={}, attrs={"value": value}
|
|
45
|
+
)
|
|
46
|
+
elif isinstance(value, str):
|
|
47
|
+
return nt.ProcNode.from_nodetype(
|
|
48
|
+
node_type="FunctionNodeInputString", inputs={}, attrs={"value": value}
|
|
49
|
+
)
|
|
50
|
+
else:
|
|
51
|
+
raise ValueError(f"Unsupported constant type: {type(value)}")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def align_euler_to_vector(
|
|
55
|
+
rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
56
|
+
factor: nt.SocketOrVal[float] = 1.0,
|
|
57
|
+
vector: nt.SocketOrVal[pt.Vector] = (0, 0, 1),
|
|
58
|
+
axis: Literal["X", "Y", "Z"] = "X",
|
|
59
|
+
pivot_axis: Literal["AUTO", "X", "Y", "Z"] = "AUTO",
|
|
60
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
61
|
+
"""
|
|
62
|
+
Uses a AlignEulerToVector Function Node.
|
|
63
|
+
|
|
64
|
+
See: http://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/align_euler_to_vector.html
|
|
65
|
+
"""
|
|
66
|
+
return nt.ProcNode.from_nodetype(
|
|
67
|
+
node_type="FunctionNodeAlignEulerToVector",
|
|
68
|
+
inputs={"Rotation": rotation, "Factor": factor, "Vector": vector},
|
|
69
|
+
attrs={"axis": axis, "pivot_axis": pivot_axis},
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def align_rotation_to_vector(
|
|
74
|
+
rotation: Any = (0, 0, 0),
|
|
75
|
+
factor: nt.SocketOrVal[float] = 1.0,
|
|
76
|
+
vector: nt.SocketOrVal[pt.Vector] = (0, 0, 1),
|
|
77
|
+
axis: Literal["X", "Y", "Z"] = "Z",
|
|
78
|
+
pivot_axis: Literal["AUTO", "X", "Y", "Z"] = "AUTO",
|
|
79
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
80
|
+
"""
|
|
81
|
+
Uses a AlignRotationToVector Function Node.
|
|
82
|
+
|
|
83
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/align_rotation_to_vector.html
|
|
84
|
+
"""
|
|
85
|
+
return nt.ProcNode.from_nodetype(
|
|
86
|
+
node_type="FunctionNodeAlignRotationToVector",
|
|
87
|
+
inputs={"Rotation": rotation, "Factor": factor, "Vector": vector},
|
|
88
|
+
attrs={"axis": axis, "pivot_axis": pivot_axis},
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def axes_to_rotation(
|
|
93
|
+
primary_axis_vector: nt.SocketOrVal[pt.Vector] = (0, 0, 1),
|
|
94
|
+
secondary_axis_vector: nt.SocketOrVal[pt.Vector] = (1, 0, 0),
|
|
95
|
+
primary_axis: Literal["X", "Y", "Z"] = "X",
|
|
96
|
+
secondary_axis: Literal["X", "Y", "Z"] = "Y",
|
|
97
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
98
|
+
"""
|
|
99
|
+
Uses a AxesToRotation Function Node.
|
|
100
|
+
|
|
101
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/axis_to_rotation.html
|
|
102
|
+
"""
|
|
103
|
+
return nt.ProcNode.from_nodetype(
|
|
104
|
+
node_type="FunctionNodeAxesToRotation",
|
|
105
|
+
inputs={
|
|
106
|
+
"Primary Axis": primary_axis_vector,
|
|
107
|
+
"Secondary Axis": secondary_axis_vector,
|
|
108
|
+
},
|
|
109
|
+
attrs={"primary_axis": primary_axis, "secondary_axis": secondary_axis},
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def axis_angle_to_rotation(
|
|
114
|
+
axis: nt.SocketOrVal[pt.Vector] = (0, 0, 1), angle: nt.SocketOrVal[float] = 0.0
|
|
115
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
116
|
+
"""
|
|
117
|
+
Uses a AxisAngleToRotation Function Node.
|
|
118
|
+
|
|
119
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/axis_angle_to_rotation.html
|
|
120
|
+
"""
|
|
121
|
+
return nt.ProcNode.from_nodetype(
|
|
122
|
+
node_type="FunctionNodeAxisAngleToRotation",
|
|
123
|
+
inputs={"Axis": axis, "Angle": angle},
|
|
124
|
+
attrs={},
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def boolean_or(
|
|
129
|
+
a: nt.SocketOrVal[bool] = False,
|
|
130
|
+
b: nt.SocketOrVal[bool] = False,
|
|
131
|
+
) -> nt.ProcNode[bool]:
|
|
132
|
+
return nt.ProcNode.from_nodetype(
|
|
133
|
+
node_type="FunctionNodeBooleanMath",
|
|
134
|
+
inputs={("Boolean", 0): a, ("Boolean", 1): b},
|
|
135
|
+
attrs={"operation": "OR"},
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def boolean_and(
|
|
140
|
+
a: nt.SocketOrVal[bool] = False,
|
|
141
|
+
b: nt.SocketOrVal[bool] = False,
|
|
142
|
+
) -> nt.ProcNode[bool]:
|
|
143
|
+
return nt.ProcNode.from_nodetype(
|
|
144
|
+
node_type="FunctionNodeBooleanMath",
|
|
145
|
+
inputs={("Boolean", 0): a, ("Boolean", 1): b},
|
|
146
|
+
attrs={"operation": "AND"},
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def boolean_xor(
|
|
151
|
+
a: nt.SocketOrVal[bool] = False,
|
|
152
|
+
b: nt.SocketOrVal[bool] = False,
|
|
153
|
+
) -> nt.ProcNode[bool]:
|
|
154
|
+
return nt.ProcNode.from_nodetype(
|
|
155
|
+
node_type="FunctionNodeBooleanMath",
|
|
156
|
+
inputs={("Boolean", 0): a, ("Boolean", 1): b},
|
|
157
|
+
attrs={"operation": "XOR"},
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def boolean_not(
|
|
162
|
+
a: nt.SocketOrVal[bool] = False,
|
|
163
|
+
) -> nt.ProcNode[bool]:
|
|
164
|
+
"""
|
|
165
|
+
Uses a BooleanNot Function Node.
|
|
166
|
+
|
|
167
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/math/boolean_math.html
|
|
168
|
+
"""
|
|
169
|
+
return nt.ProcNode.from_nodetype(
|
|
170
|
+
node_type="FunctionNodeBooleanMath",
|
|
171
|
+
inputs={("Boolean", 0): a},
|
|
172
|
+
attrs={"operation": "NOT"},
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def combine_matrix(
|
|
177
|
+
column_1_row_1: nt.SocketOrVal[float] = 1.0,
|
|
178
|
+
column_1_row_2: nt.SocketOrVal[float] = 0.0,
|
|
179
|
+
column_1_row_3: nt.SocketOrVal[float] = 0.0,
|
|
180
|
+
column_1_row_4: nt.SocketOrVal[float] = 0.0,
|
|
181
|
+
column_2_row_1: nt.SocketOrVal[float] = 0.0,
|
|
182
|
+
column_2_row_2: nt.SocketOrVal[float] = 1.0,
|
|
183
|
+
column_2_row_3: nt.SocketOrVal[float] = 0.0,
|
|
184
|
+
column_2_row_4: nt.SocketOrVal[float] = 0.0,
|
|
185
|
+
column_3_row_1: nt.SocketOrVal[float] = 0.0,
|
|
186
|
+
column_3_row_2: nt.SocketOrVal[float] = 0.0,
|
|
187
|
+
column_3_row_3: nt.SocketOrVal[float] = 1.0,
|
|
188
|
+
column_3_row_4: nt.SocketOrVal[float] = 0.0,
|
|
189
|
+
column_4_row_1: nt.SocketOrVal[float] = 0.0,
|
|
190
|
+
column_4_row_2: nt.SocketOrVal[float] = 0.0,
|
|
191
|
+
column_4_row_3: nt.SocketOrVal[float] = 0.0,
|
|
192
|
+
column_4_row_4: nt.SocketOrVal[float] = 1.0,
|
|
193
|
+
) -> nt.ProcNode[pt.Matrix]:
|
|
194
|
+
"""
|
|
195
|
+
Uses a CombineMatrix Function Node.
|
|
196
|
+
|
|
197
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/combine_matrix.html
|
|
198
|
+
"""
|
|
199
|
+
return nt.ProcNode.from_nodetype(
|
|
200
|
+
node_type="FunctionNodeCombineMatrix",
|
|
201
|
+
inputs={
|
|
202
|
+
"Column 1 Row 1": column_1_row_1,
|
|
203
|
+
"Column 1 Row 2": column_1_row_2,
|
|
204
|
+
"Column 1 Row 3": column_1_row_3,
|
|
205
|
+
"Column 1 Row 4": column_1_row_4,
|
|
206
|
+
"Column 2 Row 1": column_2_row_1,
|
|
207
|
+
"Column 2 Row 2": column_2_row_2,
|
|
208
|
+
"Column 2 Row 3": column_2_row_3,
|
|
209
|
+
"Column 2 Row 4": column_2_row_4,
|
|
210
|
+
"Column 3 Row 1": column_3_row_1,
|
|
211
|
+
"Column 3 Row 2": column_3_row_2,
|
|
212
|
+
"Column 3 Row 3": column_3_row_3,
|
|
213
|
+
"Column 3 Row 4": column_3_row_4,
|
|
214
|
+
"Column 4 Row 1": column_4_row_1,
|
|
215
|
+
"Column 4 Row 2": column_4_row_2,
|
|
216
|
+
"Column 4 Row 3": column_4_row_3,
|
|
217
|
+
"Column 4 Row 4": column_4_row_4,
|
|
218
|
+
},
|
|
219
|
+
attrs={},
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def combine_transform(
|
|
224
|
+
translation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
225
|
+
rotation: Any = (0, 0, 0),
|
|
226
|
+
scale: nt.SocketOrVal[pt.Vector] = (1, 1, 1),
|
|
227
|
+
) -> nt.ProcNode[pt.Matrix]:
|
|
228
|
+
"""
|
|
229
|
+
Uses a CombineTransform Function Node.
|
|
230
|
+
|
|
231
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/combine_transform.html
|
|
232
|
+
"""
|
|
233
|
+
return nt.ProcNode.from_nodetype(
|
|
234
|
+
node_type="FunctionNodeCombineTransform",
|
|
235
|
+
inputs={"Translation": translation, "Rotation": rotation, "Scale": scale},
|
|
236
|
+
attrs={},
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
TCompare = TypeVar(
|
|
241
|
+
"TCompare",
|
|
242
|
+
nt.SocketOrVal[int],
|
|
243
|
+
nt.SocketOrVal[pt.Color],
|
|
244
|
+
nt.SocketOrVal[str],
|
|
245
|
+
nt.SocketOrVal[float],
|
|
246
|
+
nt.SocketOrVal[pt.Vector],
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
TCompareOperation = Literal[
|
|
250
|
+
"LESS_THAN", "LESS_EQUAL", "GREATER_THAN", "GREATER_EQUAL", "EQUAL", "NOT_EQUAL"
|
|
251
|
+
]
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _compare(
|
|
255
|
+
a: TCompare = None,
|
|
256
|
+
b: TCompare = None,
|
|
257
|
+
epsilon: nt.SocketOrVal[float] | None = None,
|
|
258
|
+
operation: TCompareOperation = "EQUAL",
|
|
259
|
+
data_type: NodeDataType | RuntimeResolveDataType | None = None,
|
|
260
|
+
) -> nt.ProcNode[bool]:
|
|
261
|
+
"""
|
|
262
|
+
Uses a Compare Function Node.
|
|
263
|
+
|
|
264
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/math/compare.html
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
# TODO merge with math.less_than etc
|
|
268
|
+
|
|
269
|
+
if data_type is None:
|
|
270
|
+
data_type = RuntimeResolveDataType(
|
|
271
|
+
[
|
|
272
|
+
NodeDataType.INT,
|
|
273
|
+
NodeDataType.FLOAT,
|
|
274
|
+
NodeDataType.RGBA,
|
|
275
|
+
NodeDataType.STRING,
|
|
276
|
+
NodeDataType.FLOAT_VECTOR,
|
|
277
|
+
],
|
|
278
|
+
["A", "B"],
|
|
279
|
+
)
|
|
280
|
+
return nt.ProcNode.from_nodetype(
|
|
281
|
+
node_type="FunctionNodeCompare",
|
|
282
|
+
inputs={"A": a, "B": b, "Epsilon": epsilon},
|
|
283
|
+
attrs={
|
|
284
|
+
"operation": operation,
|
|
285
|
+
"data_type": data_type,
|
|
286
|
+
},
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
TCompareNumeric = TypeVar("TCompareNumeric", nt.SocketOrVal[int], nt.SocketOrVal[float])
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def less_than(
|
|
294
|
+
a: TCompareNumeric = None,
|
|
295
|
+
b: TCompareNumeric = None,
|
|
296
|
+
) -> nt.ProcNode[bool]:
|
|
297
|
+
return _compare(a, b, operation="LESS_THAN")
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def less_equal(
|
|
301
|
+
a: TCompareNumeric = None,
|
|
302
|
+
b: TCompareNumeric = None,
|
|
303
|
+
) -> nt.ProcNode[bool]:
|
|
304
|
+
return _compare(a, b, operation="LESS_EQUAL")
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def greater_than(
|
|
308
|
+
a: TCompareNumeric = None,
|
|
309
|
+
b: TCompareNumeric = None,
|
|
310
|
+
) -> nt.ProcNode[bool]:
|
|
311
|
+
return _compare(a, b, operation="GREATER_THAN")
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def greater_equal(
|
|
315
|
+
a: TCompareNumeric = None,
|
|
316
|
+
b: TCompareNumeric = None,
|
|
317
|
+
) -> nt.ProcNode[bool]:
|
|
318
|
+
return _compare(a, b, operation="GREATER_EQUAL")
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
TCompareEqual = TypeVar(
|
|
322
|
+
"TCompareEqual",
|
|
323
|
+
nt.SocketOrVal[int],
|
|
324
|
+
nt.SocketOrVal[float],
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def equal(
|
|
329
|
+
a: TCompareEqual = None,
|
|
330
|
+
b: TCompareEqual = None,
|
|
331
|
+
epsilon: nt.SocketOrVal[float] | None = None,
|
|
332
|
+
) -> nt.ProcNode[bool]:
|
|
333
|
+
return _compare(a, b, epsilon, operation="EQUAL")
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def not_equal(
|
|
337
|
+
a: TCompareEqual = None,
|
|
338
|
+
b: TCompareEqual = None,
|
|
339
|
+
epsilon: nt.SocketOrVal[float] | None = None,
|
|
340
|
+
) -> nt.ProcNode[bool]:
|
|
341
|
+
return _compare(a, b, epsilon, operation="NOT_EQUAL")
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def vector_compare_elementwise(
|
|
345
|
+
a: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
346
|
+
b: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
347
|
+
epsilon: nt.SocketOrVal[float] = 0.001,
|
|
348
|
+
operation: TCompareOperation = "EQUAL",
|
|
349
|
+
) -> nt.ProcNode[bool]:
|
|
350
|
+
# TODO merge with math.less_than etc
|
|
351
|
+
|
|
352
|
+
return nt.ProcNode.from_nodetype(
|
|
353
|
+
node_type="FunctionNodeCompare",
|
|
354
|
+
inputs={"A": a, "B": b, "Epsilon": epsilon},
|
|
355
|
+
attrs={
|
|
356
|
+
"operation": operation,
|
|
357
|
+
"data_type": NodeDataType.FLOAT_VECTOR,
|
|
358
|
+
"mode": "ELEMENT_WISE",
|
|
359
|
+
},
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def compare_color(
|
|
364
|
+
a: nt.SocketOrVal[pt.Color],
|
|
365
|
+
b: nt.SocketOrVal[pt.Color],
|
|
366
|
+
operation: Literal["EQUAL", "NOT_EQUAL", "BRIGHTER", "DARKER"],
|
|
367
|
+
epsilon: nt.SocketOrVal[float] = 0.001,
|
|
368
|
+
) -> nt.ProcNode[bool]:
|
|
369
|
+
return nt.ProcNode.from_nodetype(
|
|
370
|
+
node_type="FunctionNodeCompare",
|
|
371
|
+
inputs={"A": a, "B": b, "Epsilon": epsilon},
|
|
372
|
+
attrs={"operation": operation},
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def euler_to_rotation(
|
|
377
|
+
euler: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
378
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
379
|
+
"""
|
|
380
|
+
Uses a EulerToRotation Function Node.
|
|
381
|
+
|
|
382
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/euler_to_rotation.html
|
|
383
|
+
"""
|
|
384
|
+
return nt.ProcNode.from_nodetype(
|
|
385
|
+
node_type="FunctionNodeEulerToRotation",
|
|
386
|
+
inputs={"Euler": euler},
|
|
387
|
+
attrs={},
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def float_to_int(
|
|
392
|
+
float: nt.SocketOrVal[float] = 0.0,
|
|
393
|
+
rounding_mode: Literal["ROUND", "FLOOR", "CEILING", "TRUNCATE"] = "ROUND",
|
|
394
|
+
) -> nt.ProcNode[int]:
|
|
395
|
+
"""
|
|
396
|
+
Uses a FloatToInt Function Node.
|
|
397
|
+
|
|
398
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/math/float_to_integer.html
|
|
399
|
+
"""
|
|
400
|
+
return nt.ProcNode.from_nodetype(
|
|
401
|
+
node_type="FunctionNodeFloatToInt",
|
|
402
|
+
inputs={"Float": float},
|
|
403
|
+
attrs={"rounding_mode": rounding_mode},
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
'''
|
|
408
|
+
def input_bool(boolean: bool = False) -> t.ProcNode[bool]:
|
|
409
|
+
"""
|
|
410
|
+
Uses a InputBool Function Node.
|
|
411
|
+
|
|
412
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/input/constant/boolean.html
|
|
413
|
+
"""
|
|
414
|
+
|
|
415
|
+
raise_io_error("input_bool", logger=logger)
|
|
416
|
+
|
|
417
|
+
return t.ProcNode.from_nodetype(
|
|
418
|
+
node_type="FunctionNodeInputBool",
|
|
419
|
+
inputs={},
|
|
420
|
+
attrs={"boolean": boolean},
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def input_color(value: tuple = (0.5, 0.5, 0.5, 1.0)) -> t.ProcNode[pt.Color]:
|
|
425
|
+
"""
|
|
426
|
+
Uses a InputColor Function Node.
|
|
427
|
+
|
|
428
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/input/constant/color.html
|
|
429
|
+
"""
|
|
430
|
+
|
|
431
|
+
raise_io_error("input_color", logger=logger)
|
|
432
|
+
|
|
433
|
+
return t.ProcNode.from_nodetype(
|
|
434
|
+
node_type="FunctionNodeInputColor",
|
|
435
|
+
inputs={},
|
|
436
|
+
attrs={"value": value},
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def input_int(integer: int = 0) -> t.ProcNode[int]:
|
|
441
|
+
"""
|
|
442
|
+
Uses a InputInt Function Node.
|
|
443
|
+
|
|
444
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/input/constant/integer.html
|
|
445
|
+
"""
|
|
446
|
+
|
|
447
|
+
raise_io_error("input_int", logger=logger)
|
|
448
|
+
|
|
449
|
+
return t.ProcNode.from_nodetype(
|
|
450
|
+
node_type="FunctionNodeInputInt",
|
|
451
|
+
inputs={},
|
|
452
|
+
attrs={"integer": integer},
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def input_rotation(rotation_euler: tuple = (0.0, 0.0, 0.0)) -> t.ProcNode[pt.Vector]:
|
|
457
|
+
"""
|
|
458
|
+
Uses a InputRotation Function Node.
|
|
459
|
+
|
|
460
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/input/constant/rotation.html
|
|
461
|
+
"""
|
|
462
|
+
|
|
463
|
+
raise_io_error("input_rotation", logger=logger)
|
|
464
|
+
|
|
465
|
+
return t.ProcNode.from_nodetype(
|
|
466
|
+
node_type="FunctionNodeInputRotation",
|
|
467
|
+
inputs={},
|
|
468
|
+
attrs={"rotation_euler": rotation_euler},
|
|
469
|
+
)
|
|
470
|
+
'''
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
class InputSpecialCharactersResult(NamedTuple):
|
|
474
|
+
line_break: nt.ProcNode[str]
|
|
475
|
+
tab: nt.ProcNode[str]
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def input_special_characters() -> InputSpecialCharactersResult:
|
|
479
|
+
"""
|
|
480
|
+
Uses a InputSpecialCharacters Function Node.
|
|
481
|
+
|
|
482
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/text/special_characters.html
|
|
483
|
+
"""
|
|
484
|
+
|
|
485
|
+
raise_io_error("input_special_characters", logger=logger)
|
|
486
|
+
|
|
487
|
+
node = nt.ProcNode.from_nodetype(
|
|
488
|
+
node_type="FunctionNodeInputSpecialCharacters",
|
|
489
|
+
inputs={},
|
|
490
|
+
attrs={},
|
|
491
|
+
)
|
|
492
|
+
return InputSpecialCharactersResult(
|
|
493
|
+
node._output_socket("line_break"), node._output_socket("tab")
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
def input_string(string: str = "") -> nt.ProcNode[str]:
|
|
498
|
+
"""
|
|
499
|
+
Uses a InputString Function Node.
|
|
500
|
+
|
|
501
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/input/constant/string.html
|
|
502
|
+
"""
|
|
503
|
+
|
|
504
|
+
raise_io_error("input_string", logger=logger)
|
|
505
|
+
|
|
506
|
+
return nt.ProcNode.from_nodetype(
|
|
507
|
+
node_type="FunctionNodeInputString",
|
|
508
|
+
inputs={},
|
|
509
|
+
attrs={"string": string},
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def input_vector(vector: tuple = (0.0, 0.0, 0.0)) -> nt.ProcNode[pt.Vector]:
|
|
514
|
+
"""
|
|
515
|
+
Uses a InputVector Function Node.
|
|
516
|
+
|
|
517
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/input/constant/vector.html
|
|
518
|
+
"""
|
|
519
|
+
|
|
520
|
+
raise_io_error("input_vector", logger=logger)
|
|
521
|
+
|
|
522
|
+
return nt.ProcNode.from_nodetype(
|
|
523
|
+
node_type="FunctionNodeInputVector",
|
|
524
|
+
inputs={},
|
|
525
|
+
attrs={"vector": vector},
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
class InvertMatrixResult(NamedTuple):
|
|
530
|
+
matrix: nt.ProcNode[pt.Matrix]
|
|
531
|
+
invertible: nt.ProcNode[bool]
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
def invert_matrix(matrix: nt.SocketOrVal[pt.Matrix] = None) -> InvertMatrixResult:
|
|
535
|
+
"""
|
|
536
|
+
Uses a InvertMatrix Function Node.
|
|
537
|
+
|
|
538
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/invert_matrix.html
|
|
539
|
+
"""
|
|
540
|
+
node = nt.ProcNode.from_nodetype(
|
|
541
|
+
node_type="FunctionNodeInvertMatrix",
|
|
542
|
+
inputs={"Matrix": matrix},
|
|
543
|
+
attrs={},
|
|
544
|
+
)
|
|
545
|
+
return InvertMatrixResult(
|
|
546
|
+
node._output_socket("matrix"), node._output_socket("invertible")
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def invert_rotation(
|
|
551
|
+
rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
552
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
553
|
+
"""
|
|
554
|
+
Uses a InvertRotation Function Node.
|
|
555
|
+
|
|
556
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/invert_rotation.html
|
|
557
|
+
"""
|
|
558
|
+
return nt.ProcNode.from_nodetype(
|
|
559
|
+
node_type="FunctionNodeInvertRotation",
|
|
560
|
+
inputs={"Rotation": rotation},
|
|
561
|
+
attrs={},
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
def matrix_multiply(
|
|
566
|
+
matrix_0: nt.SocketOrVal[pt.Matrix] = None,
|
|
567
|
+
matrix_1: nt.SocketOrVal[pt.Matrix] = None,
|
|
568
|
+
) -> nt.ProcNode[pt.Matrix]:
|
|
569
|
+
"""
|
|
570
|
+
Uses a MatrixMultiply Function Node.
|
|
571
|
+
|
|
572
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/multiply_matrices.html
|
|
573
|
+
"""
|
|
574
|
+
return nt.ProcNode.from_nodetype(
|
|
575
|
+
node_type="FunctionNodeMatrixMultiply",
|
|
576
|
+
inputs={("Matrix", 0): matrix_0, ("Matrix", 1): matrix_1},
|
|
577
|
+
attrs={},
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def project_point(
|
|
582
|
+
vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
583
|
+
transform: nt.SocketOrVal[pt.Matrix] = None,
|
|
584
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
585
|
+
"""
|
|
586
|
+
Uses a ProjectPoint Function Node.
|
|
587
|
+
|
|
588
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/project_point.html
|
|
589
|
+
"""
|
|
590
|
+
return nt.ProcNode.from_nodetype(
|
|
591
|
+
node_type="FunctionNodeProjectPoint",
|
|
592
|
+
inputs={"Vector": vector, "Transform": transform},
|
|
593
|
+
attrs={},
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def quaternion_to_rotation(
|
|
598
|
+
w: nt.SocketOrVal[float] = 1.0,
|
|
599
|
+
x: nt.SocketOrVal[float] = 0.0,
|
|
600
|
+
y: nt.SocketOrVal[float] = 0.0,
|
|
601
|
+
z: nt.SocketOrVal[float] = 0.0,
|
|
602
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
603
|
+
"""
|
|
604
|
+
Uses a QuaternionToRotation Function Node.
|
|
605
|
+
|
|
606
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/quaternion_to_rotation.html
|
|
607
|
+
"""
|
|
608
|
+
return nt.ProcNode.from_nodetype(
|
|
609
|
+
node_type="FunctionNodeQuaternionToRotation",
|
|
610
|
+
inputs={"W": w, "X": x, "Y": y, "Z": z},
|
|
611
|
+
attrs={},
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
TRandomValue = TypeVar("TRandomValue", int, float, pt.Vector, pt.Color)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
def random_value(
|
|
619
|
+
min: nt.SocketOrVal[TRandomValue] = 0.0,
|
|
620
|
+
max: nt.SocketOrVal[TRandomValue] = 1.0,
|
|
621
|
+
id: nt.SocketOrVal[int] = 0,
|
|
622
|
+
seed: nt.SocketOrVal[int] = 0,
|
|
623
|
+
data_type: NodeDataType | RuntimeResolveDataType | None = None,
|
|
624
|
+
) -> nt.ProcNode[TRandomValue]:
|
|
625
|
+
"""
|
|
626
|
+
Uses a RandomValue Function Node.
|
|
627
|
+
|
|
628
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/random_value.html
|
|
629
|
+
"""
|
|
630
|
+
|
|
631
|
+
if data_type is None:
|
|
632
|
+
data_type = RuntimeResolveDataType(
|
|
633
|
+
[
|
|
634
|
+
NodeDataType.INT,
|
|
635
|
+
NodeDataType.FLOAT,
|
|
636
|
+
NodeDataType.FLOAT_VECTOR,
|
|
637
|
+
NodeDataType.RGBA,
|
|
638
|
+
],
|
|
639
|
+
["Min", "Max"],
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
return nt.ProcNode.from_nodetype(
|
|
643
|
+
node_type="FunctionNodeRandomValue",
|
|
644
|
+
inputs={
|
|
645
|
+
"ID": id,
|
|
646
|
+
"Max": max,
|
|
647
|
+
"Min": min,
|
|
648
|
+
"Seed": seed,
|
|
649
|
+
},
|
|
650
|
+
attrs={"data_type": data_type},
|
|
651
|
+
)
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
def random_boolean(
|
|
655
|
+
probability: nt.SocketOrVal[float] = 0.5,
|
|
656
|
+
id: nt.SocketOrVal[int] = 0,
|
|
657
|
+
seed: nt.SocketOrVal[int] = 0,
|
|
658
|
+
) -> nt.ProcNode[bool]:
|
|
659
|
+
"""
|
|
660
|
+
Uses a RandomBoolean Function Node.
|
|
661
|
+
"""
|
|
662
|
+
return nt.ProcNode.from_nodetype(
|
|
663
|
+
node_type="FunctionNodeRandomValue",
|
|
664
|
+
inputs={"ID": id, "Probability": probability, "Seed": seed},
|
|
665
|
+
attrs={"data_type": NodeDataType.BOOLEAN},
|
|
666
|
+
)
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def replace_string(
|
|
670
|
+
string: nt.SocketOrVal[str] = "",
|
|
671
|
+
find: nt.SocketOrVal[str] = "",
|
|
672
|
+
replace: nt.SocketOrVal[str] = "",
|
|
673
|
+
) -> nt.ProcNode[str]:
|
|
674
|
+
"""
|
|
675
|
+
Uses a ReplaceString Function Node.
|
|
676
|
+
|
|
677
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/text/replace_string.html
|
|
678
|
+
"""
|
|
679
|
+
return nt.ProcNode.from_nodetype(
|
|
680
|
+
node_type="FunctionNodeReplaceString",
|
|
681
|
+
inputs={"String": string, "Find": find, "Replace": replace},
|
|
682
|
+
attrs={},
|
|
683
|
+
)
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def rotate_euler(
|
|
687
|
+
rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
688
|
+
rotate_by: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
689
|
+
rotation_type: Literal["EULER", "AXIS_ANGLE"] = "EULER",
|
|
690
|
+
space: Literal["OBJECT", "LOCAL"] = "OBJECT",
|
|
691
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
692
|
+
"""
|
|
693
|
+
Uses a RotateEuler Function Node.
|
|
694
|
+
|
|
695
|
+
See: http://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/rotate_euler.html
|
|
696
|
+
"""
|
|
697
|
+
return nt.ProcNode.from_nodetype(
|
|
698
|
+
node_type="FunctionNodeRotateEuler",
|
|
699
|
+
inputs={"Rotation": rotation, "Rotate By": rotate_by},
|
|
700
|
+
attrs={"rotation_type": rotation_type, "space": space},
|
|
701
|
+
)
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
def rotate_rotation(
|
|
705
|
+
rotation: Any = (0, 0, 0),
|
|
706
|
+
rotate_by: Any = (0, 0, 0),
|
|
707
|
+
rotation_space: Literal["GLOBAL", "LOCAL"] = "GLOBAL",
|
|
708
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
709
|
+
"""
|
|
710
|
+
Uses a RotateRotation Function Node.
|
|
711
|
+
|
|
712
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/rotate_rotation.html
|
|
713
|
+
"""
|
|
714
|
+
return nt.ProcNode.from_nodetype(
|
|
715
|
+
node_type="FunctionNodeRotateRotation",
|
|
716
|
+
inputs={"Rotation": rotation, "Rotate By": rotate_by},
|
|
717
|
+
attrs={"rotation_space": rotation_space},
|
|
718
|
+
)
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
def rotate_vector(
|
|
722
|
+
vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0), rotation: Any = (0, 0, 0)
|
|
723
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
724
|
+
"""
|
|
725
|
+
Uses a RotateVector Function Node.
|
|
726
|
+
|
|
727
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/rotate_vector.html
|
|
728
|
+
"""
|
|
729
|
+
return nt.ProcNode.from_nodetype(
|
|
730
|
+
node_type="FunctionNodeRotateVector",
|
|
731
|
+
inputs={"Vector": vector, "Rotation": rotation},
|
|
732
|
+
attrs={},
|
|
733
|
+
)
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
class RotationToAxisAngleResult(NamedTuple):
|
|
737
|
+
axis: nt.ProcNode[pt.Vector]
|
|
738
|
+
angle: nt.ProcNode[float]
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
def rotation_to_axis_angle(
|
|
742
|
+
rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
743
|
+
) -> RotationToAxisAngleResult:
|
|
744
|
+
"""
|
|
745
|
+
Uses a RotationToAxisAngle Function Node.
|
|
746
|
+
|
|
747
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/axis_angle_to_rotation.html
|
|
748
|
+
"""
|
|
749
|
+
node = nt.ProcNode.from_nodetype(
|
|
750
|
+
node_type="FunctionNodeRotationToAxisAngle",
|
|
751
|
+
inputs={"Rotation": rotation},
|
|
752
|
+
attrs={},
|
|
753
|
+
)
|
|
754
|
+
return RotationToAxisAngleResult(
|
|
755
|
+
node._output_socket("axis"), node._output_socket("angle")
|
|
756
|
+
)
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def rotation_to_euler(
|
|
760
|
+
rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
761
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
762
|
+
"""
|
|
763
|
+
Uses a RotationToEuler Function Node.
|
|
764
|
+
|
|
765
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/rotation_to_euler.html
|
|
766
|
+
"""
|
|
767
|
+
return nt.ProcNode.from_nodetype(
|
|
768
|
+
node_type="FunctionNodeRotationToEuler",
|
|
769
|
+
inputs={"Rotation": rotation},
|
|
770
|
+
attrs={},
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
class RotationToQuaternionResult(NamedTuple):
|
|
775
|
+
w: nt.ProcNode[float]
|
|
776
|
+
x: nt.ProcNode[float]
|
|
777
|
+
y: nt.ProcNode[float]
|
|
778
|
+
z: nt.ProcNode[float]
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
def rotation_to_quaternion(
|
|
782
|
+
rotation: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
783
|
+
) -> RotationToQuaternionResult:
|
|
784
|
+
"""
|
|
785
|
+
Uses a RotationToQuaternion Function Node.
|
|
786
|
+
|
|
787
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/rotation/rotation_to_quaternion.html
|
|
788
|
+
"""
|
|
789
|
+
node = nt.ProcNode.from_nodetype(
|
|
790
|
+
node_type="FunctionNodeRotationToQuaternion",
|
|
791
|
+
inputs={"Rotation": rotation},
|
|
792
|
+
attrs={},
|
|
793
|
+
)
|
|
794
|
+
return RotationToQuaternionResult(
|
|
795
|
+
node._output_socket("w"),
|
|
796
|
+
node._output_socket("x"),
|
|
797
|
+
node._output_socket("y"),
|
|
798
|
+
node._output_socket("z"),
|
|
799
|
+
)
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
class SeparateColorResult(NamedTuple):
|
|
803
|
+
red: nt.ProcNode[float]
|
|
804
|
+
green: nt.ProcNode[float]
|
|
805
|
+
blue: nt.ProcNode[float]
|
|
806
|
+
alpha: nt.ProcNode[float]
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
def separate_color(
|
|
810
|
+
color: nt.SocketOrVal[pt.Color] = (1, 1, 1, 1),
|
|
811
|
+
mode: Literal["RGB", "HSV", "HSL"] = "RGB",
|
|
812
|
+
ycc_mode: Literal["ITUBT601", "ITUBT709", "JFIF"] = "ITUBT709",
|
|
813
|
+
) -> SeparateColorResult:
|
|
814
|
+
"""
|
|
815
|
+
Uses a SeparateColor Function Node.
|
|
816
|
+
|
|
817
|
+
Context mapping:
|
|
818
|
+
- Shader: ShaderNodeSeparateColor (input: Color, outputs: red/green/blue, mode: RGB only)
|
|
819
|
+
- Compositor: CompositorNodeSeparateColor (input: Image, outputs: red/green/blue/alpha, modes: RGB/HSV/HSL/YCC/YUV, ycc_mode param)
|
|
820
|
+
- Texture: TextureNodeSeparateColor (input: Color, modes: RGB/HSV/HSL)
|
|
821
|
+
- Function: FunctionNodeSeparateColor (input: Color, outputs: red/green/blue/alpha)
|
|
822
|
+
|
|
823
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/color/separate_color.html
|
|
824
|
+
"""
|
|
825
|
+
res = nt.ProcNode.from_nodetype(
|
|
826
|
+
node_type=ContextualNode.SEPARATE_COLOR.value,
|
|
827
|
+
inputs={"Color": color},
|
|
828
|
+
attrs={"mode": mode},
|
|
829
|
+
)
|
|
830
|
+
return SeparateColorResult(
|
|
831
|
+
red=res._output_socket("red"),
|
|
832
|
+
green=res._output_socket("green"),
|
|
833
|
+
blue=res._output_socket("blue"),
|
|
834
|
+
alpha=res._output_socket("alpha"),
|
|
835
|
+
)
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
"""
|
|
839
|
+
def separate_matrix(matrix: t.SocketOrVal[pt.Matrix] = None) -> t.ProcNode[pt.Matrix]:
|
|
840
|
+
|
|
841
|
+
return t.ProcNode.from_nodetype(
|
|
842
|
+
node_type="FunctionNodeSeparateMatrix",
|
|
843
|
+
inputs={"Matrix": matrix},
|
|
844
|
+
attrs={},
|
|
845
|
+
"column_1_row_1",
|
|
846
|
+
"column_1_row_2",
|
|
847
|
+
"column_1_row_3",
|
|
848
|
+
"column_1_row_4",
|
|
849
|
+
"column_2_row_1",
|
|
850
|
+
"column_2_row_2",
|
|
851
|
+
"column_2_row_3",
|
|
852
|
+
"column_2_row_4",
|
|
853
|
+
"column_3_row_1",
|
|
854
|
+
"column_3_row_2",
|
|
855
|
+
"column_3_row_3",
|
|
856
|
+
"column_3_row_4",
|
|
857
|
+
"column_4_row_1",
|
|
858
|
+
"column_4_row_2",
|
|
859
|
+
"column_4_row_3",
|
|
860
|
+
"column_4_row_4",
|
|
861
|
+
],
|
|
862
|
+
)
|
|
863
|
+
"""
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
class SeparateTransformResult(NamedTuple):
|
|
867
|
+
translation: nt.ProcNode[pt.Vector]
|
|
868
|
+
rotation: nt.ProcNode[pt.Vector]
|
|
869
|
+
scale: nt.ProcNode[pt.Vector]
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
def separate_transform(
|
|
873
|
+
transform: nt.SocketOrVal[pt.Matrix] = None,
|
|
874
|
+
) -> SeparateTransformResult:
|
|
875
|
+
"""
|
|
876
|
+
Uses a SeparateTransform Function Node.
|
|
877
|
+
|
|
878
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/separate_transform.html
|
|
879
|
+
"""
|
|
880
|
+
node = nt.ProcNode.from_nodetype(
|
|
881
|
+
node_type="FunctionNodeSeparateTransform",
|
|
882
|
+
inputs={"Transform": transform},
|
|
883
|
+
attrs={},
|
|
884
|
+
)
|
|
885
|
+
return SeparateTransformResult(
|
|
886
|
+
node._output_socket("translation"),
|
|
887
|
+
node._output_socket("rotation"),
|
|
888
|
+
node._output_socket("scale"),
|
|
889
|
+
)
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
def slice_string(
|
|
893
|
+
string: nt.SocketOrVal[str] = "",
|
|
894
|
+
position: nt.SocketOrVal[int] = 0,
|
|
895
|
+
length: nt.SocketOrVal[int] = 10,
|
|
896
|
+
) -> nt.ProcNode[str]:
|
|
897
|
+
"""
|
|
898
|
+
Uses a SliceString Function Node.
|
|
899
|
+
|
|
900
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/text/slice_string.html
|
|
901
|
+
"""
|
|
902
|
+
return nt.ProcNode.from_nodetype(
|
|
903
|
+
node_type="FunctionNodeSliceString",
|
|
904
|
+
inputs={"String": string, "Position": position, "Length": length},
|
|
905
|
+
attrs={},
|
|
906
|
+
)
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
def string_length(string: nt.SocketOrVal[str] = "") -> nt.ProcNode[int]:
|
|
910
|
+
"""
|
|
911
|
+
Uses a StringLength Function Node.
|
|
912
|
+
|
|
913
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/text/string_length.html
|
|
914
|
+
"""
|
|
915
|
+
return nt.ProcNode.from_nodetype(
|
|
916
|
+
node_type="FunctionNodeStringLength",
|
|
917
|
+
inputs={"String": string},
|
|
918
|
+
attrs={},
|
|
919
|
+
)
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
def transform_direction(
|
|
923
|
+
direction: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
924
|
+
transform: nt.SocketOrVal[pt.Matrix] = None,
|
|
925
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
926
|
+
"""
|
|
927
|
+
Uses a TransformDirection Function Node.
|
|
928
|
+
|
|
929
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/transform_direction.html
|
|
930
|
+
"""
|
|
931
|
+
return nt.ProcNode.from_nodetype(
|
|
932
|
+
node_type="FunctionNodeTransformDirection",
|
|
933
|
+
inputs={"Direction": direction, "Transform": transform},
|
|
934
|
+
attrs={},
|
|
935
|
+
)
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
def transform_point(
|
|
939
|
+
vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
940
|
+
transform: nt.SocketOrVal[pt.Matrix] = None,
|
|
941
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
942
|
+
"""
|
|
943
|
+
Uses a TransformPoint Function Node.
|
|
944
|
+
|
|
945
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/transform_point.html
|
|
946
|
+
"""
|
|
947
|
+
return nt.ProcNode.from_nodetype(
|
|
948
|
+
node_type="FunctionNodeTransformPoint",
|
|
949
|
+
inputs={"Vector": vector, "Transform": transform},
|
|
950
|
+
attrs={},
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
def transpose_matrix(
|
|
955
|
+
matrix: nt.SocketOrVal[pt.Matrix] = None,
|
|
956
|
+
) -> nt.ProcNode[pt.Matrix]:
|
|
957
|
+
"""
|
|
958
|
+
Uses a TransposeMatrix Function Node.
|
|
959
|
+
|
|
960
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/matrix/transpose_matrix.html
|
|
961
|
+
"""
|
|
962
|
+
return nt.ProcNode.from_nodetype(
|
|
963
|
+
node_type="FunctionNodeTransposeMatrix",
|
|
964
|
+
inputs={"Matrix": matrix},
|
|
965
|
+
attrs={},
|
|
966
|
+
)
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
def value_to_string(
|
|
970
|
+
value: nt.SocketOrVal[float] = 0.0, decimals: nt.SocketOrVal[int] = 0
|
|
971
|
+
) -> nt.ProcNode[str]:
|
|
972
|
+
"""
|
|
973
|
+
Uses a ValueToString Function Node.
|
|
974
|
+
|
|
975
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/text/value_to_string.html
|
|
976
|
+
"""
|
|
977
|
+
return nt.ProcNode.from_nodetype(
|
|
978
|
+
node_type="FunctionNodeValueToString",
|
|
979
|
+
inputs={"Value": value, "Decimals": decimals},
|
|
980
|
+
attrs={},
|
|
981
|
+
)
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
TMix = TypeVar("TMix", nt.SocketOrVal[float], nt.SocketOrVal[pt.Vector])
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
def mix(
|
|
988
|
+
a: TMix | None = None,
|
|
989
|
+
b: TMix | None = None,
|
|
990
|
+
factor: nt.SocketOrVal[float] = 0.5,
|
|
991
|
+
clamp_factor: bool = True,
|
|
992
|
+
factor_mode: Literal["UNIFORM", "NON_UNIFORM"] = "UNIFORM",
|
|
993
|
+
data_type: NodeDataType | RuntimeResolveDataType | None = None,
|
|
994
|
+
) -> nt.ProcNode[TMix]:
|
|
995
|
+
"""
|
|
996
|
+
Uses MixNode to mix float or vector fields
|
|
997
|
+
|
|
998
|
+
NOTE: procfunc forces all colors to be mixed via mix_rgb, since setting this function
|
|
999
|
+
to type Color adds extra args & exactly matches the interface of mix_rgb
|
|
1000
|
+
|
|
1001
|
+
"""
|
|
1002
|
+
|
|
1003
|
+
if data_type is None:
|
|
1004
|
+
data_type = RuntimeResolveDataType(
|
|
1005
|
+
[NodeDataType.RGBA, NodeDataType.FLOAT, NodeDataType.FLOAT_VECTOR],
|
|
1006
|
+
["A", "B"],
|
|
1007
|
+
)
|
|
1008
|
+
return nt.ProcNode.from_nodetype(
|
|
1009
|
+
node_type="ShaderNodeMix",
|
|
1010
|
+
inputs={"A": a, "B": b, "Factor": factor},
|
|
1011
|
+
attrs={
|
|
1012
|
+
"blend_type": "MIX",
|
|
1013
|
+
"clamp_factor": clamp_factor,
|
|
1014
|
+
"clamp_result": False,
|
|
1015
|
+
"factor_mode": factor_mode,
|
|
1016
|
+
"data_type": data_type,
|
|
1017
|
+
},
|
|
1018
|
+
)
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
TColorMixType = Literal[
|
|
1022
|
+
"MIX",
|
|
1023
|
+
"DARKEN",
|
|
1024
|
+
"MULTIPLY",
|
|
1025
|
+
"BURN",
|
|
1026
|
+
"LIGHTEN",
|
|
1027
|
+
"SCREEN",
|
|
1028
|
+
"DODGE",
|
|
1029
|
+
"ADD",
|
|
1030
|
+
"OVERLAY",
|
|
1031
|
+
"SOFT_LIGHT",
|
|
1032
|
+
"LINEAR_LIGHT",
|
|
1033
|
+
"DIFFERENCE",
|
|
1034
|
+
"EXCLUSION",
|
|
1035
|
+
"SUBTRACT",
|
|
1036
|
+
"DIVIDE",
|
|
1037
|
+
"HUE",
|
|
1038
|
+
"SATURATION",
|
|
1039
|
+
"COLOR",
|
|
1040
|
+
"VALUE",
|
|
1041
|
+
]
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
def mix_rgb(
|
|
1045
|
+
factor: nt.SocketOrVal[float] = 0.5,
|
|
1046
|
+
a: nt.SocketOrVal[pt.Color] = (0.5, 0.5, 0.5, 1),
|
|
1047
|
+
b: nt.SocketOrVal[pt.Color] = (0.5, 0.5, 0.5, 1),
|
|
1048
|
+
blend_type: TColorMixType = "MIX",
|
|
1049
|
+
clamp_result: bool = False,
|
|
1050
|
+
clamp_factor: bool = True,
|
|
1051
|
+
) -> nt.ProcNode[pt.Color]:
|
|
1052
|
+
"""
|
|
1053
|
+
Uses a Mix Node with datatype Color
|
|
1054
|
+
|
|
1055
|
+
NOTE: separated from float/vector mix() due to extra arguments
|
|
1056
|
+
|
|
1057
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/color/mix.html
|
|
1058
|
+
"""
|
|
1059
|
+
return nt.ProcNode.from_nodetype(
|
|
1060
|
+
node_type="ShaderNodeMix",
|
|
1061
|
+
inputs={"Factor": factor, "A": a, "B": b},
|
|
1062
|
+
attrs={
|
|
1063
|
+
"blend_type": blend_type,
|
|
1064
|
+
"clamp_result": clamp_result,
|
|
1065
|
+
"clamp_factor": clamp_factor,
|
|
1066
|
+
"data_type": NodeDataType.RGBA,
|
|
1067
|
+
},
|
|
1068
|
+
)
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
def rgb_curve(
|
|
1072
|
+
fac: nt.SocketOrVal[float] = 1.0,
|
|
1073
|
+
color: nt.SocketOrVal[pt.Color] = (1, 1, 1, 1),
|
|
1074
|
+
curves: list[np.ndarray] | None = None,
|
|
1075
|
+
) -> nt.ProcNode:
|
|
1076
|
+
"""
|
|
1077
|
+
Uses a RGBCurve Shader Node.
|
|
1078
|
+
|
|
1079
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/color/rgb_curves.html
|
|
1080
|
+
"""
|
|
1081
|
+
return nt.ProcNode.from_nodetype(
|
|
1082
|
+
node_type="ShaderNodeRGBCurve",
|
|
1083
|
+
inputs={"Fac": fac, "Color": color},
|
|
1084
|
+
attrs={"curves": curves},
|
|
1085
|
+
)
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
def combine_color(
|
|
1089
|
+
red: nt.SocketOrVal[float] = 0.0,
|
|
1090
|
+
green: nt.SocketOrVal[float] = 0.0,
|
|
1091
|
+
blue: nt.SocketOrVal[float] = 0.0,
|
|
1092
|
+
mode: Literal["RGB", "HSV", "HSL"] = "RGB",
|
|
1093
|
+
) -> nt.ProcNode[pt.Color]:
|
|
1094
|
+
"""
|
|
1095
|
+
Uses a CombineColor Shader Node.
|
|
1096
|
+
|
|
1097
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/combine_color.html
|
|
1098
|
+
"""
|
|
1099
|
+
return nt.ProcNode.from_nodetype(
|
|
1100
|
+
node_type=ContextualNode.COMBINE_COLOR.value,
|
|
1101
|
+
inputs={"Red": red, "Green": green, "Blue": blue},
|
|
1102
|
+
attrs={"mode": mode},
|
|
1103
|
+
)
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
def combine_rgb(
|
|
1107
|
+
red: nt.SocketOrVal[float] = 0.0,
|
|
1108
|
+
green: nt.SocketOrVal[float] = 0.0,
|
|
1109
|
+
blue: nt.SocketOrVal[float] = 0.0,
|
|
1110
|
+
mode: Literal["RGB", "HSV", "HSL"] = "RGB",
|
|
1111
|
+
) -> nt.ProcNode[pt.Color]:
|
|
1112
|
+
"""
|
|
1113
|
+
Uses a CombineColor Shader Node.
|
|
1114
|
+
|
|
1115
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/combine_color.html
|
|
1116
|
+
"""
|
|
1117
|
+
return nt.ProcNode.from_nodetype(
|
|
1118
|
+
node_type=ContextualNode.COMBINE_COLOR.value,
|
|
1119
|
+
inputs={"Red": red, "Green": green, "Blue": blue},
|
|
1120
|
+
attrs={"mode": mode},
|
|
1121
|
+
)
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
def combine_hsv(
|
|
1125
|
+
hue: nt.SocketOrVal[float] = 0.0,
|
|
1126
|
+
saturation: nt.SocketOrVal[float] = 0.0,
|
|
1127
|
+
value: nt.SocketOrVal[float] = 0.0,
|
|
1128
|
+
) -> nt.ProcNode[pt.Color]:
|
|
1129
|
+
"""
|
|
1130
|
+
Uses a CombineColor Shader Node.
|
|
1131
|
+
|
|
1132
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/combine_color.html
|
|
1133
|
+
"""
|
|
1134
|
+
return nt.ProcNode.from_nodetype(
|
|
1135
|
+
node_type=ContextualNode.COMBINE_COLOR.value,
|
|
1136
|
+
inputs={"Hue": hue, "Saturation": saturation, "Value": value},
|
|
1137
|
+
attrs={"mode": "HSV"},
|
|
1138
|
+
)
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
def combine_hsl(
|
|
1142
|
+
hue: nt.SocketOrVal[float] = 0.0,
|
|
1143
|
+
saturation: nt.SocketOrVal[float] = 0.0,
|
|
1144
|
+
lightness: nt.SocketOrVal[float] = 0.0,
|
|
1145
|
+
) -> nt.ProcNode[pt.Color]:
|
|
1146
|
+
"""
|
|
1147
|
+
Uses a CombineHSV Shader Node.
|
|
1148
|
+
|
|
1149
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/combine_color.html
|
|
1150
|
+
"""
|
|
1151
|
+
return nt.ProcNode.from_nodetype(
|
|
1152
|
+
node_type=ContextualNode.COMBINE_COLOR.value,
|
|
1153
|
+
inputs={"Hue": hue, "Saturation": saturation, "Lightness": lightness},
|
|
1154
|
+
attrs={"mode": "HSL"},
|
|
1155
|
+
)
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
def combine_xyz(
|
|
1159
|
+
x: nt.SocketOrVal[float] = 0.0,
|
|
1160
|
+
y: nt.SocketOrVal[float] = 0.0,
|
|
1161
|
+
z: nt.SocketOrVal[float] = 0.0,
|
|
1162
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
1163
|
+
"""
|
|
1164
|
+
Uses a CombineXYZ Shader Node.
|
|
1165
|
+
|
|
1166
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/combine_xyz.html
|
|
1167
|
+
"""
|
|
1168
|
+
return nt.ProcNode.from_nodetype(
|
|
1169
|
+
node_type="ShaderNodeCombineXYZ",
|
|
1170
|
+
inputs={"X": x, "Y": y, "Z": z},
|
|
1171
|
+
attrs={},
|
|
1172
|
+
)
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
class SeparateHsvResult(NamedTuple):
|
|
1176
|
+
h: nt.ProcNode[float]
|
|
1177
|
+
s: nt.ProcNode[float]
|
|
1178
|
+
v: nt.ProcNode[float]
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
def separate_hsv(
|
|
1182
|
+
color: nt.SocketOrVal[pt.Color] = (0.8, 0.8, 0.8, 1),
|
|
1183
|
+
) -> SeparateHsvResult:
|
|
1184
|
+
"""
|
|
1185
|
+
Uses a SeparateHSV Shader Node.
|
|
1186
|
+
|
|
1187
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/separate_color.html
|
|
1188
|
+
"""
|
|
1189
|
+
res = nt.ProcNode.from_nodetype(
|
|
1190
|
+
node_type="ShaderNodeSeparateHSV",
|
|
1191
|
+
inputs={"Color": color},
|
|
1192
|
+
attrs={},
|
|
1193
|
+
)
|
|
1194
|
+
return SeparateHsvResult(
|
|
1195
|
+
h=res._output_socket("h"),
|
|
1196
|
+
s=res._output_socket("s"),
|
|
1197
|
+
v=res._output_socket("v"),
|
|
1198
|
+
)
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
class SeparateRgbResult(NamedTuple):
|
|
1202
|
+
r: nt.ProcNode[float]
|
|
1203
|
+
g: nt.ProcNode[float]
|
|
1204
|
+
b: nt.ProcNode[float]
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
def separate_rgb(
|
|
1208
|
+
image: nt.SocketOrVal[pt.Color] = (0.8, 0.8, 0.8, 1),
|
|
1209
|
+
) -> SeparateRgbResult:
|
|
1210
|
+
"""
|
|
1211
|
+
Uses a SeparateRGB Shader Node.
|
|
1212
|
+
|
|
1213
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/separate_color.html
|
|
1214
|
+
"""
|
|
1215
|
+
res = nt.ProcNode.from_nodetype(
|
|
1216
|
+
node_type="ShaderNodeSeparateRGB",
|
|
1217
|
+
inputs={"Image": image},
|
|
1218
|
+
attrs={},
|
|
1219
|
+
)
|
|
1220
|
+
return SeparateRgbResult(
|
|
1221
|
+
r=res._output_socket("r"),
|
|
1222
|
+
g=res._output_socket("g"),
|
|
1223
|
+
b=res._output_socket("b"),
|
|
1224
|
+
)
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
class SeparateXyzResult(NamedTuple):
|
|
1228
|
+
x: nt.ProcNode[float]
|
|
1229
|
+
y: nt.ProcNode[float]
|
|
1230
|
+
z: nt.ProcNode[float]
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
def separate_xyz(vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0)) -> SeparateXyzResult:
|
|
1234
|
+
"""
|
|
1235
|
+
Uses a SeparateXYZ Shader Node.
|
|
1236
|
+
|
|
1237
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/separate_xyz.html
|
|
1238
|
+
"""
|
|
1239
|
+
node = nt.ProcNode.from_nodetype(
|
|
1240
|
+
node_type="ShaderNodeSeparateXYZ",
|
|
1241
|
+
inputs={"Vector": vector},
|
|
1242
|
+
attrs={},
|
|
1243
|
+
)
|
|
1244
|
+
return SeparateXyzResult(
|
|
1245
|
+
node._output_socket("x"), node._output_socket("y"), node._output_socket("z")
|
|
1246
|
+
)
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
TInterpolationType = Literal["LINEAR", "STEPPED_LINEAR", "SMOOTHSTEP", "SMOOTHERSTEP"]
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
def map_range(
|
|
1253
|
+
value: nt.SocketOrVal[float] = 1.0,
|
|
1254
|
+
from_max: nt.SocketOrVal[float] = 1.0,
|
|
1255
|
+
from_min: nt.SocketOrVal[float] = 0.0,
|
|
1256
|
+
to_max: nt.SocketOrVal[float] = 1.0,
|
|
1257
|
+
to_min: nt.SocketOrVal[float] = 0.0,
|
|
1258
|
+
clamp: bool = True,
|
|
1259
|
+
interpolation_type: TInterpolationType = "LINEAR",
|
|
1260
|
+
data_type: NodeDataType | RuntimeResolveDataType | None = None,
|
|
1261
|
+
) -> nt.ProcNode:
|
|
1262
|
+
"""
|
|
1263
|
+
Uses a MapRange Shader Node.
|
|
1264
|
+
|
|
1265
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/map_range.html
|
|
1266
|
+
"""
|
|
1267
|
+
|
|
1268
|
+
if data_type is None:
|
|
1269
|
+
data_type = RuntimeResolveDataType(
|
|
1270
|
+
[NodeDataType.FLOAT, NodeDataType.FLOAT_VECTOR],
|
|
1271
|
+
["From Max", "From Min", "To Max", "To Min", "Value"],
|
|
1272
|
+
)
|
|
1273
|
+
|
|
1274
|
+
return nt.ProcNode.from_nodetype(
|
|
1275
|
+
node_type="ShaderNodeMapRange",
|
|
1276
|
+
inputs={
|
|
1277
|
+
"From Max": from_max,
|
|
1278
|
+
"From Min": from_min,
|
|
1279
|
+
"To Max": to_max,
|
|
1280
|
+
"To Min": to_min,
|
|
1281
|
+
"Value": value,
|
|
1282
|
+
},
|
|
1283
|
+
attrs={
|
|
1284
|
+
"clamp": clamp,
|
|
1285
|
+
"interpolation_type": interpolation_type,
|
|
1286
|
+
"data_type": data_type,
|
|
1287
|
+
},
|
|
1288
|
+
)
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
def float_curve(
|
|
1292
|
+
factor: nt.SocketOrVal[float] = 1.0,
|
|
1293
|
+
value: nt.SocketOrVal[float] = 1.0,
|
|
1294
|
+
curve: np.ndarray | None = None,
|
|
1295
|
+
handle_type: str = "AUTO",
|
|
1296
|
+
use_clip: bool = True,
|
|
1297
|
+
) -> nt.ProcNode[float]:
|
|
1298
|
+
"""
|
|
1299
|
+
Uses a FloatCurve Shader Node.
|
|
1300
|
+
|
|
1301
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/converter/float_curve.html
|
|
1302
|
+
"""
|
|
1303
|
+
return nt.ProcNode.from_nodetype(
|
|
1304
|
+
node_type="ShaderNodeFloatCurve",
|
|
1305
|
+
inputs={"Factor": factor, "Value": value},
|
|
1306
|
+
attrs={"mapping": curve, "handle_type": handle_type, "use_clip": use_clip},
|
|
1307
|
+
)
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
def vector_curve(
|
|
1311
|
+
fac: nt.SocketOrVal[float] = 1.0,
|
|
1312
|
+
vector: nt.SocketOrVal[pt.Vector] = (0, 0, 0),
|
|
1313
|
+
curves: np.ndarray | None = None,
|
|
1314
|
+
) -> nt.ProcNode[pt.Vector]:
|
|
1315
|
+
"""
|
|
1316
|
+
Uses a VectorCurve Shader Node.
|
|
1317
|
+
|
|
1318
|
+
See: https://docs.blender.org/manual/en/4.2/render/shader_nodes/vector/curves.html
|
|
1319
|
+
"""
|
|
1320
|
+
return nt.ProcNode.from_nodetype(
|
|
1321
|
+
node_type="ShaderNodeVectorCurve",
|
|
1322
|
+
inputs={"Fac": fac, "Vector": vector},
|
|
1323
|
+
attrs={"curves": curves},
|
|
1324
|
+
)
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
TIndexSwitch = TypeVar(
|
|
1328
|
+
"TIndexSwitch",
|
|
1329
|
+
nt.SocketOrVal[bool],
|
|
1330
|
+
nt.SocketOrVal[int],
|
|
1331
|
+
nt.SocketOrVal[pt.Color],
|
|
1332
|
+
nt.SocketOrVal[str],
|
|
1333
|
+
nt.SocketOrVal[float],
|
|
1334
|
+
nt.SocketOrVal[nt.pt.Vector],
|
|
1335
|
+
)
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
def index_switch(
|
|
1339
|
+
val_0: TIndexSwitch = 0,
|
|
1340
|
+
val_1: TIndexSwitch = 0,
|
|
1341
|
+
index: nt.SocketOrVal[int] = 0,
|
|
1342
|
+
data_type: NodeDataType | RuntimeResolveDataType | None = None,
|
|
1343
|
+
) -> nt.ProcNode:
|
|
1344
|
+
"""
|
|
1345
|
+
Uses a IndexSwitch Geometry Node.
|
|
1346
|
+
|
|
1347
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/index_switch.html
|
|
1348
|
+
"""
|
|
1349
|
+
if data_type is None:
|
|
1350
|
+
data_type = RuntimeResolveDataType(
|
|
1351
|
+
[
|
|
1352
|
+
NodeDataType.BOOLEAN,
|
|
1353
|
+
NodeDataType.INT,
|
|
1354
|
+
NodeDataType.RGBA,
|
|
1355
|
+
NodeDataType.STRING,
|
|
1356
|
+
NodeDataType.FLOAT,
|
|
1357
|
+
NodeDataType.FLOAT_VECTOR,
|
|
1358
|
+
],
|
|
1359
|
+
["0", "1"],
|
|
1360
|
+
)
|
|
1361
|
+
return nt.ProcNode.from_nodetype(
|
|
1362
|
+
node_type="GeometryNodeIndexSwitch",
|
|
1363
|
+
inputs={"0": val_0, "1": val_1, "Index": index},
|
|
1364
|
+
attrs={
|
|
1365
|
+
"data_type": data_type,
|
|
1366
|
+
},
|
|
1367
|
+
)
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
TSwitchArgType = TypeVar(
|
|
1371
|
+
"TAnyDataVal",
|
|
1372
|
+
int,
|
|
1373
|
+
float,
|
|
1374
|
+
bool,
|
|
1375
|
+
str,
|
|
1376
|
+
pt.Vector,
|
|
1377
|
+
pt.Color,
|
|
1378
|
+
pt.Matrix,
|
|
1379
|
+
pt.Quaternion,
|
|
1380
|
+
nt.Geometry,
|
|
1381
|
+
)
|
|
1382
|
+
|
|
1383
|
+
_SWITCH_DATA_TYPES = [
|
|
1384
|
+
NodeDataType.BOOLEAN,
|
|
1385
|
+
NodeDataType.INT,
|
|
1386
|
+
NodeDataType.FLOAT,
|
|
1387
|
+
NodeDataType.STRING,
|
|
1388
|
+
NodeDataType.FLOAT_VECTOR,
|
|
1389
|
+
NodeDataType.RGBA,
|
|
1390
|
+
NodeDataType.FLOAT_MATRIX,
|
|
1391
|
+
NodeDataType.GEOMETRY,
|
|
1392
|
+
]
|
|
1393
|
+
|
|
1394
|
+
|
|
1395
|
+
def switch(
|
|
1396
|
+
switch: nt.SocketOrVal[bool] = False,
|
|
1397
|
+
a: nt.SocketOrVal[TSwitchArgType] | None = None,
|
|
1398
|
+
b: nt.SocketOrVal[TSwitchArgType] | None = None,
|
|
1399
|
+
data_type: NodeDataType | RuntimeResolveDataType | None = None,
|
|
1400
|
+
) -> nt.ProcNode[TSwitchArgType]:
|
|
1401
|
+
"""
|
|
1402
|
+
Uses a Switch Geometry Node.
|
|
1403
|
+
|
|
1404
|
+
See: https://docs.blender.org/manual/en/4.2/modeling/geometry_nodes/utilities/switch.html
|
|
1405
|
+
"""
|
|
1406
|
+
|
|
1407
|
+
if data_type is None:
|
|
1408
|
+
data_type = RuntimeResolveDataType(
|
|
1409
|
+
_SWITCH_DATA_TYPES,
|
|
1410
|
+
["False", "True"],
|
|
1411
|
+
)
|
|
1412
|
+
|
|
1413
|
+
return nt.ProcNode.from_nodetype(
|
|
1414
|
+
node_type="GeometryNodeSwitch",
|
|
1415
|
+
inputs={"Switch": switch, "False": a, "True": b},
|
|
1416
|
+
attrs={"input_type": data_type},
|
|
1417
|
+
)
|