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 authored and TokisanGames committed Jan 2, 2025
1 parent c75f6a3 commit b8ad459
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
11 changes: 3 additions & 8 deletions doc/docs/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,20 @@ The OpenGLES 3.0 Compatibility renderer is mostly supported from Terrain3D 0.9.3

**Both versions**

* If using a custom override shader, we add a special COMPATIBILITY_DEFINES block to your shader that will allow certain features to work properly (eg the fma() function). We remove this block from your shader if you switch back to Mobile or Forward. It is normal to receive a shader dump in your console during this transition, but it should not repeat every start, once saved.
* If using a custom override shader, we add a special COMPATIBILITY_DEFINES section to your shader that will allow certain features to work properly (eg the fma() function). We remove this block from your shader if you switch back to Mobile or Forward. It is normal to receive a shader dump in your console during this transition, but it should not repeat every start, once saved.

* `IS_COMPATIBILITY` is defined in this block should you wish to check against it with your own custom preprocessor statements.
* `IS_COMPATIBILITY` is defined in this section should you wish to check against it with your own custom preprocessor statements.

* If enabling compatibility mode on the command line, we cannot detect that currently. You can tell Terrain3D with a special parameter:

`Godot_v4.3-stable_win64_console.exe --rendering-driver opengl3 -e project.godot --terrain3d-renderer=compatibility`

**Godot 4.3**

* `VRAM Compressed` is only partially supported. You can use 2 textures in the asset list. If a third is added, Godot will crash. It seems to be fixed in 4.4. The workaround for now is to select `VRAM Uncompressed` or `Lossless` on the Import tab and reimport for all of your textures.

* Textures that are imported with `VRAM Compressed` are forced uncompressed and a warning issued. You can disable the warning by manually selecting `VRAM Uncompressed` or `Lossless` on the Import tab and reimport for all of your textures. Compression seems to be fixed in 4.4. If you still get a black terrain or crashing adding additional textures, manually change your textures to `VRAM Uncompressed` or `Lossless` on the Import tab and click reimport for all of them.

**Godot 4.2**

* There are some startup warnings about depth textures and glow that you can ignore.

* `VRAM Compressed` is not supported. In the `Import` panel, you must set your texture files to either `VRAM Uncompressed` or `Lossless` and reimport.

* The command line option `--rendering-method gl_compatibility` breaks the terrain in 4.2. Don't use it. The full command above works for 4.2 or 4.3.

Further reading:
Expand Down
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 1.0 - remove in Godot 4.4
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 1.0 - remove in Godot 4.4
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 1.0 - remove in Godot 4.4
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 1.0 - remove in Godot 4.4
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 1.0 - remove in Godot 4.4
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 1.0 - remove in Godot 4.4
if (warn_compatibility_decompress == true) {
LOG(WARN, "Textures were decompressed for the Compatibility renderer. Decompress in the Import panel to remove this warning. See Supported Renderers doc.");
}
emit_signal("textures_changed");
}

Expand Down

0 comments on commit b8ad459

Please sign in to comment.