Merge pull request #633 from zeux/gltf-unlit

gltfpack: Remove normal streams from meshes with unlit materials
This commit is contained in:
Arseny Kapoulkine
2023-11-17 07:34:15 -08:00
committed by GitHub
4 changed files with 9 additions and 0 deletions
+1
View File
@@ -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);
+2
View File
@@ -219,6 +219,8 @@ struct MaterialInfo
bool usesTextureTransform;
bool needsTangents;
bool unlit;
unsigned int textureSetMask;
int remap;
+3
View File
@@ -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<MaterialInfo>& materials, std::vector<TextureInfo>& textures, std::vector<ImageInfo>& images)
+3
View File
@@ -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;