Skip to content

Commit

Permalink
Bed texture fixes:
Browse files Browse the repository at this point in the history
 . 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.
  • Loading branch information
supermerill committed Jan 18, 2024
1 parent 1fb8127 commit f83cd4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
9 changes: 7 additions & 2 deletions src/slic3r/GUI/3DBed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ std::tuple<Bed3D::Type, std::string, std::string, bool> 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};
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/slic3r/GUI/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f83cd4b

Please sign in to comment.