Skip to content

Commit 95d3d7c

Browse files
committed
Fix export of base color, metalic and roughness factors
1 parent 5b730b2 commit 95d3d7c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

addons/io_scene_gltf2_msfs/com/msfs_material_props.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,19 @@ def from_dict(
282282

283283
@staticmethod
284284
def to_extension(blender_material, gltf2_material, export_settings):
285-
# All the properties here (besides some textures, which we handle elsewhere) are exported from the Khronos exporter
285+
286+
if gltf2_material.pbr_metallic_roughness:
287+
gltf2_material.pbr_metallic_roughness.base_color_factor = [f for f in blender_material.msfs_base_color_factor]
288+
gltf2_material.emissive_factor = [f * blender_material.msfs_emissive_scale for f in blender_material.msfs_emissive_factor]
289+
gltf2_material.pbr_metallic_roughness.metallic_factor = blender_material.msfs_metallic_factor
290+
gltf2_material.pbr_metallic_roughness.roughness_factor = blender_material.msfs_roughness_factor
291+
292+
if gltf2_material.normal_texture:
293+
gltf2_material.normal_texture.scale = blender_material.msfs_normal_scale
294+
295+
if "KHR_materials_emissive_strength" in gltf2_material.extensions:
296+
gltf2_material.extensions.pop("KHR_materials_emissive_strength")
297+
286298
gltf2_material.emissive_factor = [f * blender_material.msfs_emissive_scale for f in blender_material.msfs_emissive_factor]
287299

288300
if "KHR_materials_emissive_strength" in gltf2_material.extensions:

addons/io_scene_gltf2_msfs/io/msfs_multi_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ def execute(self, context):
218218
sort_by_collection = context.scene.multi_exporter_grouped_by_collections
219219

220220
for lod_group in lod_groups:
221-
# Generate XML if needed
222221
export_folder_path = lod_group.folder_path
223222
if export_folder_path == '//\\':
224223
export_folder_path = export_folder_path.rsplit('\\')[0]
225224
export_folder_path = bpy.path.abspath(export_folder_path)
225+
# Generate XML if needed
226226
if lod_group.generate_xml:
227227
xml_path = os.path.join(export_folder_path, lod_group.group_name + ".xml")
228228
found_guid = None

0 commit comments

Comments
 (0)