From 3afabb8f17c1b031a28ce87d40024078a6ee69b2 Mon Sep 17 00:00:00 2001 From: darth negative hunter <73083466+thenegativehunter2@users.noreply.github.com> Date: Sun, 29 Aug 2021 12:49:45 +0430 Subject: [PATCH 1/2] Add an import option to force TextureArrays as normal maps for RGTC i have added the option to chose normal map for channel pack. this will force the to use red and green channels for the texture only. the option is added meaning it will not conflict with the existing settings. i have made this change as a response to my own proposal Bugsquad edit: Closes godotengine/godot-proposals#3184 --- editor/import/resource_importer_layered_texture.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index d5bb21443cfe..eb44f13620e1 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -138,7 +138,7 @@ void ResourceImporterLayeredTexture::get_import_options(List *r_op r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Disabled,Enabled,RGBA Only"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized,Normal Map (RG channels"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "mipmaps/generate"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "mipmaps/limit", PROPERTY_HINT_RANGE, "-1,256"), -1)); @@ -249,7 +249,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector> p_images, cons } if (p_mipmaps) { - p_images.write[i]->generate_mipmaps(); + p_images.write[i]->generate_mipmaps(p_csource == Image::COMPRESS_SOURCE_NORMAL); } else { p_images.write[i]->clear_mipmaps(); } @@ -356,6 +356,9 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const Image::CompressSource csource = Image::COMPRESS_SOURCE_GENERIC; if (channel_pack == 0) { csource = Image::COMPRESS_SOURCE_SRGB; + } else if (channel_pack == 2) { + // force normal + csource = Image::COMPRESS_SOURCE_NORMAL; } Image::UsedChannels used_channels = image->detect_used_channels(csource); From 1cd473596a28f104e6786dd0a8be1797b1790f1d Mon Sep 17 00:00:00 2001 From: darth negative hunter <73083466+thenegativehunter2@users.noreply.github.com> Date: Fri, 17 Sep 2021 01:11:26 +0430 Subject: [PATCH 2/2] Update editor/import/resource_importer_layered_texture.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: RĂ©mi Verschelde --- editor/import/resource_importer_layered_texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index eb44f13620e1..3a2ddab3f4d5 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -138,7 +138,7 @@ void ResourceImporterLayeredTexture::get_import_options(List *r_op r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Disabled,Enabled,RGBA Only"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized,Normal Map (RG channels"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized,Normal Map (RG Channels)"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "mipmaps/generate"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "mipmaps/limit", PROPERTY_HINT_RANGE, "-1,256"), -1));