MaterialX Realtime results update in viewport render #10

Merged
Bogdan Nagirniak merged 4 commits from Vasyl-Pidhirskyi/blender-addons:BLEN-412 into materialx-addon 2023-05-18 08:22:01 +02:00
2 changed files with 9 additions and 0 deletions
Showing only changes of commit ab0ade2091 - Show all commits

View File

@ -133,6 +133,8 @@ def generate_property_code(mx_param, category):
if mx_type == 'filename' and category in ("texture2d", "texture3d"): if mx_type == 'filename' and category in ("texture2d", "texture3d"):
prop_attr_strings.insert(0, "type=bpy.types.Image") prop_attr_strings.insert(0, "type=bpy.types.Image")
prop_attr_strings.append('update=MxNode.update_prop')
return f"{prop_type}({', '.join(prop_attr_strings)})" return f"{prop_type}({', '.join(prop_attr_strings)})"

View File

@ -78,6 +78,9 @@ class MxNode(bpy.types.ShaderNode):
_ui_folders = () # list of ui folders mentioned in nodedef _ui_folders = () # list of ui folders mentioned in nodedef
category = "" category = ""
def update_prop(self, context):
self.socket_value_update(context)
@classmethod @classmethod
def get_nodedef(cls, data_type): def get_nodedef(cls, data_type):
if not cls._data_types[data_type]['nd']: if not cls._data_types[data_type]['nd']:
@ -150,6 +153,8 @@ class MxNode(bpy.types.ShaderNode):
for i, nd_output in enumerate(nodedef.getActiveOutputs()): for i, nd_output in enumerate(nodedef.getActiveOutputs()):
self.outputs[i].name = nd_output.getName() self.outputs[i].name = nd_output.getName()
self.update_prop(context)
def init(self, context): def init(self, context):
nodedef = self.nodedef nodedef = self.nodedef
@ -368,6 +373,8 @@ class MxNode(bpy.types.ShaderNode):
if f: if f:
self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) self.inputs[i].hide = not getattr(self, self._folder_prop_name(f))
self.update_prop(context)
def check_ui_folders(self): def check_ui_folders(self):
if not self._ui_folders: if not self._ui_folders:
return return