You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Fix Texture3D import not working
Fix Texture3D import not working when texture has fully opaque and (partly or fully) transparent slices. For better style make cases of detect_alpha check against the exact enums rather than the enum 0.
This commit is contained in:
@@ -310,8 +310,6 @@ Ref<Image> CompressedTexture2D::load_image_from_file(Ref<FileAccess> f, int p_si
|
|||||||
Vector<Ref<Image>> mipmap_images;
|
Vector<Ref<Image>> mipmap_images;
|
||||||
uint64_t total_size = 0;
|
uint64_t total_size = 0;
|
||||||
|
|
||||||
bool first = true;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mipmaps + 1; i++) {
|
for (uint32_t i = 0; i < mipmaps + 1; i++) {
|
||||||
uint32_t size = f->get_32();
|
uint32_t size = f->get_32();
|
||||||
|
|
||||||
@@ -340,14 +338,17 @@ Ref<Image> CompressedTexture2D::load_image_from_file(Ref<FileAccess> f, int p_si
|
|||||||
if (img.is_null() || img->is_empty()) {
|
if (img.is_null() || img->is_empty()) {
|
||||||
ERR_FAIL_COND_V(img.is_null() || img->is_empty(), Ref<Image>());
|
ERR_FAIL_COND_V(img.is_null() || img->is_empty(), Ref<Image>());
|
||||||
}
|
}
|
||||||
|
// If the image is compressed and its format doesn't match the desired format, return an empty reference.
|
||||||
|
// This is done to avoid recompressing the image on load.
|
||||||
|
ERR_FAIL_COND_V(img->is_compressed() && format != img->get_format(), Ref<Image>());
|
||||||
|
|
||||||
if (first) {
|
// The format will actually be the format of the header,
|
||||||
//format will actually be the format of the first image,
|
// as it may have changed on compression.
|
||||||
//as it may have changed on compression
|
if (format != img->get_format()) {
|
||||||
format = img->get_format();
|
// Convert the image to the desired format.
|
||||||
first = false;
|
// Note: We are not decompressing the image here, just changing its format.
|
||||||
} else if (img->get_format() != format) {
|
// It's important that all images in the texture array share the same format for correct rendering.
|
||||||
img->convert(format); //all needs to be the same format
|
img->convert(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
total_size += img->get_data().size();
|
total_size += img->get_data().size();
|
||||||
|
|||||||
Reference in New Issue
Block a user