1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Sanitize tangents when creating mesh surfaces to avoid triggering the compressed mesh path in the shader

This commit is contained in:
clayjohn
2023-10-11 21:34:52 -06:00
parent b1371806ad
commit e3d31837eb
4 changed files with 32 additions and 0 deletions

View File

@@ -208,6 +208,11 @@ void ImmediateMesh::surface_end() {
uint32_t value = 0;
value |= (uint16_t)CLAMP(t.x * 65535, 0, 65535);
value |= (uint16_t)CLAMP(t.y * 65535, 0, 65535) << 16;
if (value == 4294901760) {
// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
// So we sanitize here.
value = 4294967295;
}
*tangent = value;
}