forked from blender/blender-addons
Caching generated image leads to infinite loop in preview render #15
@ -103,7 +103,7 @@ def set_param_value(mx_param, val, nd_type, nd_output=None):
|
|||||||
elif nd_type == 'float':
|
elif nd_type == 'float':
|
||||||
if isinstance(val, NodeItem):
|
if isinstance(val, NodeItem):
|
||||||
val = val.data
|
val = val.data
|
||||||
|
|
||||||
if isinstance(val, tuple):
|
if isinstance(val, tuple):
|
||||||
val = val[0]
|
val = val[0]
|
||||||
|
|
||||||
@ -347,6 +347,14 @@ READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't w
|
|||||||
|
|
||||||
|
|
||||||
def cache_image_file(image: bpy.types.Image, cache_check=True):
|
def cache_image_file(image: bpy.types.Image, cache_check=True):
|
||||||
|
try:
|
||||||
|
import _bpy_hydra
|
||||||
|
return _bpy_hydra.cache_or_get_image_file(bpy.context.as_pointer(), image.as_pointer())
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
# without bpy_hydra we are going to cache image through python
|
||||||
|
pass
|
||||||
|
|
||||||
image_path = Path(image.filepath_from_user())
|
image_path = Path(image.filepath_from_user())
|
||||||
if not image.packed_file and image.source != 'GENERATED':
|
if not image.packed_file and image.source != 'GENERATED':
|
||||||
if not image_path.is_file():
|
if not image_path.is_file():
|
||||||
@ -380,6 +388,7 @@ def cache_image_file(image: bpy.types.Image, cache_check=True):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
image.save_render(filepath=str(temp_path))
|
image.save_render(filepath=str(temp_path))
|
||||||
|
|
||||||
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 +664,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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user