You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Import mesh colors in 8BPP.
* Colors were imported as 16BPP (half float) * Far most common use cases only require 8BPP * If you need higher data precision, use a custom array, which are supported now. **WARNING**: 3D Scenes imported in 4.0 no longer compatible with this new format. You need to re-import them (erase them from .godot/import)
This commit is contained in:
@@ -223,7 +223,7 @@ void ImmediateMesh::surface_end() {
|
||||
|
||||
if (uses_colors) {
|
||||
format |= ARRAY_FORMAT_COLOR;
|
||||
attribute_stride += sizeof(uint16_t) * 4;
|
||||
attribute_stride += sizeof(uint8_t) * 4;
|
||||
}
|
||||
uint32_t uv_offset = 0;
|
||||
if (uses_uvs) {
|
||||
@@ -244,25 +244,25 @@ void ImmediateMesh::surface_end() {
|
||||
|
||||
for (uint32_t i = 0; i < vertices.size(); i++) {
|
||||
if (uses_colors) {
|
||||
uint16_t *color16 = (uint16_t *)&surface_attribute_ptr[i * attribute_stride];
|
||||
uint8_t *color8 = (uint8_t *)&surface_attribute_ptr[i * attribute_stride];
|
||||
|
||||
color16[0] = Math::make_half_float(colors[i].r);
|
||||
color16[1] = Math::make_half_float(colors[i].g);
|
||||
color16[2] = Math::make_half_float(colors[i].b);
|
||||
color16[3] = Math::make_half_float(colors[i].a);
|
||||
color8[0] = uint8_t(CLAMP(colors[i].r * 255.0, 0.0, 255.0));
|
||||
color8[1] = uint8_t(CLAMP(colors[i].g * 255.0, 0.0, 255.0));
|
||||
color8[2] = uint8_t(CLAMP(colors[i].b * 255.0, 0.0, 255.0));
|
||||
color8[3] = uint8_t(CLAMP(colors[i].a * 255.0, 0.0, 255.0));
|
||||
}
|
||||
if (uses_uvs) {
|
||||
float *uv = (float *)&surface_attribute_ptr[i * attribute_stride + uv_offset];
|
||||
|
||||
uv[0] = uvs[i].x;
|
||||
uv[0] = uvs[i].y;
|
||||
uv[1] = uvs[i].y;
|
||||
}
|
||||
|
||||
if (uses_uv2s) {
|
||||
float *uv2 = (float *)&surface_attribute_ptr[i * attribute_stride + uv2_offset];
|
||||
|
||||
uv2[0] = uv2s[i].x;
|
||||
uv2[0] = uv2s[i].y;
|
||||
uv2[1] = uv2s[i].y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user