From f9ad019f38986630d64343c80a9f48e16a3e6f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Tue, 21 May 2024 06:48:15 +0200 Subject: [PATCH] editor: sampler modifications will happen after system init --- Editor/Editor.cpp | 6 +++++- Editor/GraphicsWindow.cpp | 28 +++++++++++++++++----------- Editor/GraphicsWindow.h | 2 ++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 92e0fcabe..b7e748ba1 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -1002,10 +1002,12 @@ void EditorComponent::Load() } void EditorComponent::Start() { + // Start() is called after system initialization is complete, while Load() can be while initialization is still not finished + // Therefore we initialize things in Start which would need to be after system initializations: + // Font icon is from #include "FontAwesomeV6.h" // We will not directly use this font style, but let the font renderer fall back on it // when an icon character is not found in the default font. - // This is added on main thread, not inside Load(), to avoid conflict with font system intialization wi::font::AddFontStyle("FontAwesomeV6", font_awesome_v6, font_awesome_v6_size); // Add other fonts that were loaded from fonts directory as fallback fonts: @@ -1014,6 +1016,8 @@ void EditorComponent::Start() wi::font::AddFontStyle(x.name, x.filedata.data(), x.filedata.size()); } + graphicsWnd.ApplySamplerSettings(); + RenderPath2D::Start(); } void EditorComponent::PreUpdate() diff --git a/Editor/GraphicsWindow.cpp b/Editor/GraphicsWindow.cpp index a10d7ddcb..7e24f0a99 100644 --- a/Editor/GraphicsWindow.cpp +++ b/Editor/GraphicsWindow.cpp @@ -630,23 +630,17 @@ void GraphicsWindow::Create(EditorComponent* _editor) break; } + desc.mip_lod_bias = wi::math::Clamp(mipLodBiasSlider.GetValue(), -15.9f, 15.9f); + wi::renderer::ModifyObjectSampler(desc); editor->main->config.GetSection("graphics").Set("texture_quality", args.iValue); editor->main->config.Commit(); }); - if (editor->main->config.GetSection("graphics").Has("texture_quality")) - { - textureQualityComboBox.SetSelected(editor->main->config.GetSection("graphics").GetInt("texture_quality")); - } - else - { - textureQualityComboBox.SetSelected(3); - } textureQualityComboBox.SetTooltip("Choose a texture sampling method for material textures."); AddWidget(&textureQualityComboBox); - mipLodBiasSlider.Create(-2, 2, 0, 100000, "MipLOD Bias: "); + mipLodBiasSlider.Create(-16, 16, 0, 100000, "MipLOD Bias: "); mipLodBiasSlider.SetTooltip("Bias the rendered mip map level of the material textures."); mipLodBiasSlider.SetSize(XMFLOAT2(wid, itemheight)); mipLodBiasSlider.SetPos(XMFLOAT2(x, y += step)); @@ -1398,7 +1392,6 @@ void GraphicsWindow::Create(EditorComponent* _editor) fsr2Combo.Create("FSR 2.1 Preset: "); fsr2Combo.SetTooltip("Set resolution scaling quality mode for FSR 2.1:\nQuality: 1.5x\nBalanced: 1.7x\nPerformance: 2.0x\nUltra performance: 3.0x"); - int fsr2_preset = editor->main->config.GetSection("graphics").GetInt("fsr2_preset"); fsr2Combo.SetSize(XMFLOAT2(wid, hei)); fsr2Combo.SetPos(XMFLOAT2(x, y += step)); fsr2Combo.AddItem("Quality", (uint64_t)wi::RenderPath3D::FSR2_Preset::Quality); @@ -1415,7 +1408,6 @@ void GraphicsWindow::Create(EditorComponent* _editor) editor->main->config.GetSection("graphics").Set("fsr2_preset", args.iValue); editor->main->config.Commit(); }); - fsr2Combo.SetSelected(fsr2_preset); AddWidget(&fsr2Combo); SetVisible(false); @@ -1855,3 +1847,17 @@ void GraphicsWindow::ResizeLayout() } + +void GraphicsWindow::ApplySamplerSettings() +{ + if (editor->main->config.GetSection("graphics").Has("texture_quality")) + { + textureQualityComboBox.SetSelected(editor->main->config.GetSection("graphics").GetInt("texture_quality")); + } + else + { + textureQualityComboBox.SetSelected(3); + } + int fsr2_preset = editor->main->config.GetSection("graphics").GetInt("fsr2_preset"); + fsr2Combo.SetSelected(fsr2_preset); // modifies sampler bias +} diff --git a/Editor/GraphicsWindow.h b/Editor/GraphicsWindow.h index 3d26b74f2..c6207dba4 100644 --- a/Editor/GraphicsWindow.h +++ b/Editor/GraphicsWindow.h @@ -110,5 +110,7 @@ public: void Update(); void ResizeLayout() override; + + void ApplySamplerSettings(); };