浏览代码

Fix the channels gltf importer uses for metallic and AO textures.

Khronos blender gltf exporter uses red channel for occlusion and blue channel for metallic, whereas the current behavior is the opposite.

Fixes #10700.
Ferenc Arn 8 年之前
父节点
当前提交
609ef89362
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      editor/import/editor_scene_importer_gltf.cpp

+ 2 - 1
editor/import/editor_scene_importer_gltf.cpp

@@ -1216,7 +1216,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
 				if (bct.has("index")) {
 					Ref<Texture> t = _get_texture(state, bct["index"]);
 					material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t);
-					material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED);
+					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")) {
@@ -1243,6 +1243,7 @@ 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);
 			}
 		}