2
0
Эх сурвалжийг харах

Use the vertex colors by default in gltf.

(cherry picked from commit 43424e132173553201cd26f5aca064ad30e96bda)
K. S. Ernest (iFire) Lee 5 жил өмнө
parent
commit
460ab353b4

+ 7 - 0
editor/import/editor_scene_importer_gltf.cpp

@@ -1226,6 +1226,12 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
 				ERR_FAIL_INDEX_V(material, state.materials.size(), ERR_FILE_CORRUPT);
 				const Ref<Material> &mat = state.materials[material];
 
+				mesh.mesh->surface_set_material(mesh.mesh->get_surface_count() - 1, mat);
+			} else {
+				Ref<SpatialMaterial> mat;
+				mat.instance();
+				mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+
 				mesh.mesh->surface_set_material(mesh.mesh->get_surface_count() - 1, mat);
 			}
 		}
@@ -1391,6 +1397,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
 		if (d.has("name")) {
 			material->set_name(d["name"]);
 		}
+		material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
 
 		if (d.has("pbrMetallicRoughness")) {