summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_export.cpp30
-rw-r--r--editor/editor_export.h2
-rw-r--r--editor/import/resource_importer_layered_texture.cpp21
-rw-r--r--editor/import/resource_importer_texture.cpp41
-rw-r--r--editor/project_settings_editor.cpp1
5 files changed, 89 insertions, 6 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 5c911a00ca..721158cebb 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -661,6 +661,21 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
List<String> remaps;
config->get_section_keys("remap", &remaps);
+ Set<String> remap_features;
+
+ for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
+
+ String remap = F->get();
+ String feature = remap.get_slice(".", 1);
+ if (feature == "fallback" || features.has(feature)) {
+ remap_features.insert(feature);
+ }
+ }
+
+ if (remap_features.size() > 1) {
+ this->resolve_platform_feature_priorities(p_preset, remap_features);
+ }
+
for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
String remap = F->get();
@@ -670,7 +685,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
p_func(p_udata, remapped_path, array, idx, total);
} else if (remap.begins_with("path.")) {
String feature = remap.get_slice(".", 1);
- if (features.has(feature)) {
+
+ if (remap_features.has(feature)) {
String remapped_path = config->get_value("remap", remap);
Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
p_func(p_udata, remapped_path, array, idx, total);
@@ -1249,9 +1265,11 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &
void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/no_bptc_fallbacks"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE), ""));
@@ -1434,6 +1452,16 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
}
}
+void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) {
+
+ if (p_features.has("bptc")) {
+ if (p_preset->has("texture_format/no_bptc_fallbacks")) {
+ p_features.erase("s3tc");
+ p_features.erase("fallback");
+ }
+ }
+}
+
int EditorExportPlatformPC::get_chmod_flags() const {
return chmod_flags;
diff --git a/editor/editor_export.h b/editor/editor_export.h
index 1d0b89cf16..b984d66a1b 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -246,6 +246,7 @@ public:
virtual Error export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual void get_platform_features(List<String> *r_features) = 0;
+ virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) = 0;
EditorExportPlatform();
};
@@ -403,6 +404,7 @@ public:
void add_platform_feature(const String &p_feature);
virtual void get_platform_features(List<String> *r_features);
+ virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features);
int get_chmod_flags() const;
void set_chmod_flags(int p_flags);
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index 2f958a6fdd..211bb7bcc9 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -163,6 +163,7 @@ void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_imag
Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
int compress_mode = p_options["compress/mode"];
+ int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"];
int repeat = p_options["flags/repeat"];
bool filter = p_options["flags/filter"];
bool mipmaps = p_options["flags/mipmaps"];
@@ -226,6 +227,26 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
//Android, GLES 2.x
bool ok_on_pc = false;
+ bool encode_bptc = false;
+
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) {
+
+ encode_bptc = true;
+
+ if (no_bptc_if_rgb) {
+ Image::DetectChannels channels = image->get_detected_channels();
+ if (channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) {
+ encode_bptc = false;
+ }
+ }
+ }
+
+ if (encode_bptc) {
+
+ _save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps, tex_flags);
+ r_platform_variants->push_back("bptc");
+ ok_on_pc = true;
+ }
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index a2d54e0048..7feb506270 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -188,7 +188,8 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "Compress,Force RGBE"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "LDR Fallback,Force RGBE,RGBE Fallback"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/normal_map", PROPERTY_HINT_ENUM, "Detect,Enable,Disabled"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset == PRESET_2D_PIXEL ? false : true));
@@ -347,6 +348,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
int compress_mode = p_options["compress/mode"];
+ int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"];
float lossy = p_options["compress/lossy_quality"];
int repeat = p_options["flags/repeat"];
bool filter = p_options["flags/filter"];
@@ -359,6 +361,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
bool stream = p_options["stream"];
int size_limit = p_options["size_limit"];
bool force_rgbe = int(p_options["compress/hdr_mode"]) == 1;
+ bool rgbe_fallback = int(p_options["compress/hdr_mode"]) == 2;
bool hdr_as_srgb = p_options["process/HDR_as_SRGB"];
int normal = p_options["compress/normal_map"];
float scale = p_options["svg/scale"];
@@ -434,31 +437,59 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
//Android, GLES 2.x
bool ok_on_pc = false;
+ bool encode_bptc = false;
+ bool is_hdr = (image->get_format() >= Image::FORMAT_RF && image->get_format() <= Image::FORMAT_RGBE9995);
+ bool no_ldr_compression = (is_hdr && rgbe_fallback);
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) {
+
+ encode_bptc = true;
+
+ if (no_bptc_if_rgb && !is_hdr) {
+ Image::DetectChannels channels = image->get_detected_channels();
+ if (channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) {
+ encode_bptc = false;
+ }
+ }
+ }
+
+ if (encode_bptc) {
+
+ _save_stex(image, p_save_path + ".bptc.stex", compress_mode, lossy, Image::COMPRESS_BPTC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
+ r_platform_variants->push_back("bptc");
+ ok_on_pc = true;
+ }
+
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("s3tc");
ok_on_pc = true;
}
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("etc2");
}
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("etc");
}
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("pvrtc");
}
+ if (is_hdr && rgbe_fallback) {
+ _save_stex(image, p_save_path + ".fallback.stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, true, detect_normal, force_normal);
+ r_platform_variants->push_back("fallback");
+ ok_on_pc = true;
+ }
+
if (!ok_on_pc) {
EditorNode::add_io_error("Warning, no suitable PC VRAM compression enabled in Project Settings. This texture will not display correcly on PC.");
}
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 970302e058..65b2e2301b 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -1007,6 +1007,7 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
Set<String> presets;
+ presets.insert("bptc");
presets.insert("s3tc");
presets.insert("etc");
presets.insert("etc2");