Skip to content

Commit

Permalink
force decompress texture arrays in compatibility
Browse files Browse the repository at this point in the history
Deprecated in 4.4 (hopefully)
  • Loading branch information
Xtarsia committed Dec 5, 2024
1 parent 90d9245 commit 32f24d4
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/terrain_3d_assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void Terrain3DAssets::_set_asset(const AssetType p_type, const int p_id, const R
}

void Terrain3DAssets::_update_texture_files() {
IS_INIT(VOID);
LOG(DEBUG, "Received texture_changed signal");
_generated_albedo_textures.clear();
_generated_normal_textures.clear();
Expand All @@ -173,6 +174,8 @@ void Terrain3DAssets::_update_texture_files() {
Image::Format normal_format = Image::FORMAT_MAX;
bool albedo_mipmaps = true;
bool normal_mipmaps = true;
//DEPRECATED
bool warn_compatibility_decompress = false;

for (int i = 0; i < _texture_list.size(); i++) {
Ref<Terrain3DTextureAsset> texture_set = _texture_list[i];
Expand All @@ -192,6 +195,11 @@ void Terrain3DAssets::_update_texture_files() {
return;
}
Ref<Image> img = albedo_tex->get_image();
//DEPRECATED
if (_terrain->is_compatibility_mode() && img->is_compressed()) {
warn_compatibility_decompress = true;
img->decompress();
}
Image::Format format = img->get_format();
if (albedo_format == Image::FORMAT_MAX) {
albedo_format = format;
Expand All @@ -210,6 +218,11 @@ void Terrain3DAssets::_update_texture_files() {
return;
}
Ref<Image> img = normal_tex->get_image();
//DEPRECATED
if (_terrain->is_compatibility_mode() && img->is_compressed()) {
warn_compatibility_decompress = true;
img->decompress();
}
Image::Format format = img->get_format();
if (normal_format == Image::FORMAT_MAX) {
normal_format = format;
Expand Down Expand Up @@ -250,6 +263,11 @@ void Terrain3DAssets::_update_texture_files() {
texture_set->_albedo_texture = ImageTexture::create_from_image(img);
} else {
img = tex->get_image();
//DEPRECATED
if (_terrain->is_compatibility_mode() && img->is_compressed()) {
warn_compatibility_decompress = true;
img->decompress();
}
LOG(DEBUG, "ID ", i, " albedo texture is valid. Format: ", img->get_format());
}
albedo_texture_array.push_back(img);
Expand Down Expand Up @@ -278,6 +296,11 @@ void Terrain3DAssets::_update_texture_files() {
texture_set->_normal_texture = ImageTexture::create_from_image(img);
} else {
img = tex->get_image();
//DEPRECATED
if (_terrain->is_compatibility_mode() && img->is_compressed()) {
warn_compatibility_decompress = true;
img->decompress();
}
LOG(DEBUG, "ID ", i, " Normal texture is valid. Format: ", img->get_format());
}
normal_texture_array.push_back(img);
Expand All @@ -286,7 +309,10 @@ void Terrain3DAssets::_update_texture_files() {
_generated_normal_textures.create(normal_texture_array);
}
}

//DEPRECATED
if (warn_compatibility_decompress == true) {
LOG(WARN, "Decompressed Terrain3DTextureAsset textures for compatibility with texture2Darrays in Compatibility renderer.");
}
emit_signal("textures_changed");
}

Expand Down

0 comments on commit 32f24d4

Please sign in to comment.