Repository: godotengine/godot
File: editor/import/resource_importer_layered_texture.cpp (C++)

Code before:
			int x = slice_w * j;
			int y = slice_h * i;
			Ref<Image> slice = image->get_rect(Rect2(x, y, slice_w, slice_h));
			ERR_CONTINUE(slice.is_null() || slice->is_empty());
			if (slice->get_width() != slice_w || slice->get_height() != slice_h) {
				slice->resize(slice_w, slice_h);
			}
			slices.push_back(slice);
		}
	}

	String extension = get_save_extension();
	Array formats_imported;

	if (compress_mode == COMPRESS_VRAM_COMPRESSED) {
		//must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc).
		//Android, GLES 2.x

		bool ok_on_pc = false;
		bool is_hdr = (image->get_format() >= Image::FORMAT_RF && image->get_format() <= Image::FORMAT_RGBE9995);
		bool is_ldr = (image->get_format() >= Image::FORMAT_L8 && image->get_format() <= Image::FORMAT_RGB565);
		bool can_bptc = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_bptc");
		bool can_s3tc = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_s3tc");

		if (can_bptc) {
			formats_imported.push_back("bptc"); //needs to be aded anyway
		}
		bool can_compress_hdr = hdr_compression > 0;

		if (is_hdr && can_compress_hdr) {
			if (used_channels == Image::USED_CHANNELS_LA || used_channels == Image::USED_CHANNELS_RGBA) {
				//can compress hdr, but hdr with alpha is not compressible

				if (hdr_compression == 2) {
					//but user selected to compress hdr anyway, so force an alpha-less format.
					if (image->get_format() == Image::FORMAT_RGBAF) {
						for (int i = 0; i < slices.size(); i++) {
							slices.write[i]->convert(Image::FORMAT_RGBF);
						}

					} else if (image->get_format() == Image::FORMAT_RGBAH) {
						for (int i = 0; i < slices.size(); i++) {
							slices.write[i]->convert(Image::FORMAT_RGBH);
						}
					}
				} else {
					can_compress_hdr = false;
				}
			}

			if (can_compress_hdr) {

Review comment (suggestion):
```suggestion
			formats_imported.push_back("bptc"); // Needs to be added anyway.
```

Code after:
			int x = slice_w * j;
			int y = slice_h * i;
			Ref<Image> slice = image->get_rect(Rect2(x, y, slice_w, slice_h));
			ERR_CONTINUE(slice.is_null() || slice->is_empty());
			if (slice->get_width() != slice_w || slice->get_height() != slice_h) {
				slice->resize(slice_w, slice_h);
			}
			slices.push_back(slice);
		}
	}

	String extension = get_save_extension();
	Array formats_imported;

	if (compress_mode == COMPRESS_VRAM_COMPRESSED) {
		//must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc).
		//Android, GLES 2.x

		bool ok_on_pc = false;
		bool is_hdr = (image->get_format() >= Image::FORMAT_RF && image->get_format() <= Image::FORMAT_RGBE9995);
		bool is_ldr = (image->get_format() >= Image::FORMAT_L8 && image->get_format() <= Image::FORMAT_RGB565);
		bool can_bptc = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_bptc");
		bool can_s3tc = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_s3tc");

		if (can_bptc) {
			formats_imported.push_back("bptc"); // Needs to be added anyway.
		}
		bool can_compress_hdr = hdr_compression > 0;

		if (is_hdr && can_compress_hdr) {
			if (used_channels == Image::USED_CHANNELS_LA || used_channels == Image::USED_CHANNELS_RGBA) {
				//can compress hdr, but hdr with alpha is not compressible

				if (hdr_compression == 2) {
					//but user selected to compress hdr anyway, so force an alpha-less format.
					if (image->get_format() == Image::FORMAT_RGBAF) {
						for (int i = 0; i < slices.size(); i++) {
							slices.write[i]->convert(Image::FORMAT_RGBF);
						}

					} else if (image->get_format() == Image::FORMAT_RGBAH) {
						for (int i = 0; i < slices.size(); i++) {
							slices.write[i]->convert(Image::FORMAT_RGBH);
						}
					}
				} else {
					can_compress_hdr = false;
				}
			}

			if (can_compress_hdr) {