From 1ac24cbda8912679b54965651cad81c1753c675c Mon Sep 17 00:00:00 2001 From: Sebastian Sille Date: Mon, 20 Feb 2023 15:31:50 +0100 Subject: [PATCH] Make sure there is a primary texture If there is no primary texture the remaining will be exported as primary Signed-off-by: Sebastian Sille --- io_scene_3ds/export_3ds.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/io_scene_3ds/export_3ds.py b/io_scene_3ds/export_3ds.py index 2a22d74..422fc8c 100644 --- a/io_scene_3ds/export_3ds.py +++ b/io_scene_3ds/export_3ds.py @@ -673,12 +673,15 @@ def make_material_chunk(material, image): material_chunk.add_subchunk(make_percent_subchunk(MATSELFILPCT, wrap.emission_strength)) material_chunk.add_subchunk(shading) + primary_tex = False + if wrap.base_color_texture: d_pct = 0.7 + sum(wrap.base_color[:]) * 0.1 color = [wrap.base_color_texture] matmap = make_material_texture_chunk(MAT_DIFFUSEMAP, color, d_pct) if matmap: material_chunk.add_subchunk(matmap) + primary_tex = True if wrap.specular_texture: spec = [wrap.specular_texture] @@ -703,8 +706,7 @@ def make_material_chunk(material, image): if wrap.normalmap_texture: normal = [wrap.normalmap_texture] - bump = wrap.normalmap_strength - b_pct = min(bump, 1) + b_pct = wrap.normalmap_strength matmap = make_material_texture_chunk(MAT_BUMPMAP, normal, b_pct) if matmap: material_chunk.add_subchunk(matmap) @@ -733,7 +735,10 @@ def make_material_chunk(material, image): diffuse = [link.from_node.image] if not wrap.normalmap_texture else None if diffuse: - matmap = make_texture_chunk(MAT_TEX2MAP, diffuse) + if primary_tex == False: + matmap = make_texture_chunk(MAT_DIFFUSEMAP, diffuse) + else: + matmap = make_texture_chunk(MAT_TEX2MAP, diffuse) if matmap: material_chunk.add_subchunk(matmap) -- 2.30.2