mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-19 12:03:07 -04:00
Merge pull request #633 from zeux/gltf-unlit
gltfpack: Remove normal streams from meshes with unlit materials
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -219,6 +219,8 @@ struct MaterialInfo
|
||||
|
||||
bool usesTextureTransform;
|
||||
bool needsTangents;
|
||||
bool unlit;
|
||||
|
||||
unsigned int textureSetMask;
|
||||
|
||||
int remap;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user