diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index a014f6609c..94301ce102 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -3027,6 +3027,8 @@ do_reload_ram_image(bool allow_compression) { } _loaded_from_image = false; + Format orig_format = _format; + int orig_num_components = _num_components; LoaderOptions options; options.set_texture_flags(LoaderOptions::TF_preload); @@ -3034,6 +3036,12 @@ do_reload_ram_image(bool allow_compression) { _primary_file_num_channels, _alpha_file_channel, z, n, _has_read_pages, _has_read_mipmaps, options, NULL); + if (orig_num_components == _num_components) { + // Restore the original format, in case it was needlessly changed + // during the reload operation. + _format = orig_format; + } + if (do_has_ram_image() && record != (BamCacheRecord *)NULL) { if (cache->get_cache_textures() || (_ram_image_compression != CM_off && cache->get_cache_compressed_textures())) { // Update the cache.