Skip to content

Shader

Bases: ShaderRoot, Shader

Source code in core/sock_shader.py
 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
class Shader(ShaderRoot, generated.Shader):

    SOCKET_TYPE = 'SHADER'

    def __init__(self, 
        value: Socket = None,
        name: str = None,
        tip: str = '',
        panel: str = "",
        optional_label: bool = False,
        hide_value: bool = False,
        hide_in_modifier: bool = False,
        ):
        """ Socket of type Shader

        A group input socket of type Shader.

        Parameters
        ----------
        value : Socket
            initial value

        name : str, optional
            group input socket name if not None default=None.

        tip : str, default=''
            Property description

        panel : str, optional
            Panel name default="".

        optional_label : bool, default=False
            Property optional_label

        hide_value : bool, default=False
            Property hide_value

        hide_in_modifier : bool, default=False
            Property hide_in_modifier

        """

        bsock = utils.get_bsocket(value)
        if bsock is None:
            bsock = self._create_input_socket(name=name, tip=tip,
                panel=panel, optional_label=optional_label, hide_value=hide_value,
                hide_in_modifier=hide_in_modifier)

        super().__init__(bsock)


    def out(self, name=None, panel=""):
        """ Shader output
        """
        if self._tree._is_group:
            super().out(name, panel=panel)
        else:
            self._tree.output_node.set_input_socket("Surface", self, create=False)

_interface_socket property

Return the interface socket if exists

An interface socket exists when the socket a tree input or output socket or when it is the socket of a group

Returns:

Type Description
Interface Socket

_name property

Return the name or the label

Returns:

Type Description
str

default is ""

_panel_name property

Return the name of the panel

Returns:

Type Description
str

default is ""

is_grid property

bool property

Returns True if socket is a grid (inferred_structure_type == 'GRID').

node_color property writable

Node color

Returns:

Type Description
SysColor

node_label property writable

Node Label

Returns:

Type Description
str

Constant(value, user_label='') classmethod

Create an input socket from a constant Node.

Parameters:

Name Type Description Default
value Any

constant default value default=None.

required
user_label str

socket name (used to rename nodes if not None) default="".

