From eb7983377081651e120487a095101c94343ea203 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 23 Feb 2019 19:10:31 +0100 Subject: [PATCH] Tweak SpatialMaterial's default metallic and roughness texture channels To follow the glTF 2.0 specification in all cases (including outside of imported glTF scenes), the blue channel is now used for metallic and the green channel is now used for roughness. --- editor/import/editor_scene_importer_gltf.cpp | 3 --- scene/resources/material.cpp | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index ff2f68ffd34..b88928cfcf7 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1322,9 +1322,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (bct.has("index")) { Ref t = _get_texture(state, bct["index"]); material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); - material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); - material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN); if (!mr.has("metallicFactor")) { material->set_metallic(1); } @@ -1349,7 +1347,6 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { Dictionary bct = d["occlusionTexture"]; if (bct.has("index")) { material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"])); - material->set_ao_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED); material->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true); } } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 190dc707c4c..3f61fc481b8 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -2320,8 +2320,8 @@ SpatialMaterial::SpatialMaterial() : set_ao_light_affect(0.0); - set_metallic_texture_channel(TEXTURE_CHANNEL_RED); - set_roughness_texture_channel(TEXTURE_CHANNEL_RED); + set_metallic_texture_channel(TEXTURE_CHANNEL_BLUE); + set_roughness_texture_channel(TEXTURE_CHANNEL_GREEN); set_ao_texture_channel(TEXTURE_CHANNEL_RED); set_refraction_texture_channel(TEXTURE_CHANNEL_RED);