diff --git a/gltf/gltfpack.cpp b/gltf/gltfpack.cpp index fabc586d..3e97d321 100644 --- a/gltf/gltfpack.cpp +++ b/gltf/gltfpack.cpp @@ -354,6 +354,7 @@ static void process(cgltf_data* data, const char* input_path, const char* output mi.needsTangents |= vi.needsTangents; mi.textureSetMask |= vi.textureSetMask; + mi.unlit &= vi.unlit; } filterStreams(mesh, mi); diff --git a/gltf/gltfpack.h b/gltf/gltfpack.h index c3257589..fed181ea 100644 --- a/gltf/gltfpack.h +++ b/gltf/gltfpack.h @@ -219,6 +219,8 @@ struct MaterialInfo bool usesTextureTransform; bool needsTangents; + bool unlit; + unsigned int textureSetMask; int remap; diff --git a/gltf/material.cpp b/gltf/material.cpp index 59238ac1..9b1ad14a 100644 --- a/gltf/material.cpp +++ b/gltf/material.cpp @@ -500,6 +500,9 @@ static void analyzeMaterial(const cgltf_material& material, MaterialInfo& mi, cg analyzeMaterialTexture(material.normal_texture, TextureKind_Normal, mi, data, textures, images); analyzeMaterialTexture(material.occlusion_texture, TextureKind_Attrib, mi, data, textures, images); analyzeMaterialTexture(material.emissive_texture, TextureKind_Color, mi, data, textures, images); + + if (material.unlit) + mi.unlit = true; } void analyzeMaterials(cgltf_data* data, std::vector& materials, std::vector& textures, std::vector& images) diff --git a/gltf/mesh.cpp b/gltf/mesh.cpp index 7d02cd1b..f5730c98 100644 --- a/gltf/mesh.cpp +++ b/gltf/mesh.cpp @@ -424,6 +424,9 @@ void filterStreams(Mesh& mesh, const MaterialInfo& mi) if (stream.type == cgltf_attribute_type_texcoord && stream.index > keep_texture_set) continue; + if (stream.type == cgltf_attribute_type_normal && mi.unlit) + continue; + if (stream.type == cgltf_attribute_type_tangent && !mi.needsTangents) continue;