diff --git a/Editor/GraphicsWindow.cpp b/Editor/GraphicsWindow.cpp index 69b1e2cd9..be52805da 100644 --- a/Editor/GraphicsWindow.cpp +++ b/Editor/GraphicsWindow.cpp @@ -14,7 +14,7 @@ void GraphicsWindow::Create(EditorComponent* _editor) wi::renderer::SetToDrawGridHelper(true); wi::renderer::SetToDrawDebugCameras(true); - SetSize(XMFLOAT2(580, 1850)); + SetSize(XMFLOAT2(580, 1880)); float step = 21; float itemheight = 18; @@ -747,6 +747,48 @@ void GraphicsWindow::Create(EditorComponent* _editor) }); AddWidget(&exposureSlider); + brightnessSlider.Create(-1.0f, 1.0f, 0, 10000, "Brightness: "); + brightnessSlider.SetSize(XMFLOAT2(wid, hei)); + brightnessSlider.SetPos(XMFLOAT2(x, y += step)); + if (editor->main->config.GetSection("graphics").Has("brightness")) + { + editor->renderPath->setBrightness(editor->main->config.GetSection("graphics").GetFloat("brightness")); + } + brightnessSlider.OnSlide([=](wi::gui::EventArgs args) { + editor->renderPath->setBrightness(args.fValue); + editor->main->config.GetSection("graphics").Set("brightness", args.fValue); + editor->main->config.Commit(); + }); + AddWidget(&brightnessSlider); + + contrastSlider.Create(0.0f, 2.0f, 1, 10000, "Contrast: "); + contrastSlider.SetSize(XMFLOAT2(wid, hei)); + contrastSlider.SetPos(XMFLOAT2(x, y += step)); + if (editor->main->config.GetSection("graphics").Has("contrast")) + { + editor->renderPath->setContrast(editor->main->config.GetSection("graphics").GetFloat("contrast")); + } + contrastSlider.OnSlide([=](wi::gui::EventArgs args) { + editor->renderPath->setContrast(args.fValue); + editor->main->config.GetSection("graphics").Set("contrast", args.fValue); + editor->main->config.Commit(); + }); + AddWidget(&contrastSlider); + + saturationSlider.Create(0.0f, 2.0f, 1, 10000, "Saturation: "); + saturationSlider.SetSize(XMFLOAT2(wid, hei)); + saturationSlider.SetPos(XMFLOAT2(x, y += step)); + if (editor->main->config.GetSection("graphics").Has("saturation")) + { + editor->renderPath->setSaturation(editor->main->config.GetSection("graphics").GetFloat("saturation")); + } + saturationSlider.OnSlide([=](wi::gui::EventArgs args) { + editor->renderPath->setSaturation(args.fValue); + editor->main->config.GetSection("graphics").Set("saturation", args.fValue); + editor->main->config.Commit(); + }); + AddWidget(&saturationSlider); + lensFlareCheckBox.Create("LensFlare: "); lensFlareCheckBox.SetTooltip("Toggle visibility of light source flares. Additional setup needed per light for a lensflare to be visible."); lensFlareCheckBox.SetScriptTip("RenderPath3D::SetLensFlareEnabled(bool value)"); @@ -1532,6 +1574,9 @@ void GraphicsWindow::Update() resolutionScaleSlider.SetValue(editor->resolutionScale); MSAAComboBox.SetSelectedByUserdataWithoutCallback(editor->renderPath->getMSAASampleCount()); exposureSlider.SetValue(editor->renderPath->getExposure()); + brightnessSlider.SetValue(editor->renderPath->getBrightness()); + contrastSlider.SetValue(editor->renderPath->getContrast()); + saturationSlider.SetValue(editor->renderPath->getSaturation()); lensFlareCheckBox.SetCheck(editor->renderPath->getLensFlareEnabled()); lightShaftsCheckBox.SetCheck(editor->renderPath->getLightShaftsEnabled()); lightShaftsStrengthStrengthSlider.SetValue(editor->renderPath->getLightShaftsStrength()); @@ -1809,6 +1854,9 @@ void GraphicsWindow::ResizeLayout() y += jump; add(exposureSlider); + add(brightnessSlider); + add(contrastSlider); + add(saturationSlider); add_right(lensFlareCheckBox); add_right(lightShaftsStrengthStrengthSlider); lightShaftsCheckBox.SetPos(XMFLOAT2(lightShaftsStrengthStrengthSlider.GetPos().x - lightShaftsCheckBox.GetSize().x - 80, lightShaftsStrengthStrengthSlider.GetPos().y)); diff --git a/Editor/GraphicsWindow.h b/Editor/GraphicsWindow.h index 5af8c67ad..5320b654e 100644 --- a/Editor/GraphicsWindow.h +++ b/Editor/GraphicsWindow.h @@ -53,6 +53,9 @@ public: wi::gui::CheckBox forceDiffuseLightingCheckBox; wi::gui::Slider exposureSlider; + wi::gui::Slider brightnessSlider; + wi::gui::Slider contrastSlider; + wi::gui::Slider saturationSlider; wi::gui::CheckBox lensFlareCheckBox; wi::gui::CheckBox lightShaftsCheckBox; wi::gui::Slider lightShaftsStrengthStrengthSlider; diff --git a/WickedEngine/shaders/tonemapCS.hlsl b/WickedEngine/shaders/tonemapCS.hlsl index fc9a78a57..e5026bdb3 100644 --- a/WickedEngine/shaders/tonemapCS.hlsl +++ b/WickedEngine/shaders/tonemapCS.hlsl @@ -42,19 +42,19 @@ float3 ACESFitted(float3 color) return color; } -float4x4 saturationMatrix(float saturate) +float4x4 saturationMatrix(float saturation) { float3 luminance = float3(0.3086f, 0.6094f, 0.0820f); - float oneMinusSat = 1.0f - saturate; + float oneMinusSat = 1.0f - saturation; float3 red = float3(luminance * oneMinusSat); - red += float3(saturate, 0, 0); + red += float3(saturation, 0, 0); float3 green = float3(luminance * oneMinusSat); - green += float3(0, saturate, 0); + green += float3(0, saturation, 0); float3 blue = float3(luminance * oneMinusSat); - blue += float3(0, 0, saturate); + blue += float3(0, 0, saturation); return float4x4(red, 0, green, 0, blue, 0, 0, 0, 0, 1); } @@ -139,30 +139,8 @@ void main(uint3 DTid : SV_DispatchThreadID) result.rgb += (dither((float2)DTid.xy) - 0.5f) / 64.0f; } - float saturationIntensity = 1.0f; - float brightness = 0.0f; - float contrast = 1.0f; - - [branch] - if (tonemap_push.brightness >= 0) - { - brightness = tonemap_push.brightness; - } - - [branch] - if (tonemap_push.contrast >= 0) - { - contrast = tonemap_push.contrast; - } - - [branch] - if (tonemap_push.saturation >= 0) - { - saturationIntensity = tonemap_push.saturation; - } - - result.rgb = (result.rgb - 0.5f) * contrast + 0.5f + brightness; - result.rgb = (float3)(mul(saturationMatrix(saturationIntensity), result)); + result.rgb = (result.rgb - 0.5f) * tonemap_push.contrast + 0.5f + tonemap_push.brightness; + result.rgb = (float3)(mul(saturationMatrix(tonemap_push.saturation), result)); [branch] if (tonemap_push.texture_output >= 0) diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index b233eadd1..a86fb6aff 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 76; + const int revision = 77; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);