Skip to content

Commit

Permalink
feat(materials): add support for specular node image connection
Browse files Browse the repository at this point in the history
  • Loading branch information
LKAMinco committed May 1, 2024
1 parent a30ac03 commit e827a0a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions addon/i3dio/node_classes/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _resolve_with_nodes(self):
self.logger.warning(f"Uses nodes but Principled BSDF node is not found!")

gloss_node = self.blender_material.node_tree.nodes.get('Glossmap')
specular_socket = main_node.inputs['Specular IOR Level' if bpy.app.version >= (4, 0, 0) else 'Specular']
if gloss_node is not None:
try:
if bpy.app.version < (3, 3, 0):
Expand All @@ -71,6 +72,18 @@ def _resolve_with_nodes(self):
file_id = self.i3d.add_file_image(gloss_image_path)
self.xml_elements['Glossmap'] = xml_i3d.SubElement(self.element, 'Glossmap')
self._write_attribute('fileId', file_id, 'Glossmap')
elif specular_socket.is_linked:
connected_node = specular_socket.links[0].from_node
if connected_node.type == "TEX_IMAGE":
if connected_node.image is None:
self.logger.error(f"Specular node has no image")
else:
self.logger.debug(f"Has Glossmap '{utility.as_fs_relative_path(connected_node.image.filepath)}'")
file_id = self.i3d.add_file_image(connected_node.image.filepath)
self.xml_elements['Glossmap'] = xml_i3d.SubElement(self.element, 'Glossmap')
self._write_attribute('fileId', file_id, 'Glossmap')
else:
self.logger.debug(f"Specular node is not a TEX_IMAGE node")
else:
self.logger.debug(f"Has no Glossmap")

Expand Down

0 comments on commit e827a0a

Please sign in to comment.