''
Source code in core/socket_class.py
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
@classmethod
def Constant(cls, value: None, user_label: str = ""):
    """ Create an input socket from a constant Node.

    Parameters
    ----------
    value : Any, optional
        constant default value default=None.

    user_label : str, optional
        socket name (used to rename nodes if not None) default="".

    """

    # ---------------------------------------------------------------------------
    # Ensure array
    # ---------------------------------------------------------------------------

    def get_shaped(v, *shapes):
        r = np.ravel(v)
        shape = np.shape(r)
        if shape in shapes:
            return tuple(r)

        if shape == (1,):
            return tuple(np.resize(r, shapes[0]))

        raise NodeError(
            f"The value <{v}> can't be transformed in a valid initial value for {SocketType(cls.SOCKET_TYPE).class_name}."
        )

    # ---------------------------------------------------------------------------
    # Does the array contain sockets
    # ---------------------------------------------------------------------------

    def has_sockets(a):
        for v in a:
            if SocketType.get_bsocket(v) is not None:
                return True
        return False

    # ---------------------------------------------------------------------------
    # Default value
    # ---------------------------------------------------------------------------

    socket_type = SocketType(cls.SOCKET_TYPE)
    if cls.SOCKET_TYPE not in ['RGBA', 'VECTOR', 'ROTATION', 'MATRIX']:
        def_val = socket_type.get_default_from_value(value)

    # ---------------------------------------------------------------------------
    # Depending on the socket type
    # ---------------------------------------------------------------------------

    if cls.SOCKET_TYPE == 'BOOLEAN':
        return Node('Boolean', boolean=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'BUNDLE':
        return Node("Combine Bundle")._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'CLOSURE':
        socket = ZoneNode.Closure().closure
        socket._use_layout = False
        return socket._ul(user_label)

    elif cls.SOCKET_TYPE == 'COLLECTION':
        return Node('Collection', collection=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'RGBA':

        if value is None:
            a = (0, 0, 0, 1)
        elif isinstance(value, str):
            #a = colors.to_color(value)
            a = SysColor(value).rgba
        else:
            a = get_shaped(value, (4,), (3,))

        if has_sockets(a):
            if Tree.is_geonodes():
                node = Node('Combine Color', {0: a[0], 1: a[1], 2:a[2]})
                if len(a) == 4:
                    node.alpha = a[3]
                return node._out._ul(user_label)
            else:
                return Node('Combine Color', {0: a[0], 1: a[1], 2:a[2]})._out._ul(user_label)

        else:
            def_val = SocketType('COLOR').get_default_from_value(a)
            if Tree.is_geonodes():
                return Node('Color', value=def_val)._out._ul(user_label)

            else:
                socket = Node('Color')._out
                socket._bsocket.default_value = def_val
                return socket._ul(user_label)

    elif cls.SOCKET_TYPE == 'IMAGE':
        return Node('Image', image=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'INT':
        return Node('Integer', integer=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'MATERIAL':
        return Node('Material', material=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'MATRIX':

        if value is None:
            a = (1, 0, 0, 0,   0, 1, 0, 0,   0, 0, 1, 0,   0, 0, 0, 1)
        else:
            a = get_shaped(value, (16,))

        return Node('Combine Matrix', named_sockets = {i: a[i] for i in range(16)})._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'MENU':
        return Node('Menu Switch')._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'OBJECT':
        return Node('Object', object=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'FONT':
        return cls.NewInput("Font", value)

    elif cls.SOCKET_TYPE == 'ROTATION':

        if value is None:
            a = (0, 0, 0)
        else:
            a = get_shaped(value, (3,))

        if has_sockets(a):
            return Node('Combine XYZ', x=a[0], y=a[1], z=a[2])._out.to_rotation()._ul(user_label)
        else:
            return Node('Rotation', rotation_euler=a)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'STRING':
        return Node('String', string=def_val)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'VALUE':
        node = Node('Value')
        node._bnode.outputs[0].default_value = def_val
        return node._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'VECTOR':

        if value is None:
            a = (0, 0, 0)
        else:
            a = get_shaped(value, (3,))

        if has_sockets(a):
            return Node('Combine XYZ', x=a[0], y=a[1], z=a[2])._out._ul(user_label)
        else:
            return Node('Vector', vector=a)._out._ul(user_label)

    elif cls.SOCKET_TYPE == 'GEOMETRY':
        raise NodeError(f"There is no node to create a Geometry. Use explicit constructors such as 'Mesh.Cube()', 'Curve.Spiral()' or 'Cloud.Points().")

    else:
        assert False, f"Shouldn't happen {socket_type}"

Diffuse(color=None, roughness=None, normal=None) classmethod

Node Diffuse BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
normal Vector

socket 'Normal' (id: Normal)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@classmethod
def Diffuse(cls, color: Color = None, roughness: Float = None, normal: Vector = None):
    """ > Node Diffuse BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    normal : Vector, optional
        socket 'Normal' (id: Normal)


    Returns
    -------
    Shader
    """
    node = Node('Diffuse BSDF', {'Color': color, 'Roughness': roughness, 'Normal': normal})
    return cls(node._out)

Emission(color=None, strength=None) classmethod

Node Emission

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
strength Float

socket 'Strength' (id: Strength)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
@classmethod
def Emission(cls, color: Color = None, strength: Float = None):
    """ > Node Emission

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    strength : Float, optional
        socket 'Strength' (id: Strength)


    Returns
    -------
    Shader
    """
    node = Node('Emission', {'Color': color, 'Strength': strength})
    return cls(node._out)

Empty(value=None) classmethod

Create an empty socket.

An empty socket is used temporarily as an input for nodes with dynamic sockets:

Parameters:

Name Type Description Default
value Any

default value default=None.

None
Source code in core/socket_class.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
@classmethod
def Empty(cls, value = None):
    """ Create an empty socket.

    An empty socket is used temporarily as an input for nodes with dynamic sockets:

    Parameters
    ----------
    value : Any, optional
        default value default=None.

    """
    socket = cls(constants.EMPTY_SOCKET)
    socket._bsocket = SocketType(cls.SOCKET_TYPE).get_default_from_value(value)
    return socket

Glass(color=None, roughness=None, ior=None, normal=None, thin_film_thickness=None, thin_film_ior=None, distribution='MULTI_GGX') classmethod

Node Glass BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
ior Float

socket 'IOR' (id: IOR)

None
normal Vector

socket 'Normal' (id: Normal)

None
thin_film_thickness Float

socket 'Thin Film Thickness' (id: Thin Film Thickness)

None
thin_film_ior Float

socket 'Thin Film IOR' (id: Thin Film IOR)

None
distribution Literal['Beckmann', 'GGX', 'Multiscatter GGX']

parameter distribution

'MULTI_GGX'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
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
@classmethod
def Glass(cls,
                color: Color = None,
                roughness: Float = None,
                ior: Float = None,
                normal: Vector = None,
                thin_film_thickness: Float = None,
                thin_film_ior: Float = None,
                distribution: Literal['BECKMANN', 'GGX', 'MULTI_GGX'] = 'MULTI_GGX'):
    """ > Node Glass BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    ior : Float, optional
        socket 'IOR' (id: IOR)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    thin_film_thickness : Float, optional
        socket 'Thin Film Thickness' (id: Thin Film Thickness)

    thin_film_ior : Float, optional
        socket 'Thin Film IOR' (id: Thin Film IOR)

    distribution : Literal['Beckmann', 'GGX', 'Multiscatter GGX']
        parameter `distribution`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Glass BSDF', 'distribution', distribution, 'Glass', ('BECKMANN', 'GGX', 'MULTI_GGX'))
    node = Node('Glass BSDF', {'Color': color, 'Roughness': roughness, 'IOR': ior, 'Normal': normal, 'Thin Film Thickness': thin_film_thickness, 'Thin Film IOR': thin_film_ior}, distribution=distribution)
    return cls(node._out)

Glossy(color=None, roughness=None, anisotropy=None, rotation=None, normal=None, tangent=None, distribution='MULTI_GGX') classmethod

Node Glossy BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
anisotropy Float

socket 'Anisotropy' (id: Anisotropy)

None
rotation Float

socket 'Rotation' (id: Rotation)

None
normal Vector

socket 'Normal' (id: Normal)

None
tangent Vector

socket 'Tangent' (id: Tangent)

None
distribution Literal['Beckmann', 'GGX', 'Ashikhmin-Shirley', 'Multiscatter GGX']

parameter distribution

'MULTI_GGX'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
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
@classmethod
def Glossy(cls,
                color: Color = None,
                roughness: Float = None,
                anisotropy: Float = None,
                rotation: Float = None,
                normal: Vector = None,
                tangent: Vector = None,
                distribution: Literal['BECKMANN', 'GGX', 'ASHIKHMIN_SHIRLEY', 'MULTI_GGX'] = 'MULTI_GGX'):
    """ > Node Glossy BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    anisotropy : Float, optional
        socket 'Anisotropy' (id: Anisotropy)

    rotation : Float, optional
        socket 'Rotation' (id: Rotation)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    tangent : Vector, optional
        socket 'Tangent' (id: Tangent)

    distribution : Literal['Beckmann', 'GGX', 'Ashikhmin-Shirley', 'Multiscatter GGX']
        parameter `distribution`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Glossy BSDF', 'distribution', distribution, 'Glossy', ('BECKMANN', 'GGX', 'ASHIKHMIN_SHIRLEY', 'MULTI_GGX'))
    node = Node('Glossy BSDF', {'Color': color, 'Roughness': roughness, 'Anisotropy': anisotropy, 'Rotation': rotation, 'Normal': normal, 'Tangent': tangent}, distribution=distribution)
    return cls(node._out)

Hair(color=None, offset=None, roughnessu=None, roughnessv=None, tangent=None, component='Reflection') classmethod

Node Hair BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
offset Float

socket 'Offset' (id: Offset)

None
roughnessu Float

socket 'RoughnessU' (id: RoughnessU)

None
roughnessv Float

socket 'RoughnessV' (id: RoughnessV)

None
tangent Vector

socket 'Tangent' (id: Tangent)

None
component Literal['Reflection', 'Transmission']

parameter component

'Reflection'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
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
@classmethod
def Hair(cls,
                color: Color = None,
                offset: Float = None,
                roughnessu: Float = None,
                roughnessv: Float = None,
                tangent: Vector = None,
                component: Literal['Reflection', 'Transmission'] = 'Reflection'):
    """ > Node Hair BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    offset : Float, optional
        socket 'Offset' (id: Offset)

    roughnessu : Float, optional
        socket 'RoughnessU' (id: RoughnessU)

    roughnessv : Float, optional
        socket 'RoughnessV' (id: RoughnessV)

    tangent : Vector, optional
        socket 'Tangent' (id: Tangent)

    component : Literal['Reflection', 'Transmission']
        parameter `component`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Hair BSDF', 'component', component, 'Hair', ('Reflection', 'Transmission'))
    node = Node('Hair BSDF', {'Color': color, 'Offset': offset, 'RoughnessU': roughnessu, 'RoughnessV': roughnessv, 'Tangent': tangent}, component=component)
    return cls(node._out)

Holdout() classmethod

Node Holdout

Returns:

Type Description
Shader
Source code in core/generated/shader.py
693
694
695
696
697
698
699
700
701
702
@classmethod
def Holdout(cls):
    """ > Node Holdout

    Returns
    -------
    Shader
    """
    node = Node('Holdout', )
    return cls(node._out)

IndexSwitch(*values, index=None, default_index=0) classmethod

Node Index Switch

with GeoNodes("IndexSwitch demo"):

    # Create some geometries
    geo    = Geometry()
    cube   = Mesh.Cube()
    sphere = Mesh.IcoSphere()
    cone   = Mesh.Cone()

    # Pick in this list
    pick_geo = Geometry.IndexSwitch(geo, cube, sphere, cone, index=tree.new_input("Geometry index", default_value=2))

    # Plug the result to the output
    pick_geo.out()

Parameters:

Name Type Description Default
*values Any

List of Sockets to select into

()
index Integer

socket 'Index' (Index) default=None.

None
default_index int

default idex default=0.

0

Returns:

Type Description
Socket
Source code in core/socket_class.py
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
@classmethod
def IndexSwitch(cls, *values, index = None, default_index: int = 0):
    """ > Node Index Switch

    ``` python
    with GeoNodes("IndexSwitch demo"):

        # Create some geometries
        geo    = Geometry()
        cube   = Mesh.Cube()
        sphere = Mesh.IcoSphere()
        cone   = Mesh.Cone()

        # Pick in this list
        pick_geo = Geometry.IndexSwitch(geo, cube, sphere, cone, index=tree.new_input("Geometry index", default_value=2))

        # Plug the result to the output
        pick_geo.out()
    ```

    Parameters
    ----------
    *values : Any
        List of Sockets to select into

    index : Integer, optional
        socket 'Index' (Index) default=None.

    default_index : int, optional
        default idex default=0.


    Returns
    -------
    Socket
    """
    #return IndexSwitchNode(*values, index=index, data_type=cls.input_type())._out
    return MenuNode('Index Switch', 
                    {str(i): value for i, value in enumerate(values)}, 
                    data_type=cls.SOCKET_TYPE, 
                    Index=index,
                    default_menu = default_index)._out

Input(name, panel='', halt=True) classmethod

Get an exist input socket from its name and panel.

Note

The "input" socket here is an "output" socket of the current input node

To create a input socket use NewInput.

If the 'name' argument is None, the first socket of the proper type is returned.

Raises:

Type Description
- NodeError if socket is not found and halt is requested

Parameters:

Name Type Description Default
name str | None

socket name

required
panel str

panel name default="".

''
halt bool

raises an error if not found default=True.

True

Returns:

Type Description
Socket
Source code in core/socket_class.py
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
@classmethod
def Input(cls, name: str, panel: str = "", halt: bool = True):
    """ Get an exist input socket from its name and panel.

    !!! note
        The "input" socket here is an "output" socket of the current input node

    To create a input socket use NewInput.

    If the 'name' argument is None, the first socket of the proper type is returned.

    Raises
    ------
    - NodeError if socket is not found and halt is requested

    Parameters
    ----------
    name : str | None
        socket name

    panel : str, optional
        panel name default="".

    halt : bool, optional
        raises an error if not found default=True.


    Returns
    -------
    Socket
    """
    in_node = Tree.current_tree().get_input_node()

    include = None if name is None else [name]
    bsockets = in_node.get_sockets('OUTPUT', include=include, panel=panel)

    for _, bsock in bsockets:
        if SocketType(bsock).type == cls.SOCKET_TYPE: # and utils.snake_case(sock_name) == utils.snake_case(name):
            return cls(bsock._bsocket)._ul(name)

    if halt:
        sname = "" if name is None else f" named '{name}'"
        raise NodeError(
            f"There is no {SocketType(cls.SOCKET_TYPE).class_name} input socket{sname}.\n"
            f"Available sockets are : {[bsock[0] for bsock in in_node.get_sockets('OUTPUT')]}.")

    return None

MenuSwitch(named_sockets={}, default_menu=None, **sockets) classmethod

Node Menu Switch

The items of the Menu Switch node are provided in the 'items' dict.

Parameters:

Name Type Description Default
named_sockets dict

sockets to create default={}.

{}
default_menu str

default menu value default=None.

None
sockets dict

items

{}

Returns:

Type Description
Socket
Source code in core/socket_class.py
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
@classmethod
def MenuSwitch(cls, 
               named_sockets    : dict = {},
               default_menu     : str = None,
               **sockets):
    """ > Node Menu Switch

    The items of the Menu Switch node are provided in the 'items' dict.

    Parameters
    ----------
    named_sockets : dict, optional
        sockets to create default={}.

    default_menu : str, optional
        default menu value default=None.

    sockets : dict
        items


    Returns
    -------
    Socket
    """
    node = MenuNode('Menu Switch',
            named_sockets = named_sockets,
            data_type = SocketType(cls.SOCKET_TYPE).type,
            default_menu = default_menu,
            **sockets)

    return cls(node._out)

Metallic(base_color=None, edge_tint=None, roughness=None, anisotropy=None, rotation=None, normal=None, tangent=None, thin_film_thickness=None, thin_film_ior=None, distribution='MULTI_GGX', fresnel_type='F82') classmethod

Node Metallic BSDF

Parameters:

Name Type Description Default
base_color Color

socket 'Base Color' (id: Base Color)

None
edge_tint Color

socket 'Edge Tint' (id: Edge Tint)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
anisotropy Float

socket 'Anisotropy' (id: Anisotropy)

None
rotation Float

socket 'Rotation' (id: Rotation)

None
normal Vector

socket 'Normal' (id: Normal)

None
tangent Vector

socket 'Tangent' (id: Tangent)

None
thin_film_thickness Float

socket 'Thin Film Thickness' (id: Thin Film Thickness)

None
thin_film_ior Float

socket 'Thin Film IOR' (id: Thin Film IOR)

None
distribution Literal['Beckmann', 'GGX', 'Multiscatter GGX']

parameter distribution

'MULTI_GGX'
fresnel_type Literal['Physical Conductor', 'F82 Tint']

parameter fresnel_type

'F82'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
@classmethod
def Metallic(cls,
                base_color: Color = None,
                edge_tint: Color = None,
                roughness: Float = None,
                anisotropy: Float = None,
                rotation: Float = None,
                normal: Vector = None,
                tangent: Vector = None,
                thin_film_thickness: Float = None,
                thin_film_ior: Float = None,
                distribution: Literal['BECKMANN', 'GGX', 'MULTI_GGX'] = 'MULTI_GGX',
                fresnel_type: Literal['PHYSICAL_CONDUCTOR', 'F82'] = 'F82'):
    """ > Node Metallic BSDF

    Parameters
    ----------
    base_color : Color, optional
        socket 'Base Color' (id: Base Color)

    edge_tint : Color, optional
        socket 'Edge Tint' (id: Edge Tint)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    anisotropy : Float, optional
        socket 'Anisotropy' (id: Anisotropy)

    rotation : Float, optional
        socket 'Rotation' (id: Rotation)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    tangent : Vector, optional
        socket 'Tangent' (id: Tangent)

    thin_film_thickness : Float, optional
        socket 'Thin Film Thickness' (id: Thin Film Thickness)

    thin_film_ior : Float, optional
        socket 'Thin Film IOR' (id: Thin Film IOR)

    distribution : Literal['Beckmann', 'GGX', 'Multiscatter GGX']
        parameter `distribution`

    fresnel_type : Literal['Physical Conductor', 'F82 Tint']
        parameter `fresnel_type`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Metallic BSDF', 'distribution', distribution, 'Metallic', ('BECKMANN', 'GGX', 'MULTI_GGX'))
    utils.check_enum_arg('Metallic BSDF', 'fresnel_type', fresnel_type, 'Metallic', ('PHYSICAL_CONDUCTOR', 'F82'))
    node = Node('Metallic BSDF', {'Base Color': base_color, 'Edge Tint': edge_tint, 'Roughness': roughness, 'Anisotropy': anisotropy, 'Rotation': rotation, 'Normal': normal, 'Tangent': tangent, 'Thin Film Thickness': thin_film_thickness, 'Thin Film IOR': thin_film_ior}, distribution=distribution, fresnel_type=fresnel_type)
    return cls(node._out)

Named(name) classmethod

Node Named Attribute

Information
  • Parameter 'data_type' : 'BOOLEAN'

Parameters:

Name Type Description Default
name String

socket 'Name' (id: Name)

required

Returns:

Type Description
Boolean
Source code in core/socket_class.py
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
@classmethod
def Named(cls, name):
    """ > Node Named Attribute

    Information
    -----------
    - Parameter 'data_type' : 'BOOLEAN'

    Parameters
    ----------
    name : String
        socket 'Name' (id: Name)


    Returns
    -------
    Boolean
    """
    if SocketType(cls.SOCKET_TYPE).class_name not in constants.ATTRIBUTE_CLASSES:
        raise NodeError(
            f"The class {SocketType(cls.SOCKET_TYPE).class_name} is not an attribute.\n"
            f"Attribute classes are: {constants.ATTRIBUTE_CLASSES}")

    node = Node('Named Attribute', name=name)
    data_type = SocketType(cls.SOCKET_TYPE).get_node_data_type(
        tree_type = node._tree._btree.bl_idname,
        bl_idname = node._bnode.bl_idname,
        halt = True)

    node.set_parameter('data_type', data_type)

    return node._out._ul(name)

NewInput(name, value=None, tip='', panel='', **props) classmethod

Create an new input socket

Note

The "input" socket here is an "output" socket of the current input node

To get an existing input socket use Input.

Raises:

Type Description
- NodeError if socket is not found

Parameters:

Name Type Description Default
name str

socket name

required
value Any

default_value default=None.

None
tip str

description default="".

''
panel str: None

panel name

''

Returns:

Type Description
Socket
Source code in core/socket_class.py
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
@classmethod
def NewInput(cls,
        name: str, 
        value       = None, 
        tip: str    = "", 
        panel: str  = "", 
        **props):
    """ Create an new input socket

    !!! note
        The "input" socket here is an "output" socket of the current input node

    To get an existing input socket use Input.

    Raises
    ------
    - NodeError if socket is not found

    Parameters
    ----------
    name : str
        socket name

    value : Any, optional
        default_value default=None.

    tip : str, optional
        description default="".

    panel : str: None
        panel name


    Returns
    -------
    Socket
    """
    if value is None:
        defval = None
    else:
        defval = SocketType(cls.SOCKET_TYPE).get_default_from_value(value)
        new_props = {**props}

        if 'default' in new_props:
            new_props['default'] = defval

        elif 'default_value' in new_props:
            new_props['default_value'] = defval

        else:
            if 'default' not in constants.SOCKETS[cls.SOCKET_TYPE]['props']:
                raise NodeError(f"The {SocketType(cls.SOCKET_TYPE).class_name} socket doesn't accept a default value. Value argument <{value}> is invalid.")

            new_props['default_value'] = defval

        props = new_props

    return cls(Tree.current_tree().create_input_socket(
        SocketType(cls.SOCKET_TYPE).socket_id,
        name         = name,
        tip          = tip,
        panel        = panel,
        **props))

Principled(base_color=None, metallic=None, roughness=None, ior=None, alpha=None, normal=None, diffuse_roughness=None, subsurface_weight=None, subsurface_radius=None, subsurface_scale=None, subsurface_anisotropy=None, specular_ior_level=None, specular_tint=None, anisotropic=None, anisotropic_rotation=None, tangent=None, transmission_weight=None, coat_weight=None, coat_roughness=None, coat_ior=None, coat_tint=None, coat_normal=None, sheen_weight=None, sheen_roughness=None, sheen_tint=None, emission_color=None, emission_strength=None, thin_film_thickness=None, thin_film_ior=None, distribution='MULTI_GGX', subsurface_method='RANDOM_WALK') classmethod

Node Principled BSDF

Parameters:

Name Type Description Default
base_color Color

socket 'Base Color' (id: Base Color)

None
metallic Float

socket 'Metallic' (id: Metallic)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
ior Float

socket 'IOR' (id: IOR)

None
alpha Float

socket 'Alpha' (id: Alpha)

None
normal Vector

socket 'Normal' (id: Normal)

None
diffuse_roughness Float

socket 'Diffuse Roughness' (id: Diffuse Roughness)

None
subsurface_weight Float

socket 'Subsurface Weight' (id: Subsurface Weight)

None
subsurface_radius Vector

socket 'Subsurface Radius' (id: Subsurface Radius)

None
subsurface_scale Float

socket 'Subsurface Scale' (id: Subsurface Scale)

None
subsurface_anisotropy Float

socket 'Subsurface Anisotropy' (id: Subsurface Anisotropy)

None
specular_ior_level Float

socket 'Specular IOR Level' (id: Specular IOR Level)

None
specular_tint Color

socket 'Specular Tint' (id: Specular Tint)

None
anisotropic Float

socket 'Anisotropic' (id: Anisotropic)

None
anisotropic_rotation Float

socket 'Anisotropic Rotation' (id: Anisotropic Rotation)

None
tangent Vector

socket 'Tangent' (id: Tangent)

None
transmission_weight Float

socket 'Transmission Weight' (id: Transmission Weight)

None
coat_weight Float

socket 'Coat Weight' (id: Coat Weight)

None
coat_roughness Float

socket 'Coat Roughness' (id: Coat Roughness)

None
coat_ior Float

socket 'Coat IOR' (id: Coat IOR)

None
coat_tint Color

socket 'Coat Tint' (id: Coat Tint)

None
coat_normal Vector

socket 'Coat Normal' (id: Coat Normal)

None
sheen_weight Float

socket 'Sheen Weight' (id: Sheen Weight)

None
sheen_roughness Float

socket 'Sheen Roughness' (id: Sheen Roughness)

None
sheen_tint Color

socket 'Sheen Tint' (id: Sheen Tint)

None
emission_color Color

socket 'Emission Color' (id: Emission Color)

None
emission_strength Float

socket 'Emission Strength' (id: Emission Strength)

None
thin_film_thickness Float

socket 'Thin Film Thickness' (id: Thin Film Thickness)

None
thin_film_ior Float

socket 'Thin Film IOR' (id: Thin Film IOR)

None
distribution Literal['GGX', 'Multiscatter GGX']

parameter distribution

'MULTI_GGX'
subsurface_method Literal['Christensen-Burley', 'Random Walk', 'Random Walk (Skin)']

parameter subsurface_method

'RANDOM_WALK'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
@classmethod
def Principled(cls,
                base_color: Color = None,
                metallic: Float = None,
                roughness: Float = None,
                ior: Float = None,
                alpha: Float = None,
                normal: Vector = None,
                diffuse_roughness: Float = None,
                subsurface_weight: Float = None,
                subsurface_radius: Vector = None,
                subsurface_scale: Float = None,
                subsurface_anisotropy: Float = None,
                specular_ior_level: Float = None,
                specular_tint: Color = None,
                anisotropic: Float = None,
                anisotropic_rotation: Float = None,
                tangent: Vector = None,
                transmission_weight: Float = None,
                coat_weight: Float = None,
                coat_roughness: Float = None,
                coat_ior: Float = None,
                coat_tint: Color = None,
                coat_normal: Vector = None,
                sheen_weight: Float = None,
                sheen_roughness: Float = None,
                sheen_tint: Color = None,
                emission_color: Color = None,
                emission_strength: Float = None,
                thin_film_thickness: Float = None,
                thin_film_ior: Float = None,
                distribution: Literal['GGX', 'MULTI_GGX'] = 'MULTI_GGX',
                subsurface_method: Literal['BURLEY', 'RANDOM_WALK', 'RANDOM_WALK_SKIN'] = 'RANDOM_WALK'):
    """ > Node Principled BSDF

    Parameters
    ----------
    base_color : Color, optional
        socket 'Base Color' (id: Base Color)

    metallic : Float, optional
        socket 'Metallic' (id: Metallic)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    ior : Float, optional
        socket 'IOR' (id: IOR)

    alpha : Float, optional
        socket 'Alpha' (id: Alpha)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    diffuse_roughness : Float, optional
        socket 'Diffuse Roughness' (id: Diffuse Roughness)

    subsurface_weight : Float, optional
        socket 'Subsurface Weight' (id: Subsurface Weight)

    subsurface_radius : Vector, optional
        socket 'Subsurface Radius' (id: Subsurface Radius)

    subsurface_scale : Float, optional
        socket 'Subsurface Scale' (id: Subsurface Scale)

    subsurface_anisotropy : Float, optional
        socket 'Subsurface Anisotropy' (id: Subsurface Anisotropy)

    specular_ior_level : Float, optional
        socket 'Specular IOR Level' (id: Specular IOR Level)

    specular_tint : Color, optional
        socket 'Specular Tint' (id: Specular Tint)

    anisotropic : Float, optional
        socket 'Anisotropic' (id: Anisotropic)

    anisotropic_rotation : Float, optional
        socket 'Anisotropic Rotation' (id: Anisotropic Rotation)

    tangent : Vector, optional
        socket 'Tangent' (id: Tangent)

    transmission_weight : Float, optional
        socket 'Transmission Weight' (id: Transmission Weight)

    coat_weight : Float, optional
        socket 'Coat Weight' (id: Coat Weight)

    coat_roughness : Float, optional
        socket 'Coat Roughness' (id: Coat Roughness)

    coat_ior : Float, optional
        socket 'Coat IOR' (id: Coat IOR)

    coat_tint : Color, optional
        socket 'Coat Tint' (id: Coat Tint)

    coat_normal : Vector, optional
        socket 'Coat Normal' (id: Coat Normal)

    sheen_weight : Float, optional
        socket 'Sheen Weight' (id: Sheen Weight)

    sheen_roughness : Float, optional
        socket 'Sheen Roughness' (id: Sheen Roughness)

    sheen_tint : Color, optional
        socket 'Sheen Tint' (id: Sheen Tint)

    emission_color : Color, optional
        socket 'Emission Color' (id: Emission Color)

    emission_strength : Float, optional
        socket 'Emission Strength' (id: Emission Strength)

    thin_film_thickness : Float, optional
        socket 'Thin Film Thickness' (id: Thin Film Thickness)

    thin_film_ior : Float, optional
        socket 'Thin Film IOR' (id: Thin Film IOR)

    distribution : Literal['GGX', 'Multiscatter GGX']
        parameter `distribution`

    subsurface_method : Literal['Christensen-Burley', 'Random Walk', 'Random Walk (Skin)']
        parameter `subsurface_method`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Principled BSDF', 'distribution', distribution, 'Principled', ('GGX', 'MULTI_GGX'))
    utils.check_enum_arg('Principled BSDF', 'subsurface_method', subsurface_method, 'Principled', ('BURLEY', 'RANDOM_WALK', 'RANDOM_WALK_SKIN'))
    node = Node('Principled BSDF', {'Base Color': base_color, 'Metallic': metallic, 'Roughness': roughness, 'IOR': ior, 'Alpha': alpha, 'Normal': normal, 'Diffuse Roughness': diffuse_roughness, 'Subsurface Weight': subsurface_weight, 'Subsurface Radius': subsurface_radius, 'Subsurface Scale': subsurface_scale, 'Subsurface Anisotropy': subsurface_anisotropy, 'Specular IOR Level': specular_ior_level, 'Specular Tint': specular_tint, 'Anisotropic': anisotropic, 'Anisotropic Rotation': anisotropic_rotation, 'Tangent': tangent, 'Transmission Weight': transmission_weight, 'Coat Weight': coat_weight, 'Coat Roughness': coat_roughness, 'Coat IOR': coat_ior, 'Coat Tint': coat_tint, 'Coat Normal': coat_normal, 'Sheen Weight': sheen_weight, 'Sheen Roughness': sheen_roughness, 'Sheen Tint': sheen_tint, 'Emission Color': emission_color, 'Emission Strength': emission_strength, 'Thin Film Thickness': thin_film_thickness, 'Thin Film IOR': thin_film_ior}, distribution=distribution, subsurface_method=subsurface_method)
    return cls(node._out)

PrincipledHair(color=None, roughness=None, radial_roughness=None, coat=None, ior=None, offset=None, random_roughness=None, random=None, model='CHIANG', parametrization='COLOR') classmethod

Node Principled Hair BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
radial_roughness Float

socket 'Radial Roughness' (id: Radial Roughness)

None
coat Float

socket 'Coat' (id: Coat)

None
ior Float

socket 'IOR' (id: IOR)

None
offset Float

socket 'Offset' (id: Offset)

None
random_roughness Float

socket 'Random Roughness' (id: Random Roughness)

None
random Float

socket 'Random' (id: Random)

None
model Literal['Chiang', 'Huang']

parameter model

'CHIANG'
parametrization Literal['Absorption Coefficient', 'Melanin Concentration', 'Direct Coloring']

parameter parametrization

'COLOR'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
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
@classmethod
def PrincipledHair(cls,
                color: Color = None,
                roughness: Float = None,
                radial_roughness: Float = None,
                coat: Float = None,
                ior: Float = None,
                offset: Float = None,
                random_roughness: Float = None,
                random: Float = None,
                model: Literal['CHIANG', 'HUANG'] = 'CHIANG',
                parametrization: Literal['ABSORPTION', 'MELANIN', 'COLOR'] = 'COLOR'):
    """ > Node Principled Hair BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    radial_roughness : Float, optional
        socket 'Radial Roughness' (id: Radial Roughness)

    coat : Float, optional
        socket 'Coat' (id: Coat)

    ior : Float, optional
        socket 'IOR' (id: IOR)

    offset : Float, optional
        socket 'Offset' (id: Offset)

    random_roughness : Float, optional
        socket 'Random Roughness' (id: Random Roughness)

    random : Float, optional
        socket 'Random' (id: Random)

    model : Literal['Chiang', 'Huang']
        parameter `model`

    parametrization : Literal['Absorption Coefficient', 'Melanin Concentration', 'Direct Coloring']
        parameter `parametrization`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Principled Hair BSDF', 'model', model, 'PrincipledHair', ('CHIANG', 'HUANG'))
    utils.check_enum_arg('Principled Hair BSDF', 'parametrization', parametrization, 'PrincipledHair', ('ABSORPTION', 'MELANIN', 'COLOR'))
    node = Node('Principled Hair BSDF', {'Color': color, 'Roughness': roughness, 'Radial Roughness': radial_roughness, 'Coat': coat, 'IOR': ior, 'Offset': offset, 'Random Roughness': random_roughness, 'Random': random}, model=model, parametrization=parametrization)
    return cls(node._out)

RayPortal(color=None, position=None, direction=None) classmethod

Node Ray Portal BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
position Vector

socket 'Position' (id: Position)

None
direction Vector

socket 'Direction' (id: Direction)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
@classmethod
def RayPortal(cls, color: Color = None, position: Vector = None, direction: Vector = None):
    """ > Node Ray Portal BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    position : Vector, optional
        socket 'Position' (id: Position)

    direction : Vector, optional
        socket 'Direction' (id: Direction)


    Returns
    -------
    Shader
    """
    node = Node('Ray Portal BSDF', {'Color': color, 'Position': position, 'Direction': direction})
    return cls(node._out)

Refraction(color=None, roughness=None, ior=None, normal=None, distribution='BECKMANN') classmethod

Node Refraction BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
ior Float

socket 'IOR' (id: IOR)

None
normal Vector

socket 'Normal' (id: Normal)

None
distribution Literal['Beckmann', 'GGX']

parameter distribution

'BECKMANN'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
@classmethod
def Refraction(cls,
                color: Color = None,
                roughness: Float = None,
                ior: Float = None,
                normal: Vector = None,
                distribution: Literal['BECKMANN', 'GGX'] = 'BECKMANN'):
    """ > Node Refraction BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    ior : Float, optional
        socket 'IOR' (id: IOR)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    distribution : Literal['Beckmann', 'GGX']
        parameter `distribution`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Refraction BSDF', 'distribution', distribution, 'Refraction', ('BECKMANN', 'GGX'))
    node = Node('Refraction BSDF', {'Color': color, 'Roughness': roughness, 'IOR': ior, 'Normal': normal}, distribution=distribution)
    return cls(node._out)

Sheen(color=None, roughness=None, normal=None, distribution='MICROFIBER') classmethod

Node Sheen BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
normal Vector

socket 'Normal' (id: Normal)

None
distribution Literal['Ashikhmin', 'Microfiber']

parameter distribution

'MICROFIBER'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
@classmethod
def Sheen(cls,
                color: Color = None,
                roughness: Float = None,
                normal: Vector = None,
                distribution: Literal['ASHIKHMIN', 'MICROFIBER'] = 'MICROFIBER'):
    """ > Node Sheen BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    distribution : Literal['Ashikhmin', 'Microfiber']
        parameter `distribution`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Sheen BSDF', 'distribution', distribution, 'Sheen', ('ASHIKHMIN', 'MICROFIBER'))
    node = Node('Sheen BSDF', {'Color': color, 'Roughness': roughness, 'Normal': normal}, distribution=distribution)
    return cls(node._out)

Specular(base_color=None, specular=None, roughness=None, emissive_color=None, transparency=None, normal=None, clear_coat=None, clear_coat_roughness=None, clear_coat_normal=None) classmethod

Node Specular BSDF

Parameters:

Name Type Description Default
base_color Color

socket 'Base Color' (id: Base Color)

None
specular Color

socket 'Specular' (id: Specular)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
emissive_color Color

socket 'Emissive Color' (id: Emissive Color)

None
transparency Float

socket 'Transparency' (id: Transparency)

None
normal Vector

socket 'Normal' (id: Normal)

None
clear_coat Float

socket 'Clear Coat' (id: Clear Coat)

None
clear_coat_roughness Float

socket 'Clear Coat Roughness' (id: Clear Coat Roughness)

None
clear_coat_normal Vector

socket 'Clear Coat Normal' (id: Clear Coat Normal)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
@classmethod
def Specular(cls,
                base_color: Color = None,
                specular: Color = None,
                roughness: Float = None,
                emissive_color: Color = None,
                transparency: Float = None,
                normal: Vector = None,
                clear_coat: Float = None,
                clear_coat_roughness: Float = None,
                clear_coat_normal: Vector = None):
    """ > Node Specular BSDF

    Parameters
    ----------
    base_color : Color, optional
        socket 'Base Color' (id: Base Color)

    specular : Color, optional
        socket 'Specular' (id: Specular)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    emissive_color : Color, optional
        socket 'Emissive Color' (id: Emissive Color)

    transparency : Float, optional
        socket 'Transparency' (id: Transparency)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    clear_coat : Float, optional
        socket 'Clear Coat' (id: Clear Coat)

    clear_coat_roughness : Float, optional
        socket 'Clear Coat Roughness' (id: Clear Coat Roughness)

    clear_coat_normal : Vector, optional
        socket 'Clear Coat Normal' (id: Clear Coat Normal)


    Returns
    -------
    Shader
    """
    node = Node('Specular BSDF', {'Base Color': base_color, 'Specular': specular, 'Roughness': roughness, 'Emissive Color': emissive_color, 'Transparency': transparency, 'Normal': normal, 'Clear Coat': clear_coat, 'Clear Coat Roughness': clear_coat_roughness, 'Clear Coat Normal': clear_coat_normal})
    return cls(node._out)

SubsurfaceScattering(color=None, scale=None, radius=None, ior=None, roughness=None, anisotropy=None, normal=None, falloff='RANDOM_WALK') classmethod

Node Subsurface Scattering

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
scale Float

socket 'Scale' (id: Scale)

None
radius Vector

socket 'Radius' (id: Radius)

None
ior Float

socket 'IOR' (id: IOR)

None
roughness Float

socket 'Roughness' (id: Roughness)

None
anisotropy Float

socket 'Anisotropy' (id: Anisotropy)

None
normal Vector

socket 'Normal' (id: Normal)

None
falloff Literal['Christensen-Burley', 'Random Walk', 'Random Walk (Skin)']

parameter falloff

'RANDOM_WALK'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
@classmethod
def SubsurfaceScattering(cls,
                color: Color = None,
                scale: Float = None,
                radius: Vector = None,
                ior: Float = None,
                roughness: Float = None,
                anisotropy: Float = None,
                normal: Vector = None,
                falloff: Literal['BURLEY', 'RANDOM_WALK', 'RANDOM_WALK_SKIN'] = 'RANDOM_WALK'):
    """ > Node Subsurface Scattering

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    scale : Float, optional
        socket 'Scale' (id: Scale)

    radius : Vector, optional
        socket 'Radius' (id: Radius)

    ior : Float, optional
        socket 'IOR' (id: IOR)

    roughness : Float, optional
        socket 'Roughness' (id: Roughness)

    anisotropy : Float, optional
        socket 'Anisotropy' (id: Anisotropy)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    falloff : Literal['Christensen-Burley', 'Random Walk', 'Random Walk (Skin)']
        parameter `falloff`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Subsurface Scattering', 'falloff', falloff, 'SubsurfaceScattering', ('BURLEY', 'RANDOM_WALK', 'RANDOM_WALK_SKIN'))
    node = Node('Subsurface Scattering', {'Color': color, 'Scale': scale, 'Radius': radius, 'IOR': ior, 'Roughness': roughness, 'Anisotropy': anisotropy, 'Normal': normal}, falloff=falloff)
    return cls(node._out)

Switch(condition=None, false=None, true=None) classmethod

Node Switch

with GeoNodes("Switch demo"):

    # Two possible geometries
    cube   = Mesh.Cube()
    sphere = Mesh.IcoSphere()

    # Select
    geo = Geometry.Switch(Boolean(True, "Use Sphere"), cube, sphere)

    # To group output
    geo.out()

Parameters:

Name Type Description Default
condition Boolean

socket 'Switch' (Switch)

None
false

socket 'False' (False)

None
true

socket 'True' (True)

None

Returns:

Type Description
Socket
Source code in core/socket_class.py
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
@classmethod
def Switch(cls, condition=None, false=None, true=None):
    """ > Node Switch

    ``` python
    with GeoNodes("Switch demo"):

        # Two possible geometries
        cube   = Mesh.Cube()
        sphere = Mesh.IcoSphere()

        # Select
        geo = Geometry.Switch(Boolean(True, "Use Sphere"), cube, sphere)

        # To group output
        geo.out()
    ```

    Parameters
    ----------
    condition : Boolean
        socket 'Switch' (Switch)

    false
        socket 'False' (False)

    true
        socket 'True' (True)


    Returns
    -------
    Socket
    """
    input_type = SocketType(cls.SOCKET_TYPE).items_type
    return Node('Switch', {'Switch': condition, 'False': false, 'True': true}, input_type=input_type)._out

Toon(color=None, size=None, smooth=None, normal=None, component='DIFFUSE') classmethod

Node Toon BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
size Float

socket 'Size' (id: Size)

None
smooth Float

socket 'Smooth' (id: Smooth)

None
normal Vector

socket 'Normal' (id: Normal)

None
component Literal['Diffuse', 'Glossy']

parameter component

'DIFFUSE'

Returns:

Type Description
Shader
Source code in core/generated/shader.py
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
@classmethod
def Toon(cls,
                color: Color = None,
                size: Float = None,
                smooth: Float = None,
                normal: Vector = None,
                component: Literal['DIFFUSE', 'GLOSSY'] = 'DIFFUSE'):
    """ > Node Toon BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    size : Float, optional
        socket 'Size' (id: Size)

    smooth : Float, optional
        socket 'Smooth' (id: Smooth)

    normal : Vector, optional
        socket 'Normal' (id: Normal)

    component : Literal['Diffuse', 'Glossy']
        parameter `component`


    Returns
    -------
    Shader
    """
    utils.check_enum_arg('Toon BSDF', 'component', component, 'Toon', ('DIFFUSE', 'GLOSSY'))
    node = Node('Toon BSDF', {'Color': color, 'Size': size, 'Smooth': smooth, 'Normal': normal}, component=component)
    return cls(node._out)

Translucent(color=None, normal=None) classmethod

Node Translucent BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None
normal Vector

socket 'Normal' (id: Normal)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
@classmethod
def Translucent(cls, color: Color = None, normal: Vector = None):
    """ > Node Translucent BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)

    normal : Vector, optional
        socket 'Normal' (id: Normal)


    Returns
    -------
    Shader
    """
    node = Node('Translucent BSDF', {'Color': color, 'Normal': normal})
    return cls(node._out)

Transparent(color=None) classmethod

Node Transparent BSDF

Parameters:

Name Type Description Default
color Color

socket 'Color' (id: Color)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
@classmethod
def Transparent(cls, color: Color = None):
    """ > Node Transparent BSDF

    Parameters
    ----------
    color : Color, optional
        socket 'Color' (id: Color)


    Returns
    -------
    Shader
    """
    node = Node('Transparent BSDF', {'Color': color})
    return cls(node._out)

__init__(value=None, name=None, tip='', panel='', optional_label=False, hide_value=False, hide_in_modifier=False)

Socket of type Shader

A group input socket of type Shader.

Parameters:

Name Type Description Default
value Socket

initial value

None
name str

group input socket name if not None default=None.

None
tip str

Property description

''
panel str

Panel name default="".

''
optional_label bool

Property optional_label

False
hide_value bool

Property hide_value

False
hide_in_modifier bool

Property hide_in_modifier

False
Source code in core/sock_shader.py
 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
def __init__(self, 
    value: Socket = None,
    name: str = None,
    tip: str = '',
    panel: str = "",
    optional_label: bool = False,
    hide_value: bool = False,
    hide_in_modifier: bool = False,
    ):
    """ Socket of type Shader

    A group input socket of type Shader.

    Parameters
    ----------
    value : Socket
        initial value

    name : str, optional
        group input socket name if not None default=None.

    tip : str, default=''
        Property description

    panel : str, optional
        Panel name default="".

    optional_label : bool, default=False
        Property optional_label

    hide_value : bool, default=False
        Property hide_value

    hide_in_modifier : bool, default=False
        Property hide_in_modifier

    """

    bsock = utils.get_bsocket(value)
    if bsock is None:
        bsock = self._create_input_socket(name=name, tip=tip,
            panel=panel, optional_label=optional_label, hide_value=hide_value,
            hide_in_modifier=hide_in_modifier)

    super().__init__(bsock)

_create_input_socket(name='Shader', tip='', panel='', optional_label=False, hide_value=False, hide_in_modifier=False) classmethod

Shader Input

New Shader input with subtype 'NONE'.

Parameters:

Name Type Description Default
name str

Input socket name

`Shader`
tip str

Property description

`''`
panel str

Panel name

``
optional_label bool

Property optional_label

`False`
hide_value bool

Property hide_value

`False`
hide_in_modifier bool

Property hide_in_modifier

`False`

Returns:

Type Description
Shader
Source code in core/generated/shader.py
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
@classmethod
def _create_input_socket(cls,
    name: str = 'Shader',
    tip: str = '',
    panel: str = "",
    optional_label: bool = False,
    hide_value: bool = False,
    hide_in_modifier: bool = False,
     ):
    """ > Shader Input

    New Shader input with subtype 'NONE'.

    Parameters
    ----------
    name : str, default=`Shader`
        Input socket name

    tip : str, default=`''`
        Property description

    panel : str, default=``
        Panel name

    optional_label : bool, default=`False`
        Property optional_label

    hide_value : bool, default=`False`
        Property hide_value

    hide_in_modifier : bool, default=`False`
        Property hide_in_modifier


    Returns
    -------
    Shader
    """
    from ..treeclass import Tree

    return Tree.current_tree().create_input_socket('NodeSocketShader', name=name, tip=tip, panel=panel,
        optional_label=optional_label, hide_value=hide_value, hide_in_modifier=hide_in_modifier)

_get_bsocket_from_input(name=None)

Get the availble input socket if any.

The socket is get a an OUTPUT socket of the current input.

Parameters:

Name Type Description Default
name str

name filter default=None.

None

Returns:

Type Description
Socket

or None if not found

Source code in core/socket_class.py
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
def _get_bsocket_from_input(self, name: str = None) -> bpy.types.NodeSocket:
    """ Get the availble input socket if any.

    The socket is get a an OUTPUT socket of the current input.

    Parameters
    ----------
    name : str, optional
        name filter default=None.


    Returns
    -------
    Socket
        or None if not found

    """
    in_node = self._tree.get_input_node()

    include = None if name is None else [name]

    bsockets = in_node.get_sockets('OUTPUT', include=include)
    for _, bsock in bsockets:
        if SocketType(bsock).type == self.SOCKET_TYPE:
            return bsock._bsocket
    else:
        return None

_jump(socket, reset=True)

Change the wrapped output socket

When changing the socket, the description is copied to the new socket. The node color, if any, is also propagated.

Parameters:

Name Type Description Default
socket NodeSocket

the new output socket to jump to

required
reset bool

reset the cache default=True.

True

Returns:

Type Description
self
Source code in core/socket_class.py
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
def _jump(self, socket: bpy.types.NodeSocket, reset: bool = True):
    """ Change the wrapped output socket

    When changing the socket, the description is copied to the new socket.
    The node color, if any, is also propagated.

    Parameters
    ----------
    socket : bpy.types.NodeSocket
        the new output socket to jump to

    reset : bool, optional
        reset the cache default=True.


    Returns
    -------
    self
    """

    # Keep user label stored in socket description
    user_label = self.user_label

    bsocket = utils.get_bsocket(socket)
    if bsocket is None:
        raise NodeError(f"Socket error: Impossible to jump to socket {socket}")

    self._bsocket = bsocket
    if reset:
        self._reset()

    # Restore user label
    self.user_label = user_label


    return self

_lc(label=None, color=None)

Set node label and color.

This method returns self to be chained to as socket:

with GeoNodes("Node label and color"):
    Geometry().out()

    a = Float(10)._lc("Var a")
    b = Float(10)._lc("Var b")
    c = (a + b)._lc("a + b", (1, 0, 0))

Parameters:

Name Type Description Default
label str

node label default=None.

None
color SysColor

node color default=None.

None

Returns:

Type Description
self
Source code in core/socket_class.py
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
def _lc(self, label: str = None, color: SysColor = None):
    """ Set node label and color.

    This method returns self to be chained to as socket:

    ``` python
    with GeoNodes("Node label and color"):
        Geometry().out()

        a = Float(10)._lc("Var a")
        b = Float(10)._lc("Var b")
        c = (a + b)._lc("a + b", (1, 0, 0))
    ```

    Parameters
    ----------
    label : str, optional
        node label default=None.

    color : SysColor, optional
        node color default=None.


    Returns
    -------
    self
    """

    if self.node._bnode.bl_idname == 'NodeGroupInput':
        return self

    self.node_label = label
    self.node_color = color
    self.user_label = label

    return self

_ul(label)

Set the user label

Parameters:

Name Type Description Default
label str

the label to append

required

Returns:

Type Description
self
Source code in core/socket_class.py
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
def _ul(self, label : str):
    """ Set the user label

    Parameters
    ----------
    label : str
        the label to append


    Returns
    -------
    self
    """
    self.user_label = label
    return self

add(shader=None)

Node Add Shader

Fixed values

Kind Name Value
Socket Shader self

Parameters:

Name Type Description Default
shader Shader

socket 'Shader' (id: Shader_001)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def add(self, shader: Shader = None):
    """ > Node Add Shader

    **Fixed values**

    | Kind   | Name   | Value  |
    | ------ | ------ | ------ |
    | Socket | Shader | `self` |

    Parameters
    ----------
    shader : Shader, optional
        socket 'Shader' (id: Shader_001)


    Returns
    -------
    Shader
    """
    node = Node('Add Shader', {'Shader': self, 'Shader_001': shader})
    return node._out

add_method(name=None, jump=False, ret_class=None, **fixed)

Add the current tree as a method of the Socket class.

Important

The socket instance must be an input socket of the Tree. This input plays the role of self argument.

with GeoNodes("Translate"):
    geo = Geometry()
    v = Vector(0, "Translation)
    geo.transform(translation=v)

    geo.add_method(jump=True)

Once the modifier completed, it can be called as a method of geometry geo.translate(translation=(1, 2, 3))

Parameters:

Name Type Description Default
name str

replace the default name which is the snake case version of the group name default=None.

None
ret_class type

transtype the default node output default=None.

None
jump bool

the calling socket jumps to the node outpus after the call default=False.

False
ret_class type

transtype the result with this class if not None default=None.

None
Source code in core/socket_class.py
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
def add_method(self, name: str = None, jump: bool = False, ret_class: type = None, **fixed):
    """ Add the current tree as a method of the Socket class.

    !!! important

        The socket instance must be an input socket of the Tree. This input plays the role of
        self argument.

    ``` python
    with GeoNodes("Translate"):
        geo = Geometry()
        v = Vector(0, "Translation)
        geo.transform(translation=v)

        geo.add_method(jump=True)
    ```

    Once the modifier completed, it can be called as a method of geometry ```geo.translate(translation=(1, 2, 3))```

    Parameters
    ----------
    name : str, optional
        replace the default name which is the snake case version of the group name default=None.

    ret_class : type, optional
        transtype the default node output default=None.

    jump : bool, optional
        the calling socket jumps to the node outpus after the call default=False.

    ret_class : type, optional
        transtype the result with this class if not None default=None.

    """

    if self.node._bnode.bl_idname != 'NodeGroupInput':
        raise NodeError(
            f"'add_method' can be called only from a 'Group Input' socket. "
            "This socket is used a 'self' argument when calling the method of {type(self).__name__}.")

    tree = Tree.current_tree()

    # ---------------------------------------------------------------------------
    # Method Body
    # ---------------------------------------------------------------------------

    socket_rank = self.node._outputs.get_socket_rank(self)
    socket_name = utils.snake_case(self._bsocket.name)


    def call(self_, *args, **kwargs):
        node = Group(tree._btree.name)
        if socket_rank >= len(args):
            new_args = args
            new_kwargs = {socket_name: self_, **kwargs}
        else:
            new_args = args[:socket_rank] + (self_,) + args[socket_rank:]
            new_kwargs = kwargs

        res = node.method_call(*new_args, ret_class=ret_class, **new_kwargs, **fixed)

        if jump:
            return self_._jump(res)
        else:
            return res

    # ---------------------------------------------------------------------------
    # Add the method to the class
    # ---------------------------------------------------------------------------

    if name is None:
        name = tree._btree.name[len(tree._prefix):].strip()
        name = utils.snake_case(name)

    class_ = type(self)
    if name in dir(class_):
        print(f"CAUTION: the method '{name}' (implementing group '{tree._btree.name}') already exists in class {class_}.")

    setattr(class_, name, call)

index_switch(*values, index=None, default_index=0)

Node Index Switch

with GeoNodes("index_switch demo") as tree:

    # Create some geometries
    geo    = Geometry()
    cube   = Mesh.Cube()
    sphere = Mesh.IcoSphere()
    cone   = Mesh.Cone()

    # Pick in this list
    pick_geo = geo.index_switch(cube, sphere, cone, index=tree.new_input("Geometry index", default_value=2))

    # Plug the result to the output
    pick_geo.out()

Parameters:

Name Type Description Default
*values Any

List of Sockets to select into

()
index Integer

socket 'Index' (Index)

None
default_index int

default idex

0

Returns:

Type Description
Socket
Source code in core/socket_class.py
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
def index_switch(self, *values, index = None, default_index: int = 0):
    """ > Node Index Switch

    ``` python
    with GeoNodes("index_switch demo") as tree:

        # Create some geometries
        geo    = Geometry()
        cube   = Mesh.Cube()
        sphere = Mesh.IcoSphere()
        cone   = Mesh.Cone()

        # Pick in this list
        pick_geo = geo.index_switch(cube, sphere, cone, index=tree.new_input("Geometry index", default_value=2))

        # Plug the result to the output
        pick_geo.out()
    ```

    Parameters
    ----------
    *values : Any
        List of Sockets to select into

    index : Integer, optional
        socket 'Index' (Index)

    default_index : int, default=0
        default idex

    Returns
    -------
    Socket
    """
    return self.IndexSwitch(self, *values, index=index, default_index=default_index)

light_output(is_active_output=True, target='ALL')

Node Light Output

Fixed values

Kind Name Value
Socket Surface self

Parameters:

Name Type Description Default
is_active_output bool

parameter is_active_output

True
target Literal['All', 'EEVEE', 'Cycles']

parameter target

'ALL'

Returns:

Type Description
None
Source code in core/generated/shader.py
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
def light_output(self,
                is_active_output = True,
                target: Literal['ALL', 'EEVEE', 'CYCLES'] = 'ALL'):
    """ > Node Light Output

    **Fixed values**

    | Kind   | Name    | Value  |
    | ------ | ------- | ------ |
    | Socket | Surface | `self` |

    Parameters
    ----------
    is_active_output : bool
        parameter `is_active_output`

    target : Literal['All', 'EEVEE', 'Cycles']
        parameter `target`


    Returns
    -------
    None
    """
    utils.check_enum_arg('Light Output', 'target', target, 'light_output', ('ALL', 'EEVEE', 'CYCLES'))
    node = Node('Light Output', {'Surface': self}, is_active_output=is_active_output, target=target)
    return node._out

Link input sockets of the node

Allow to chain input sockets linking.

Source code in core/socket_class.py
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
def link_inputs(self,
    from_node   : Node = None,
    from_panel  : str = "",
    *,
    include     : list =  None,
    exclude     : list  = [],
    panel       : str = "",
    ):
    """ Link input sockets of the node

    Allow to chain input sockets linking.
    """
    self.node.link_inputs(from_node, from_panel=from_panel, include=include, exclude=exclude, panel=panel)
    return self

Link panel input sockets of the node

Allow to chain input sockets linking.

Source code in core/socket_class.py
1021
1022
1023
1024
1025
1026
1027
def link_panel(self, panel: str, from_node : Node = None):
    """ Link panel input sockets of the node

    Allow to chain input sockets linking.
    """
    self.node.link_panel(panel, from_node=from_node)
    return self

material_output(volume=None, displacement=None, thickness=None, is_active_output=True, target='ALL')

Node Material Output

Fixed values

Kind Name Value
Socket Surface self

Parameters:

Name Type Description Default
volume VolumeShader

socket 'Volume' (id: Volume)

None
displacement Vector

socket 'Displacement' (id: Displacement)

None
thickness Float

socket 'Thickness' (id: Thickness)

None
is_active_output bool

parameter is_active_output

True
target Literal['All', 'EEVEE', 'Cycles']

parameter target

'ALL'

Returns:

Type Description
None
Source code in core/generated/shader.py
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
def material_output(self,
                volume: VolumeShader = None,
                displacement: Vector = None,
                thickness: Float = None,
                is_active_output = True,
                target: Literal['ALL', 'EEVEE', 'CYCLES'] = 'ALL'):
    """ > Node Material Output

    **Fixed values**

    | Kind   | Name    | Value  |
    | ------ | ------- | ------ |
    | Socket | Surface | `self` |

    Parameters
    ----------
    volume : VolumeShader, optional
        socket 'Volume' (id: Volume)

    displacement : Vector, optional
        socket 'Displacement' (id: Displacement)

    thickness : Float, optional
        socket 'Thickness' (id: Thickness)

    is_active_output : bool
        parameter `is_active_output`

    target : Literal['All', 'EEVEE', 'Cycles']
        parameter `target`


    Returns
    -------
    None
    """
    utils.check_enum_arg('Material Output', 'target', target, 'material_output', ('ALL', 'EEVEE', 'CYCLES'))
    node = Node('Material Output', {'Surface': self, 'Volume': volume, 'Displacement': displacement, 'Thickness': thickness}, is_active_output=is_active_output, target=target)
    return node._out

menu_switch(self_name='Self', named_sockets={}, default_menu=None, **sockets)

Node Menu Switch

[&NO_JUMP]

Self is connected to the first menu item with the name provided as argument.

The items of the Menu Switch node are provided in the 'items' dict. An group input socket named after the 'name' argument is linked to menu selector.

Parameters:

Name Type Description Default
named_sockets dict

sockets to create default={}.

{}
default_menu str

default menu value default=None.

None
sockets dict

items

{}

Returns:

Type Description
Socket
Source code in core/socket_class.py
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
def menu_switch(self,
            self_name       : str = 'Self', 
            named_sockets   : dict = {},
            default_menu    : str = None,
            **sockets):
    """ > Node Menu Switch

    [&NO_JUMP]

    Self is connected to the first menu item with the name provided as argument.

    The items of the Menu Switch node are provided in the 'items' dict.
    An group input socket named after the 'name' argument is linked to menu selector.

    Parameters
    ----------
    named_sockets : dict, optional
        sockets to create default={}.

    default_menu : str, optional
        default menu value default=None.

    sockets : dict
        items


    Returns
    -------
    Socket
    """        
    return self.MenuSwitch(named_sockets = {self_name: self, **named_sockets}, default_menu=default_menu, **sockets)

mix(shader=None, factor=None)

Node Mix Shader

Fixed values

Kind Name Value
Socket Shader self

Parameters:

Name Type Description Default
shader Shader

socket 'Shader' (id: Shader_001)

None
factor Float

socket 'Factor' (id: Fac)

None

Returns:

Type Description
Shader
Source code in core/generated/shader.py
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
def mix(self, shader: Shader = None, factor: Float = None):
    """ > Node Mix Shader

    **Fixed values**

    | Kind   | Name   | Value  |
    | ------ | ------ | ------ |
    | Socket | Shader | `self` |

    Parameters
    ----------
    shader : Shader, optional
        socket 'Shader' (id: Shader_001)

    factor : Float, optional
        socket 'Factor' (id: Fac)


    Returns
    -------
    Shader
    """
    node = Node('Mix Shader', {'Shader': self, 'Shader_001': shader, 'Fac': factor})
    return node._out

out(name=None, panel='')

Shader output

Source code in core/sock_shader.py
142
143
144
145
146
147
148
def out(self, name=None, panel=""):
    """ Shader output
    """
    if self._tree._is_group:
        super().out(name, panel=panel)
    else:
        self._tree.output_node.set_input_socket("Surface", self, create=False)

repeat(iterations=1, named_sockets={}, **sockets)

Repeat zone

Parameters:

Name Type Description Default
iterations Integer

iteration socket

1
named_sockets dict

named sockets

{}
sockets dict

other sockets

{}

Returns:

Type Description
ZoneIterator
Source code in core/socket_class.py
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
def repeat(self, iterations=1, named_sockets: dict={}, **sockets):
    """ Repeat zone

    Parameters
    ----------
    iterations : Integer, default=1
        iteration socket

    named_sockets : dict, default={}
        named sockets

    sockets : dict, optional
        other sockets


    Returns
    -------
    ZoneIterator
    """
    class_name = type(self).__name__
    node = ZoneNode("Repeat", named_sockets={class_name: self, **named_sockets}, Iterations=iterations, **sockets)
    return ZoneIterator(self, node)

simulation(named_sockets={}, **sockets)

Simulation zone

Parameters:

Name Type Description Default
named_sockets dict

named sockets

{}
sockets dict

other sockets

{}

Returns:

Type Description
ZoneIterator
Source code in core/socket_class.py
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
def simulation(self, named_sockets: dict={}, **sockets):
    """ Simulation zone

    Parameters
    ----------
    named_sockets : dict, default={}
        named sockets

    sockets : dict, optional
        other sockets

    Returns
    -------
    ZoneIterator
    """
    class_name = type(self).__name__
    node = ZoneNode("Simulation", named_sockets={class_name: self, **named_sockets}, **sockets)
    return ZoneIterator(self, node)

surface_out(target='ALL')

Connect the shader to the Surface socket of Material Output

Parameters:

Name Type Description Default
target str

parameter ' target' in ('ALL', 'EEVEE', 'CYCLES') default='ALL'.

'ALL'
Source code in core/sock_shader.py
54
55
56
57
58
59
60
61
62
63
def surface_out(self, target='ALL'):
    """ Connect the shader to the Surface socket of Material Output

    Parameters
    ----------
    target : str, optional
        parameter ' target' in ('ALL', 'EEVEE', 'CYCLES') default='ALL'.

    """
    self._tree.set_surface(self, target=target)

switch(condition=None, true=None)

Node Switch

Self is connected to 'false' socket.

Note

switch returns self if global constant SWITCH_JUMP = True (default) set SWITCH_JUMP = False for legacy behavior

with GeoNodes("Switch demo"):

    from geonodes.core import constants
    # Legacy behavior (default is True)
    constants.SWITCH_JUMP = False

    choice = Boolean(True, "Use Sphere")

    # Two possible geometries
    cube   = Mesh.Cube()
    sphere = Mesh.IcoSphere()

    # Select
    # Legacy behavior: cube is unchanged otherwise cube
    geo = cube.switch(choice, sphere)

    # To group output
    geo.out()
Information
  • Socket 'False' : self

Parameters:

Name Type Description Default
condition Boolean

socket 'Switch' (Switch)

None
true

socket 'True' (True)

None

Returns:

Type Description
Socket(self)
Source code in core/socket_class.py
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
def switch(self, condition=None, true=None):
    """ > Node Switch

    Self is connected to 'false' socket.

    !!! note
        switch returns self if global constant SWITCH_JUMP = True (default)
        set SWITCH_JUMP = False for legacy behavior

    ``` python
    with GeoNodes("Switch demo"):

        from geonodes.core import constants
        # Legacy behavior (default is True)
        constants.SWITCH_JUMP = False

        choice = Boolean(True, "Use Sphere")

        # Two possible geometries
        cube   = Mesh.Cube()
        sphere = Mesh.IcoSphere()

        # Select
        # Legacy behavior: cube is unchanged otherwise cube
        geo = cube.switch(choice, sphere)

        # To group output
        geo.out()
    ```

    Information
    -----------
    - Socket 'False' : self

    Parameters
    ----------
    condition : Boolean
        socket 'Switch' (Switch)

    true
        socket 'True' (True)


    Returns
    -------
    Socket (self)
    """
    res = self.Switch(condition=condition, false=self, true=true)
    if constants.SWITCH_JUMP:
        return self._jump(res)
    else:
        return res

switch_false(condition=None, false=None)

Node Switch

[&JUMP]

Self is connected to 'true' socket.

Important

This methods behaves the inverse of switch : self is connected to "True" socket and the argument to "False", socket

Note

This method is mainly provided to cover the case when 'False' socket is None

with GeoNodes("Switch demo"):

    geo = Geometry()

    show_geometry = Boolean(False, "Merge with Cube")

    cube = Mesh.Cube()

    geo += cube.switch_false(show_geometry)

    # Is equivalent to
    geo += Geometry.Switch(show_geometry, None, cube)

    # To group output
    geo.out()

Note

This method let self socket unchanged. To set self socket to the result

Information
  • Socket 'True' : self

Parameters:

Name Type Description Default
condition Boolean

socket 'Switch' (Switch)

None
false

socket 'False' (False)

None

Returns:

Type Description
Socket
Source code in core/socket_class.py
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
def switch_false(self, condition=None, false=None):
    """ > Node Switch

    [&JUMP]

    Self is connected to 'true' socket.

    !!! important
        This methods behaves the inverse of switch : self is connected to "True" socket and  the argument to "False", socket

    !!! note
        This method is mainly provided to cover the case when 'False' socket is None

    ``` python
    with GeoNodes("Switch demo"):

        geo = Geometry()

        show_geometry = Boolean(False, "Merge with Cube")

        cube = Mesh.Cube()

        geo += cube.switch_false(show_geometry)

        # Is equivalent to
        geo += Geometry.Switch(show_geometry, None, cube)

        # To group output
        geo.out()
    ```

    !!! note
        This method let self socket unchanged. To set self socket to the result

    Information
    -----------
    - Socket 'True' : self

    Parameters
    ----------
    condition : Boolean
        socket 'Switch' (Switch)

    false
        socket 'False' (False)


    Returns
    -------
    Socket
    """
    res = self.Switch(condition=condition, false=false, true=self)
    if constants.SWITCH_JUMP:
        return self._jump(res)
    else:
        return res

to_rgb()

Node Shader to RGB

Fixed values

Kind Name Value
Socket Shader self

Returns:

Type Description
Color

peer sockets: alpha_ (Float)

Source code in core/generated/shader.py
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
def to_rgb(self):
    """ > Node Shader to RGB

    **Fixed values**

    | Kind   | Name   | Value  |
    | ------ | ------ | ------ |
    | Socket | Shader | `self` |

    Returns
    -------
    Color
        peer sockets: alpha_ (Float)

    """
    node = Node('Shader to RGB', {'Shader': self})
    return node._out

volume_out(target='ALL')

Connect the shader to the Volume socket of Material Output

Parameters:

Name Type Description Default
target str

parameter ' target' in ('ALL', 'EEVEE', 'CYCLES') default='ALL'.

'ALL'
Source code in core/sock_shader.py
65
66
67
68
69
70
71
72
73
74
def volume_out(self, target='ALL'):
    """ Connect the shader to the Volume socket of Material Output

    Parameters
    ----------
    target : str, optional
        parameter ' target' in ('ALL', 'EEVEE', 'CYCLES') default='ALL'.

    """
    self._tree.set_volume(self, target=target)

world_output(volume=None, is_active_output=True, target='ALL')

Node World Output

Fixed values

Kind Name Value
Socket Surface self

Parameters:

Name Type Description Default
volume VolumeShader

socket 'Volume' (id: Volume)

None
is_active_output bool

parameter is_active_output

True
target Literal['All', 'EEVEE', 'Cycles']

parameter target

'ALL'

Returns:

Type Description
None
Source code in core/generated/shader.py
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
def world_output(self,
                volume: VolumeShader = None,
                is_active_output = True,
                target: Literal['ALL', 'EEVEE', 'CYCLES'] = 'ALL'):
    """ > Node World Output

    **Fixed values**

    | Kind   | Name    | Value  |
    | ------ | ------- | ------ |
    | Socket | Surface | `self` |

    Parameters
    ----------
    volume : VolumeShader, optional
        socket 'Volume' (id: Volume)

    is_active_output : bool
        parameter `is_active_output`

    target : Literal['All', 'EEVEE', 'Cycles']
        parameter `target`


    Returns
    -------
    None
    """
    utils.check_enum_arg('World Output', 'target', target, 'world_output', ('ALL', 'EEVEE', 'CYCLES'))
    node = Node('World Output', {'Surface': self, 'Volume': volume}, is_active_output=is_active_output, target=target)
    return node._out