You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Sanitize tangents when creating mesh surfaces to avoid triggering the compressed mesh path in the shader
This commit is contained in:
@@ -1156,6 +1156,11 @@ void _fix_array_compatibility(const Vector<uint8_t> &p_src, uint64_t p_old_forma
|
||||
uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * dst_normal_tangent_stride + dst_offsets[Mesh::ARRAY_NORMAL]];
|
||||
dst[0] = (uint16_t)CLAMP(res.x * 65535, 0, 65535);
|
||||
dst[1] = (uint16_t)CLAMP(res.y * 65535, 0, 65535);
|
||||
if (dst[0] == 0 && dst[1] == 65535) {
|
||||
// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
|
||||
// So we sanitize here.
|
||||
dst[0] = 65535;
|
||||
}
|
||||
}
|
||||
src_offset += sizeof(uint8_t) * 4;
|
||||
} else {
|
||||
@@ -1167,6 +1172,11 @@ void _fix_array_compatibility(const Vector<uint8_t> &p_src, uint64_t p_old_forma
|
||||
uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * dst_normal_tangent_stride + dst_offsets[Mesh::ARRAY_NORMAL]];
|
||||
dst[0] = (uint16_t)CLAMP(res.x * 65535, 0, 65535);
|
||||
dst[1] = (uint16_t)CLAMP(res.y * 65535, 0, 65535);
|
||||
if (dst[0] == 0 && dst[1] == 65535) {
|
||||
// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
|
||||
// So we sanitize here.
|
||||
dst[0] = 65535;
|
||||
}
|
||||
}
|
||||
src_offset += sizeof(float) * 4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user