Caching generated image leads to infinite loop in preview render #15

Merged
Bogdan Nagirniak merged 3 commits from BLEN-409 into materialx-addon 2023-06-13 18:51:41 +02:00
Showing only changes of commit cf4e90cb23 - Show all commits

View File

@ -379,7 +379,11 @@ def cache_image_file(image: bpy.types.Image, cache_check=True):
scene.render.image_settings.color_mode = BLENDER_DEFAULT_COLOR_MODE scene.render.image_settings.color_mode = BLENDER_DEFAULT_COLOR_MODE
try: try:
image.save_render(filepath=str(temp_path)) import _bpy_hydra
temp_path = _bpy_hydra.cache_image(bpy.context.as_pointer(), scene.as_pointer(), image.as_pointer())
except ImportError:
print("ERROR: no Hydra scene delegate available")
finally: finally:
scene.render.image_settings.file_format = user_format scene.render.image_settings.file_format = user_format
scene.render.image_settings.color_mode = user_color_mode scene.render.image_settings.color_mode = user_color_mode
@ -655,15 +659,15 @@ def get_output_node(material):
return None return None
bl_output_node = next((node for node in material.node_tree.nodes if bl_output_node = next((node for node in material.node_tree.nodes if
node.bl_idname == 'ShaderNodeOutputMaterial' and node.bl_idname == 'ShaderNodeOutputMaterial' and
node.is_active_output and node.inputs['Surface'].links), None) node.is_active_output and node.inputs['Surface'].links), None)
if bl_output_node: if bl_output_node:
return bl_output_node return bl_output_node
mx_output_node = next((node for node in material.node_tree.nodes if mx_output_node = next((node for node in material.node_tree.nodes if
node.bl_idname == with_prefix('MxNode_STD_surfacematerial') and node.bl_idname == with_prefix('MxNode_STD_surfacematerial') and
node.inputs['surfaceshader'].links), None) node.inputs['surfaceshader'].links), None)
return mx_output_node return mx_output_node