forked from prman-pixar/RenderManForBlender
-
Notifications
You must be signed in to change notification settings - Fork 2
/
shader_parameters.py
673 lines (580 loc) · 27.2 KB
/
shader_parameters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
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
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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
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
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
672
673
# ##### BEGIN MIT LICENSE BLOCK #####
#
# Copyright (c) 2015 - 2017 Pixar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
# ##### END MIT LICENSE BLOCK #####
import os
import subprocess
import bpy
import re
import sys
from collections import OrderedDict
from .util import init_env
from .util import get_path_list
from .util import path_list_convert
from .util import path_win_to_unixy
from .util import user_path
from .util import get_sequence_path
from .util import args_files_in_path
from bpy.props import *
from .rman_utils import texture_utils
def sp_optionmenu_to_string(options):
return [(opt.attrib['value'], opt.attrib['name'],
'') for opt in options.findall('string')]
def parse_float(fs):
if fs is None:
return 0.0
return float(fs[:-1]) if 'f' in fs else float(fs)
def generate_page(sp, node, parent_name, first_level=False):
prop_names = []
prop_meta = {}
if "__annotations__" not in node.__dict__:
setattr(node, "__annotations__", {})
# don't add the sub group to prop names,
# they'll be gotten through recursion
if first_level:
param_name = 'enable' + parent_name.replace(' ', '')
prop_names.append(param_name)
prop_meta[param_name] = {
'renderman_type': 'enum', 'renderman_name': param_name}
default = parent_name == 'Diffuse'
prop = BoolProperty(name="Enable " + parent_name,
default=bool(default),
update=update_func_with_inputs)
node.__annotations__[param_name] = prop
for sub_param in sp.findall('param') + sp.findall('page'):
if sub_param.tag == 'page':
name = parent_name + '.' + sub_param.attrib['name']
sub_names, sub_meta = generate_page(sub_param, node, name)
setattr(node, name, sub_names)
# props.append(sub_props)
prop_meta.update(sub_meta)
prop_meta[name] = {'renderman_type': 'page'}
prop_names.append(name)
ui_label = "%s_uio" % name
node.__annotations__[ui_label] = BoolProperty(name=ui_label, default=False)
else:
name, meta, prop = generate_property(sub_param)
if name is None:
continue
prop_names.append(name)
prop_meta[name] = meta
node.__annotations__[name] = prop
# if name == sp.attrib['name']:
# name = name + '_prop'
return prop_names, prop_meta
def class_generate_properties(node, parent_name, shaderparameters):
prop_names = []
prop_meta = {}
output_meta = OrderedDict()
if "__annotations__" not in node.__dict__:
setattr(node, "__annotations__", {})
# pxr osl and seexpr need these to find the code
if parent_name in ["PxrOSL", "PxrSeExpr"]:
# Enum for internal, external type selection
EnumName = "codetypeswitch"
if parent_name == 'PxrOSL':
EnumProp = EnumProperty(items=(('EXT', "External", ""),
('INT', "Internal", "")),
name="Shader Location", default='INT')
else:
EnumProp = EnumProperty(items=(('NODE', "Node", ""),
('INT', "Internal", "")),
name="Expr Location", default='NODE')
EnumMeta = {'renderman_name': 'filename',
'name': 'codetypeswitch',
'renderman_type': 'string',
'default': '', 'label': 'codetypeswitch',
'type': 'enum', 'options': '',
'widget': 'mapper', '__noconnection': True}
node.__annotations__[EnumName] = EnumProp
prop_names.append(EnumName)
prop_meta[EnumName] = EnumMeta
# Internal file search prop
InternalName = "internalSearch"
InternalProp = StringProperty(name="Shader to use",
description="Storage space for internal text data block",
default="")
InternalMeta = {'renderman_name': 'filename',
'name': 'internalSearch',
'renderman_type': 'string',
'default': '', 'label': 'internalSearch',
'type': 'string', 'options': '',
'widget': 'fileinput', '__noconnection': True}
node.__annotations__[InternalName] = InternalProp
prop_names.append(InternalName)
prop_meta[InternalName] = InternalMeta
# External file prop
codeName = "shadercode"
codeProp = StringProperty(name='External File', default='',
subtype="FILE_PATH", description='')
codeMeta = {'renderman_name': 'filename',
'name': 'ShaderCode', 'renderman_type': 'string',
'default': '', 'label': 'ShaderCode',
'type': 'string', 'options': '',
'widget': 'fileinput', '__noconnection': True}
node.__annotations__[codeName] = codeProp
prop_names.append(codeName)
prop_meta[codeName] = codeMeta
for sp in shaderparameters:
if sp.tag == 'page':
page_name = sp.attrib['name']
first_level = parent_name == 'PxrSurface' and 'Globals' not in page_name
sub_prop_names, sub_params_meta = generate_page(
sp, node, page_name, first_level=first_level)
prop_names.append(page_name)
prop_meta[page_name] = {'renderman_type': 'page'}
ui_label = "%s_uio" % page_name
node.__annotations__[ui_label] = BoolProperty(name=ui_label, default=False)
prop_meta.update(sub_params_meta)
setattr(node, page_name, sub_prop_names)
elif sp.tag == 'output':
tag = sp.find('*/tag')
renderman_type = tag.attrib['value']
output_meta[sp.attrib['name']] = sp.attrib
output_meta[sp.attrib['name']]['renderman_type'] = renderman_type
else:
name, meta, prop = generate_property(sp)
if name is None:
continue
prop_names.append(name)
prop_meta[name] = meta
node.__annotations__[name] = prop
setattr(node, 'prop_names', prop_names)
setattr(node, 'prop_meta', prop_meta)
setattr(node, 'output_meta', output_meta)
def update_conditional_visops(node):
for param_name, prop_meta in getattr(node, 'prop_meta').items():
if 'conditionalVisOp' in prop_meta:
try:
hidden = not eval(prop_meta['conditionalVisOp'])
prop_meta['hidden'] = hidden
if hasattr(node, 'inputs') and param_name in node.inputs:
node.inputs[param_name].hide = hidden
except:
print("Error in conditional visop")
def update_func_with_inputs(self, context):
# check if this prop is set on an input
node = self.node if hasattr(self, 'node') else self
if context and hasattr(context, 'material'):
mat = context.material
if mat:
node.update_mat(mat)
elif context and hasattr(context, 'node'):
mat = context.space_data.id
if mat:
node.update_mat(mat)
# update the conditional_vis_ops
update_conditional_visops(node)
if node.bl_idname in ['PxrLayerPatternNode', 'PxrSurfaceBxdfNode']:
node_add_inputs(node, node.name, node.prop_names)
else:
update_inputs(node)
# set any inputs that are visible and param is hidden to hidden
prop_meta = getattr(node, 'prop_meta')
if hasattr(node, 'inputs'):
for input_name, socket in node.inputs.items():
if 'hidden' in prop_meta[input_name]:
socket.hide = prop_meta[input_name]['hidden']
# send updates to ipr if running
def update_func(self, context):
# check if this prop is set on an input
node = self.node if hasattr(self, 'node') else self
if context and hasattr(context, 'material'):
mat = context.material
if mat:
node.update_mat(mat)
elif context and hasattr(context, 'node'):
mat = context.space_data.id
if mat:
node.update_mat(mat)
# update the conditional_vis_ops
update_conditional_visops(node)
# set any inputs that are visible and param is hidden to hidden
prop_meta = getattr(node, 'prop_meta')
if hasattr(node, 'inputs'):
for input_name, socket in node.inputs.items():
if input_name not in prop_meta:
continue
if 'hidden' in prop_meta[input_name] \
and prop_meta[input_name]['hidden'] and not socket.hide:
socket.hide = True
def update_inputs(node):
if node.bl_idname == 'PxrMeshLightLightNode':
return
for page_name in node.prop_names:
if node.prop_meta[page_name]['renderman_type'] == 'page':
for prop_name in getattr(node, page_name):
if prop_name.startswith('enable'):
recursive_enable_inputs(node, getattr(
node, page_name), getattr(node, prop_name))
break
def recursive_enable_inputs(node, prop_names, enable=True):
for prop_name in prop_names:
if type(prop_name) == str and node.prop_meta[prop_name]['renderman_type'] == 'page':
recursive_enable_inputs(node, getattr(node, prop_name), enable)
elif hasattr(node, 'inputs') and prop_name in node.inputs:
node.inputs[prop_name].hide = not enable
else:
continue
# take a set of condtional visops and make a python string
def parse_conditional_visop(hintdict, op_prefix='conditionalVis'):
'''This method takes some conditional visop and makes it into a python
string which can be eval'ed. Looking up values'''
op_map = {
'notEqualTo': "!=",
'equalTo': '==',
'greaterThan': '>',
'lessThan': '<'
}
visop = hintdict.find("string[@name='%sOp']" % op_prefix).attrib['value']
if visop in ('and', 'or'):
# get the prefixes for left and right
left_prefix = hintdict.find("string[@name='%sLeft']" % op_prefix).attrib['value']
right_prefix = hintdict.find("string[@name='%sRight']" % op_prefix).attrib['value']
# recursively get string
vis_left = parse_conditional_visop(hintdict, op_prefix=left_prefix)
vis_right = parse_conditional_visop(hintdict, op_prefix=left_prefix)
# do something here
return "%s %s %s" % (vis_left, visop, vis_right)
else:
vispath = hintdict.find(
"string[@name='%sPath']" % op_prefix).attrib['value']
visValue = hintdict.find(
"string[@name='%sValue']" % op_prefix).attrib['value']
if visValue.isalpha() or not visValue:
return "getattr(node, '%s') %s '%s'" % \
(vispath.rsplit('/', 1)[-1], op_map[visop], visValue)
else:
return "float(getattr(node, '%s')) %s float(%s)" % \
(vispath.rsplit('/', 1)[-1], op_map[visop], visValue)
def parse_conditional_visop_attrib(attrib):
op_map = {
'notEqualTo': "!=",
'equalTo': '==',
'greaterThan': '>',
'lessThan': '<'
}
visop = attrib['conditionalVisOp']
vispath = attrib['conditionalVisPath']
visValue = attrib['conditionalVisValue']
if visValue.isalpha() or not visValue:
return "getattr(node, '%s') %s '%s'" % \
(vispath.rsplit('/', 1)[-1], op_map[visop], visValue)
else:
return "float(getattr(node, '%s')) %s float(%s)" % \
(vispath.rsplit('/', 1)[-1], op_map[visop], visValue)
def assetid_update_func(self, context):
node = self.node if hasattr(self, 'node') else self
light = None
active = context.active_object
if active.type == 'LIGHT':
light = active.data
texture_utils.update_texture(node, light=light)
if context and hasattr(context, 'material'):
mat = context.material
if mat:
node.update_mat(mat)
elif context and hasattr(context, 'node'):
mat = context.space_data.id
if mat:
node.update_mat(mat)
# map args params to props
def generate_property(sp):
options = {'ANIMATABLE'}
param_name = sp.attrib['name']
renderman_name = param_name
# blender doesn't like names with __ but we save the
# "renderman_name with the real one"
if param_name[0] == '_':
param_name = param_name[1:]
if param_name[0] == '_':
param_name = param_name[1:]
param_label = sp.attrib['label'] if 'label' in sp.attrib else param_name
param_widget = sp.attrib['widget'].lower() if 'widget' in sp.attrib \
else 'default'
# if param_widget == 'null':
# return (None, None, None)
param_type = 'float' # for default. Some args files are sloppy
if 'type' in sp.attrib:
param_type = sp.attrib['type']
tags = sp.find('tags')
param_default = sp.attrib['default'] if 'default' in sp.attrib else None
prop_meta = sp.attrib
if tags and tags.find('tag').attrib['value'] == "vstruct":
param_type = 'struct'
prop_meta['is_vstruct'] = True
renderman_type = param_type
# correct for param_type mismatch with tag value
if param_type == 'vector' and tags and tags.find('tag').attrib['value'] == 'color':
param_type = 'color'
update_function = update_func_with_inputs if 'enable' in param_name else update_func
prop = None
# set this prop as non connectable
if 'widget' in sp.attrib.keys() and sp.attrib['widget'] in ['null', 'checkBox', 'switch']:
prop_meta['__noconnection'] = True
tags = sp.find('tags')
if tags and tags.find('tag').attrib['value'] == "__nonconnection" or \
("connectable" in sp.attrib and
sp.attrib['connectable'].lower() == 'false'):
prop_meta['__noconnection'] = True
#print(param_name)
# if has conditionalVisOps parse them
if sp.find("hintdict[@name='conditionalVisOps']"):
prop_meta['conditionalVisOp'] = parse_conditional_visop(
sp.find("hintdict[@name='conditionalVisOps']"))
# sigh, some visops are in attrib:
elif 'conditionalVisOp' in sp.attrib:
prop_meta['conditionalVisOp'] = parse_conditional_visop_attrib(sp.attrib)
param_help = ""
for s in sp:
if s.tag == 'help' and s.text:
#
# remove leading mutlispaces (note: 'leading' require re.MULTILINE)
param_help = re.sub(r"^(?:\ )+", '', s.text, count=0, flags=re.M)
# remove single newline at beginning (if any) of whole xml node
param_help = re.sub(r'^\n', '', param_help)
# remove single newline chars (exact match), replace with a space
# (preserving multi newlines as formatting as paragraphs).
# Add a newline to the end of whole xml node to separate additional
# infos added by Blender itself.
param_help = re.sub(r"(?<!\n)\n(?!\n)", ' ', param_help, count=0, flags=re.M) + '\n'
if 'float' in param_type:
if 'arraySize' in sp.attrib.keys():
if "," in sp.attrib['default']:
param_default = tuple(float(f) for f in
sp.attrib['default'].split(','))
else:
param_default = tuple(float(f) for f in
sp.attrib['default'].split())
prop = FloatVectorProperty(name=param_label,
default=param_default, precision=3,
size=len(param_default),
description=param_help,
update=update_function)
else:
param_default = parse_float(param_default)
if param_widget == 'checkbox' or param_widget == 'switch':
prop = BoolProperty(name=param_label,
default=bool(param_default),
description=param_help, update=update_function)
elif param_widget == 'mapper':
prop = EnumProperty(name=param_label,
items=sp_optionmenu_to_string(
sp.find("hintdict[@name='options']")),
default=sp.attrib['default'],
description=param_help, update=update_function)
else:
param_min = parse_float(sp.attrib['min']) if 'min' \
in sp.attrib else (-1.0 * sys.float_info.max)
param_max = parse_float(sp.attrib['max']) if 'max' \
in sp.attrib else sys.float_info.max
param_min = parse_float(sp.attrib['slidermin']) if 'slidermin' \
in sp.attrib else param_min
param_max = parse_float(sp.attrib['slidermax']) if 'slidermax' \
in sp.attrib else param_max
prop = FloatProperty(name=param_label,
default=param_default, precision=3,
soft_min=param_min, soft_max=param_max,
description=param_help, update=update_function)
renderman_type = 'float'
elif param_type == 'int' or param_type == 'integer':
if 'arraySize' in sp.attrib.keys():
if "," in sp.attrib['default']:
param_default = tuple(int(f) for f in
sp.attrib['default'].split(','))
else:
param_default = tuple(int(f) for f in
sp.attrib['default'].split())
prop = IntVectorProperty(name=param_label,
default=param_default,
size=len(param_default),
description=param_help,
update=update_function)
else:
param_default = int(param_default) if param_default else 0
# make invertT default 0
if param_name == 'invertT':
param_default = 0
if param_widget == 'checkbox' or param_widget == 'switch':
prop = BoolProperty(name=param_label,
default=bool(param_default),
description=param_help, update=update_function)
elif param_widget == 'mapper':
prop = EnumProperty(name=param_label,
items=sp_optionmenu_to_string(
sp.find("hintdict[@name='options']")),
default=sp.attrib['default'],
description=param_help, update=update_function)
else:
param_min = int(sp.attrib['min']) if 'min' in sp.attrib else 0
param_max = int(
sp.attrib['max']) if 'max' in sp.attrib else 2 ** 31 - 1
prop = IntProperty(name=param_label,
default=param_default,
soft_min=param_min,
soft_max=param_max,
description=param_help, update=update_function)
renderman_type = 'int'
elif param_type == 'color':
if 'arraySize' in sp.attrib.keys():
return (None, None, None)
if param_default == 'null' or param_default is None:
param_default = '0 0 0'
param_default = [float(c) for c in
param_default.replace(',', ' ').split()]
prop = FloatVectorProperty(name=param_label,
default=param_default, size=3,
subtype="COLOR",
soft_min=0.0, soft_max=1.0,
description=param_help, update=update_function)
renderman_type = 'color'
elif param_type == 'shader':
param_default = ''
prop = StringProperty(name=param_label,
default=param_default,
description=param_help, update=update_function)
renderman_type = 'string'
elif param_type == 'string' or param_type == 'struct':
if param_default is None:
param_default = ''
# if '__' in param_name:
# param_name = param_name[2:]
if param_widget == 'fileinput' or param_widget == 'assetidinput' or (param_widget == 'default' and param_name == 'filename'):
prop = StringProperty(name=param_label,
default=param_default, subtype="FILE_PATH",
description=param_help, update=assetid_update_func)
#description=param_help, update=update_function)
elif param_widget == 'mapper':
prop = EnumProperty(name=param_label,
default=param_default, description=param_help,
items=sp_optionmenu_to_string(
sp.find("hintdict[@name='options']")),
update=update_function)
elif param_widget == 'popup':
options = [(o, o, '') for o in sp.attrib['options'].split('|')]
prop = EnumProperty(name=param_label,
default=param_default, description=param_help,
items=options, update=update_function)
else:
prop = StringProperty(name=param_label,
default=param_default,
description=param_help, update=update_function)
renderman_type = param_type
elif param_type == 'vector' or param_type == 'normal':
if param_default is None:
param_default = '0 0 0'
param_default = [float(v) for v in param_default.split()]
prop = FloatVectorProperty(name=param_label,
default=param_default, size=3,
subtype="NONE",
description=param_help, update=update_function)
elif param_type == 'point':
if param_default is None:
param_default = '0 0 0'
param_default = [float(v) for v in param_default.split()]
prop = FloatVectorProperty(name=param_label,
default=param_default, size=3,
subtype="XYZ",
description=param_help, update=update_function)
renderman_type = param_type
elif param_type == 'int[2]':
param_type = 'int'
param_default = tuple(int(i) for i in sp.attrib['default'].split(','))
is_array = 2
prop = IntVectorProperty(name=param_label,
default=param_default, size=2,
description=param_help, update=update_function)
renderman_type = 'int'
prop_meta['arraySize'] = 2
prop_meta['renderman_type'] = renderman_type
prop_meta['renderman_name'] = renderman_name
return (param_name, prop_meta, prop)
# map types in args files to socket types
socket_map = {
'float': 'RendermanNodeSocketFloat',
'color': 'RendermanNodeSocketColor',
'string': 'RendermanNodeSocketString',
'int': 'RendermanNodeSocketInt',
'integer': 'RendermanNodeSocketInt',
'struct': 'RendermanNodeSocketStruct',
'normal': 'RendermanNodeSocketVector',
'vector': 'RendermanNodeSocketVector',
'point': 'RendermanNodeSocketVector',
'void': 'RendermanNodeSocketStruct',
'vstruct': 'RendermanNodeSocketStruct',
}
def find_enable_param(params):
for prop_name in params:
if prop_name.startswith('enable'):
return prop_name
# add input sockets
def node_add_inputs(node, node_name, prop_names, first_level=True, label_prefix='', remove=False):
for name in prop_names:
meta = node.prop_meta[name]
param_type = meta['renderman_type']
if name in node.inputs.keys() and remove:
node.inputs.remove(node.inputs[name])
continue
elif name in node.inputs.keys():
continue
# if this is a page recursively add inputs
if 'renderman_type' in meta and meta['renderman_type'] == 'page':
if first_level and node.bl_idname in ['PxrLayerPatternNode', 'PxrSurfaceBxdfNode'] and name != 'Globals':
# add these
enable_param = find_enable_param(getattr(node, name))
if enable_param and getattr(node, enable_param):
node_add_inputs(node, node_name, getattr(node, name),
label_prefix=name + ' ',
first_level=False)
else:
node_add_inputs(node, node_name, getattr(node, name),
label_prefix=name + ' ',
first_level=False, remove=True)
continue
else:
node_add_inputs(node, node_name, getattr(node, name),
first_level=first_level,
label_prefix=label_prefix, remove=remove)
continue
if remove:
continue
# # if this is not connectable don't add socket
if param_type not in socket_map:
continue
if '__noconnection' in meta and meta['__noconnection']:
continue
param_name = name
param_label = label_prefix + meta.get('label', param_name)
socket = node.inputs.new(
socket_map[param_type], param_name, identifier=param_label)
socket.link_limit = 1
if param_type in ['struct', 'normal', 'vector', 'vstruct', 'void']:
socket.hide_value = True
update_inputs(node)
# add output sockets
def node_add_outputs(node):
for name, meta in node.output_meta.items():
rman_type = meta['renderman_type']
if rman_type in socket_map and 'vstructmember' not in meta:
socket = node.outputs.new(socket_map[rman_type], name)
socket.label = name