yw4z suggestion

Co-Authored-By: yw4z <yw4z@outlook.com>
This commit is contained in:
RF47
2026-05-18 10:28:57 -03:00
parent edaf582136
commit 5194e46877
5 changed files with 61 additions and 27 deletions

View File

@@ -259,6 +259,12 @@ void AppConfig::set_defaults()
if (get(SETTING_OPENGL_SHOW_FPS_OVERLAY).empty())
set_bool(SETTING_OPENGL_SHOW_FPS_OVERLAY, false);
if (get(SETTING_OPENGL_REALISTIC_MODE).empty())
set_bool(SETTING_OPENGL_REALISTIC_MODE, false);
if (get(SETTING_OPENGL_REALISTIC_PHONG).empty())
set_bool(SETTING_OPENGL_REALISTIC_PHONG, true);
if (get(SETTING_OPENGL_SHADING_MODEL).empty())
set(SETTING_OPENGL_SHADING_MODEL, "gouraud");

View File

@@ -34,6 +34,8 @@ using namespace nlohmann;
#define SETTING_OPENGL_FXAA_ENABLED "opengl_fxaa_enabled"
#define SETTING_OPENGL_FPS_CAP "opengl_fps_cap"
#define SETTING_OPENGL_SHOW_FPS_OVERLAY "opengl_show_fps_overlay"
#define SETTING_OPENGL_REALISTIC_MODE "opengl_realistic_mode"
#define SETTING_OPENGL_REALISTIC_PHONG "opengl_realistic_phong"
#define SETTING_OPENGL_SHADING_MODEL "opengl_shading_model"
#define SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS "opengl_phong_basic_plate_shadows"
#define SETTING_OPENGL_PHONG_SSAO "opengl_phong_ssao"

View File

@@ -222,7 +222,12 @@ void GCodeViewer::SequentialView::Marker::render(int canvas_width, int canvas_he
if (!m_visible)
return;
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
const bool use_phong = wxGetApp().app_config != nullptr &&
wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_MODE) &&
wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_PHONG);
GLShaderProgram* shader = wxGetApp().get_shader(use_phong ? "phong" : "gouraud_light");
if (shader == nullptr)
shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
return;
@@ -2414,7 +2419,12 @@ void GCodeViewer::render_shells(int canvas_width, int canvas_height)
//if (!m_shells.visible || m_shells.volumes.empty())
return;
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
const bool use_phong = wxGetApp().app_config != nullptr &&
wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_MODE) &&
wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_PHONG);
GLShaderProgram* shader = wxGetApp().get_shader(use_phong ? "phong" : "gouraud_light");
if (shader == nullptr)
shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
return;

View File

@@ -7523,7 +7523,8 @@ bool GLCanvas3D::_is_ssao_enabled() const
{
if (wxGetApp().app_config == nullptr)
return false;
return wxGetApp().app_config->get_bool(SETTING_OPENGL_PHONG_SSAO);
return wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_MODE) &&
wxGetApp().app_config->get_bool(SETTING_OPENGL_PHONG_SSAO);
}
int GLCanvas3D::_get_effective_fps_cap() const
@@ -7782,6 +7783,8 @@ void GLCanvas3D::_render_cast_shadows_on_plate(const Transform3d& view_matrix, c
// Check if shadow rendering is enabled in configuration
if (wxGetApp().app_config == nullptr)
return;
if (!wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_MODE))
return;
if (!wxGetApp().app_config->get_bool(SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS))
return;
if (m_volumes.empty())
@@ -8045,8 +8048,9 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
else
m_volumes.set_show_sinking_contours(!m_gizmos.is_hiding_instances());
const std::string shading_model = wxGetApp().app_config->get(SETTING_OPENGL_SHADING_MODEL);
const std::string shader_name = (shading_model == "phong") ? "phong" : "gouraud";
const bool realistic_mode = wxGetApp().app_config != nullptr && wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_MODE);
const bool realistic_phong = wxGetApp().app_config != nullptr && wxGetApp().app_config->get_bool(SETTING_OPENGL_REALISTIC_PHONG);
const std::string shader_name = (realistic_mode && realistic_phong) ? "phong" : "gouraud";
GLShaderProgram* shader = wxGetApp().get_shader(shader_name);
if (shader == nullptr && shader_name != "gouraud")
shader = wxGetApp().get_shader("gouraud");
@@ -9132,30 +9136,11 @@ void GLCanvas3D::_render_canvas_toolbar()
[this]{wxGetApp().toggle_show_outline();}
);
create_menu_item( _utf8(L("Reflections")),
m_canvas_type == ECanvasType::CanvasView3D,
cfg->get(SETTING_OPENGL_SHADING_MODEL) == "phong",
[this, &cfg]{
const bool enabled = cfg->get(SETTING_OPENGL_SHADING_MODEL) == "phong";
cfg->set(SETTING_OPENGL_SHADING_MODEL, enabled ? "gouraud" : "phong");
cfg->save();
}
);
create_menu_item( _utf8(L("Ambient Occlusion")),
create_menu_item( _utf8(L("Realistic mode")),
m_canvas_type != ECanvasType::CanvasAssembleView,
cfg->get_bool(SETTING_OPENGL_PHONG_SSAO),
cfg->get_bool(SETTING_OPENGL_REALISTIC_MODE),
[this, &cfg]{
cfg->set_bool(SETTING_OPENGL_PHONG_SSAO, !cfg->get_bool(SETTING_OPENGL_PHONG_SSAO));
cfg->save();
}
);
create_menu_item( _utf8(L("Shadows")),
m_canvas_type == ECanvasType::CanvasView3D,
cfg->get_bool(SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS),
[this, &cfg]{
cfg->set_bool(SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS, !cfg->get_bool(SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS));
cfg->set_bool(SETTING_OPENGL_REALISTIC_MODE, !cfg->get_bool(SETTING_OPENGL_REALISTIC_MODE));
cfg->save();
}
);

View File

@@ -1540,6 +1540,37 @@ void PreferencesDialog::create_items()
g_sizer = f_sizers.back();
g_sizer->AddGrowableCol(0, 1);
//// GRAPHICS > Realistic view
g_sizer->Add(create_item_title(_L("Realistic view")), 1, wxEXPAND);
auto item_realistic_mode = create_item_checkbox(
_L("Enable realistic view"),
_L("Enables realistic rendering mode in the 3D canvas."),
SETTING_OPENGL_REALISTIC_MODE
);
g_sizer->Add(item_realistic_mode);
auto item_realistic_phong = create_item_checkbox(
_L("Phong shading"),
_L("Uses Phong shading inside realistic view.")
, SETTING_OPENGL_REALISTIC_PHONG
);
g_sizer->Add(item_realistic_phong);
auto item_realistic_ssao = create_item_checkbox(
_L("SSAO ambient occlusion"),
_L("Applies SSAO in realistic view."),
SETTING_OPENGL_PHONG_SSAO
);
g_sizer->Add(item_realistic_ssao);
auto item_realistic_shadows = create_item_checkbox(
_L("Shadows"),
_L("Renders cast shadows on the plate in realistic view."),
SETTING_OPENGL_PHONG_BASIC_PLATE_SHADOWS
);
g_sizer->Add(item_realistic_shadows);
//// GRAPHICS > Anti-aliasing
g_sizer->Add(create_item_title(_L("Anti-aliasing")), 1, wxEXPAND);