From f83cd4b87a5bdf9976fa740bdd7484fc422971e0 Mon Sep 17 00:00:00 2001 From: supermerill Date: Thu, 18 Jan 2024 13:26:03 +0100 Subject: [PATCH] Bed texture fixes: . if vendor has only texture or model, still show it. . png texture can turn black on compression on soe hardware. A new preference (compress_png_texture) is now available to disable the optimisation that can cause that. You have to relaunch the app to force the reload of the texture or: remove it, go to platter, then re-add it. --- src/libslic3r/AppConfig.cpp | 3 +++ src/slic3r/GUI/3DBed.cpp | 9 +++++++-- src/slic3r/GUI/Preferences.cpp | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index ae0c883fb8f..75e7b1080b9 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -361,6 +361,9 @@ void AppConfig::set_defaults() set("check_blacklisted_library", "1"); #endif // _WIN32 + if (get("compress_png_texture").empty()) + set("compress_png_texture", "1"); + // remove old 'use_legacy_opengl' parameter from this config, if present if (!get("use_legacy_opengl").empty()) erase("", "use_legacy_opengl"); diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index a263dd8c49a..6bd072654fd 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -392,6 +392,10 @@ std::tuple Bed3D::detect_type(const std::string texture_filename = PresetUtils::system_printer_bed_texture(*curr); if (!model_filename.empty() && !texture_filename.empty()) return { Type::System, model_filename, texture_filename, PresetUtils::system_printer_model(*curr)->bed_with_grid }; + else if(!model_filename.empty()) + return { Type::System, model_filename, {}, true }; + else if(!texture_filename.empty()) + return { Type::System, {}, texture_filename, PresetUtils::system_printer_model(*curr)->bed_with_grid}; } } @@ -452,7 +456,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const } else if (boost::algorithm::iends_with(texture_absolute_filename, ".png")) { // generate a temporary lower resolution texture to show while no main texture levels have been compressed - if (temp_texture->get_id() == 0 || temp_texture->get_source() != texture_absolute_filename) { + if (wxGetApp().app_config->get("compress_png_texture") == "1" && (temp_texture->get_id() == 0 || temp_texture->get_source() != texture_absolute_filename)) { if (!temp_texture->load_from_file(texture_absolute_filename, false, GLTexture::None, false)) { render_default(bottom, false); return; @@ -461,7 +465,8 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const } // starts generating the main texture, compression will run asynchronously - if (!texture->load_from_file(texture_absolute_filename, true, GLTexture::MultiThreaded, true)) { + if (!texture->load_from_file(texture_absolute_filename, true, + wxGetApp().app_config->get("compress_png_texture") == "1" ? GLTexture::MultiThreaded : GLTexture::ECompressionType::None, true)) { render_default(bottom, false); return; } diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index ab6039ff013..6da31dc9110 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -480,6 +480,13 @@ void PreferencesDialog::build(size_t selected_tab) m_optgroup_camera->append_single_option_line(option); #endif // _WIN32 || __APPLE__ + def.label = L("Compress png textures"); + def.type = coBool; + def.tooltip = L("If your custom texture (in png format) is displayed black, then disable this option to remove the problematic optimisation."); + def.set_default_value(new ConfigOptionBool{ app_config->get("compress_png_texture") == "1" }); + option = Option(def, "compress_png_texture"); + m_optgroup_camera->append_single_option_line(option); + activate_options_tab(m_optgroup_camera); // Add "GUI" tab