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

@ -612,6 +612,12 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint
(uint16_t)CLAMP(res.y * 65535, 0, 65535),
};
if (vector[0] == 0 && vector[1] == 65535) {
// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
// So we sanitize here.
vector[0] = 65535;
}
memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);
}
} else { // PACKED_FLOAT64_ARRAY
@ -627,6 +633,12 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint
(uint16_t)CLAMP(res.y * 65535, 0, 65535),
};
if (vector[0] == 0 && vector[1] == 65535) {
// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
// So we sanitize here.
vector[0] = 65535;
}
memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);
}
}