Skip to content

Commit

Permalink
Fix teamcolor display in Cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
amorgun committed Jul 27, 2024
1 parent 3d7e2ab commit bbca12a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ def image_to_tga(image, dst: str | pathlib.Path, width: int, height: int, graysc
]:
if not (img := images.get(f'color_layer_{layer_name}')):
continue
if img.get('PLACEHOLDER', False):
continue
with writer.start_chunk('DATAPTLD'):
tmp_file = temp_dir / f'{layer_name}.tga'
try:
Expand Down
10 changes: 10 additions & 0 deletions importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def _reset(self):
self.armature_obj = bpy.data.objects.new('Armature', self.armature)
self.armature_obj.show_in_front = True

self.default_image = bpy.data.images.new('NOT_SET', 1, 1)
self.default_image['PLACEHOLDER'] = True
self.default_image.use_fake_user = True

def CH_DATASSHR(self, reader: ChunkReader): # CH_DATASSHR > - Chunk Handler - Material Data
material_path = reader.read_str() # -- Read Texture Path

Expand Down Expand Up @@ -278,6 +282,7 @@ def load_wtp(self, reader: ChunkReader, material_path: str, material):
node_tex.image = loaded_textures[layer_name]
else:
node_tex.hide = True
node_tex.image = self.default_image
node_tex.location = node_pos_x + 200, node_pos_y
node_tex.label = f'color_layer_{layer_name}'
links.new(uf_offset_node.outputs[0], node_tex.inputs['Vector'])
Expand Down Expand Up @@ -319,8 +324,10 @@ def load_wtp(self, reader: ChunkReader, material_path: str, material):
if layer_data is None:
node_name = f'UNUSED_{layer_name}'
layer_data = 0, 0, 0, 0
default_image = self.default_image
else:
node_name = layer_name
default_image = None
node_pos_x, node_pos_y = common_node_pos_x, common_node_pos_y - 290 * len(created_tex_nodes)
data_pos_node = material.node_tree.nodes.new('ShaderNodeCombineXYZ')
data_pos_node.inputs['X'].default_value = layer_data[0]
Expand Down Expand Up @@ -359,6 +366,9 @@ def load_wtp(self, reader: ChunkReader, material_path: str, material):
node_tex.extension = 'CLIP'
node_tex.location = node_pos_x + 200, node_pos_y
node_tex.label = node_name
if default_image is not None:
node_tex.image = default_image
node_tex.hide = True
links.new(scale_node.outputs[0], node_tex.inputs['Vector'])

node_mix = material.node_tree.nodes.new('ShaderNodeMixRGB')
Expand Down

0 comments on commit bbca12a

Please sign in to comment.