From 4fcb0d036c68ff0e0c4653ad1b8fa218ba27020f Mon Sep 17 00:00:00 2001 From: Rodolfo Ribeiro Gomes Date: Wed, 20 Jun 2018 23:44:08 -0300 Subject: [PATCH] fix default glTF metallic & roughness factor values The glTF 2.0 spec says that these pbrMetallicRoughness material properties should be set as 1.0 by default. In fact, KhronosGroup's official Blender Exporter does not even write down those parameters if they are set as 1.0. However, Godot import them as 0.0. https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#pbrmetallicroughness Fixes: #19613 https://github.com/godotengine/godot/issues/19613 (cherry picked from commit 01b01209a3ec3da4df17b03d401560bb664772c6) --- editor/import/editor_scene_importer_gltf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index f4be6e8d59f..aa516b63033 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1253,12 +1253,15 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } if (mr.has("metallicFactor")) { - material->set_metallic(mr["metallicFactor"]); + } else { + material->set_metallic(1.0); } - if (mr.has("roughnessFactor")) { + if (mr.has("roughnessFactor")) { material->set_roughness(mr["roughnessFactor"]); + } else { + material->set_roughness(1.0); } if (mr.has("metallicRoughnessTexture")) {