From b937c023f348071eef9e7e00239dd364a2a26c54 Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Mon, 8 Feb 2021 22:07:29 +0100 Subject: [PATCH] color grading map is now part of weather --- Editor/Editor.cpp | 11 ------- Editor/PostprocessWindow.cpp | 37 +--------------------- Editor/PostprocessWindow.h | 1 - Editor/WeatherWindow.cpp | 44 ++++++++++++++++++++++++++ Editor/WeatherWindow.h | 1 + WickedEngine/ArchiveVersionHistory.txt | 1 + WickedEngine/RenderPath3D.cpp | 2 +- WickedEngine/RenderPath3D.h | 10 ++---- WickedEngine/wiArchive.cpp | 2 +- WickedEngine/wiScene.h | 4 ++- WickedEngine/wiScene_Serializers.cpp | 37 ++++++++++++++++------ WickedEngine/wiVersion.cpp | 2 +- 12 files changed, 83 insertions(+), 69 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 236e7b94d..e6eeb8805 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -121,17 +121,6 @@ void EditorComponent::ChangeRenderPath(RENDERPATH path) renderPath->resolutionScale = resolutionScale; - renderPath->setShadowsEnabled(true); - renderPath->setReflectionsEnabled(true); - renderPath->setAO(RenderPath3D::AO_DISABLED); - renderPath->setSSREnabled(false); - renderPath->setMotionBlurEnabled(false); - renderPath->setColorGradingEnabled(false); - renderPath->setEyeAdaptionEnabled(false); - renderPath->setFXAAEnabled(false); - renderPath->setDepthOfFieldEnabled(false); - renderPath->setLightShaftsEnabled(false); - renderPath->Load(); wiGUI& gui = GetGUI(); diff --git a/Editor/PostprocessWindow.cpp b/Editor/PostprocessWindow.cpp index de8c65878..8cf6a542d 100644 --- a/Editor/PostprocessWindow.cpp +++ b/Editor/PostprocessWindow.cpp @@ -295,8 +295,7 @@ void PostprocessWindow::Create(EditorComponent* editor) AddWidget(&fxaaCheckBox); colorGradingCheckBox.Create("Color Grading: "); - colorGradingCheckBox.SetTooltip("Enable color grading of the final render. An additional lookup texture must be set for it to take effect."); - colorGradingCheckBox.SetScriptTip("RenderPath3D::SetColorGradingEnabled(bool value)"); + colorGradingCheckBox.SetTooltip("Enable color grading of the final render. An additional lookup texture must be set in the Weather!"); colorGradingCheckBox.SetSize(XMFLOAT2(hei, hei)); colorGradingCheckBox.SetPos(XMFLOAT2(x, y += step)); colorGradingCheckBox.SetCheck(editor->renderPath->getColorGradingEnabled()); @@ -305,40 +304,6 @@ void PostprocessWindow::Create(EditorComponent* editor) }); AddWidget(&colorGradingCheckBox); - colorGradingButton.Create("Load Color Grading LUT..."); - colorGradingButton.SetTooltip("Load a color grading lookup texture. It must be a 256x16 RGBA image!"); - colorGradingButton.SetPos(XMFLOAT2(x + 35, y)); - colorGradingButton.SetSize(XMFLOAT2(200, hei)); - colorGradingButton.OnClick([=](wiEventArgs args) { - auto x = editor->renderPath->getColorGradingTexture(); - - if (x == nullptr) - { - wiHelper::FileDialogParams params; - params.type = wiHelper::FileDialogParams::OPEN; - params.description = "Texture"; - params.extensions.push_back("png"); - params.extensions.push_back("tga"); - params.extensions.push_back("bmp"); - wiHelper::FileDialog(params, [=](std::string fileName) { - wiEvent::Subscribe_Once(SYSTEM_EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { - editor->renderPath->setColorGradingTexture(wiResourceManager::Load(fileName, wiResourceManager::IMPORT_COLORGRADINGLUT)); - if (editor->renderPath->getColorGradingTexture() != nullptr) - { - colorGradingButton.SetText(fileName); - } - }); - }); - } - else - { - editor->renderPath->setColorGradingTexture(nullptr); - colorGradingButton.SetText("Load Color Grading LUT..."); - } - - }); - AddWidget(&colorGradingButton); - ditherCheckBox.Create("Dithering: "); ditherCheckBox.SetTooltip("Toggle the full screen dithering effect. This helps to reduce color banding."); ditherCheckBox.SetSize(XMFLOAT2(hei, hei)); diff --git a/Editor/PostprocessWindow.h b/Editor/PostprocessWindow.h index 08d622739..ed041f05f 100644 --- a/Editor/PostprocessWindow.h +++ b/Editor/PostprocessWindow.h @@ -32,7 +32,6 @@ public: wiSlider bloomStrengthSlider; wiCheckBox fxaaCheckBox; wiCheckBox colorGradingCheckBox; - wiButton colorGradingButton; wiCheckBox ditherCheckBox; wiCheckBox sharpenFilterCheckBox; wiSlider sharpenFilterAmountSlider; diff --git a/Editor/WeatherWindow.cpp b/Editor/WeatherWindow.cpp index d36d46cad..bb783cfae 100644 --- a/Editor/WeatherWindow.cpp +++ b/Editor/WeatherWindow.cpp @@ -171,6 +171,40 @@ void WeatherWindow::Create(EditorComponent* editor) }); AddWidget(&skyButton); + colorgradingButton.Create("Load Color Grading LUT"); + colorgradingButton.SetTooltip("Load a color grading lookup texture. It must be a 256x16 RGBA image!"); + colorgradingButton.SetSize(XMFLOAT2(240, hei)); + colorgradingButton.SetPos(XMFLOAT2(x - 100, y += step)); + colorgradingButton.OnClick([=](wiEventArgs args) { + auto& weather = GetWeather(); + + if (weather.colorGradingMap == nullptr) + { + wiHelper::FileDialogParams params; + params.type = wiHelper::FileDialogParams::OPEN; + params.description = "Texture"; + params.extensions.push_back("png"); + params.extensions.push_back("tga"); + params.extensions.push_back("bmp"); + wiHelper::FileDialog(params, [=](std::string fileName) { + wiEvent::Subscribe_Once(SYSTEM_EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { + auto& weather = GetWeather(); + weather.colorGradingMapName = fileName; + weather.colorGradingMap = wiResourceManager::Load(fileName, wiResourceManager::IMPORT_COLORGRADINGLUT); + colorgradingButton.SetText(fileName); + }); + }); + } + else + { + weather.colorGradingMap.reset(); + weather.colorGradingMapName.clear(); + colorgradingButton.SetText("Load Color Grading LUT"); + } + + }); + AddWidget(&colorgradingButton); + // Ocean params: @@ -499,6 +533,16 @@ void WeatherWindow::Update() { auto& weather = scene.weathers[0]; + if (!weather.skyMapName.empty()) + { + skyButton.SetText(weather.skyMapName); + } + + if (!weather.colorGradingMapName.empty()) + { + colorgradingButton.SetText(weather.colorGradingMapName); + } + fogStartSlider.SetValue(weather.fogStart); fogEndSlider.SetValue(weather.fogEnd); fogHeightSlider.SetValue(weather.fogHeight); diff --git a/Editor/WeatherWindow.h b/Editor/WeatherWindow.h index 5f0c1cc4a..ebd7e1d9c 100644 --- a/Editor/WeatherWindow.h +++ b/Editor/WeatherWindow.h @@ -28,6 +28,7 @@ public: wiCheckBox simpleskyCheckBox; wiCheckBox realisticskyCheckBox; wiButton skyButton; + wiButton colorgradingButton; // ocean params: wiCheckBox ocean_enabledCheckBox; diff --git a/WickedEngine/ArchiveVersionHistory.txt b/WickedEngine/ArchiveVersionHistory.txt index de40b63db..8ca81bbdb 100644 --- a/WickedEngine/ArchiveVersionHistory.txt +++ b/WickedEngine/ArchiveVersionHistory.txt @@ -1,5 +1,6 @@ This file contains changelog of wiArchive versions +62: serialized WeatherComponent::colorGradingMapName property 61: serialized sheen and clearcoat material properties 60: serializer ObjectComponent::emissiveColor 59: serialized MaterialComponent transmission parameters diff --git a/WickedEngine/RenderPath3D.cpp b/WickedEngine/RenderPath3D.cpp index 5d9052ca9..b5c0ed3ae 100644 --- a/WickedEngine/RenderPath3D.cpp +++ b/WickedEngine/RenderPath3D.cpp @@ -1339,7 +1339,7 @@ void RenderPath3D::RenderPostprocessChain(CommandList cmd) const cmd, getExposure(), getDitherEnabled(), - getColorGradingEnabled() ? colorGradingTex->texture : nullptr + getColorGradingEnabled() ? (scene->weather.colorGradingMap == nullptr ? nullptr : scene->weather.colorGradingMap->texture) : nullptr ); rt_first = nullptr; diff --git a/WickedEngine/RenderPath3D.h b/WickedEngine/RenderPath3D.h index cd67fa6fe..a514e0ea9 100644 --- a/WickedEngine/RenderPath3D.h +++ b/WickedEngine/RenderPath3D.h @@ -46,7 +46,7 @@ private: bool shadowsEnabled = true; bool bloomEnabled = true; bool volumetricCloudsEnabled = false; - bool colorGradingEnabled = false; + bool colorGradingEnabled = true; bool volumeLightsEnabled = true; bool lightShaftsEnabled = false; bool lensFlareEnabled = true; @@ -58,8 +58,6 @@ private: bool chromaticAberrationEnabled = false; bool ditherEnabled = true; - std::shared_ptr colorGradingTex; - uint32_t msaaSampleCount = 1; public: @@ -193,7 +191,7 @@ public: constexpr bool getFXAAEnabled() const { return fxaaEnabled; } constexpr bool getBloomEnabled() const { return bloomEnabled; } constexpr bool getVolumetricCloudsEnabled() const { return volumetricCloudsEnabled; } - constexpr bool getColorGradingEnabled() const { return colorGradingEnabled && colorGradingTex != nullptr; } + constexpr bool getColorGradingEnabled() const { return colorGradingEnabled; } constexpr bool getVolumeLightsEnabled() const { return volumeLightsEnabled; } constexpr bool getLightShaftsEnabled() const { return lightShaftsEnabled; } constexpr bool getLensFlareEnabled() const { return lensFlareEnabled; } @@ -205,8 +203,6 @@ public: constexpr bool getChromaticAberrationEnabled() const { return chromaticAberrationEnabled; } constexpr bool getDitherEnabled() const { return ditherEnabled; } - constexpr const std::shared_ptr& getColorGradingTexture() const { return colorGradingTex; } - constexpr uint32_t getMSAASampleCount() const { return msaaSampleCount; } constexpr void setExposure(float value) { exposure = value; } @@ -246,8 +242,6 @@ public: constexpr void setChromaticAberrationEnabled(bool value) { chromaticAberrationEnabled = value; } constexpr void setDitherEnabled(bool value) { ditherEnabled = value; } - void setColorGradingTexture(std::shared_ptr resource) { colorGradingTex = resource; } - virtual void setMSAASampleCount(uint32_t value) { if (msaaSampleCount != value) { msaaSampleCount = value; ResizeBuffers(); } } void PreUpdate() override; diff --git a/WickedEngine/wiArchive.cpp b/WickedEngine/wiArchive.cpp index 05e5d36dc..c8d7b6135 100644 --- a/WickedEngine/wiArchive.cpp +++ b/WickedEngine/wiArchive.cpp @@ -6,7 +6,7 @@ using namespace std; // this should always be only INCREMENTED and only if a new serialization is implemeted somewhere! -uint64_t __archiveVersion = 61; +uint64_t __archiveVersion = 62; // this is the version number of which below the archive is not compatible with the current version uint64_t __archiveVersionBarrier = 22; diff --git a/WickedEngine/wiScene.h b/WickedEngine/wiScene.h index 925b9242c..1ea79ebf9 100644 --- a/WickedEngine/wiScene.h +++ b/WickedEngine/wiScene.h @@ -1135,10 +1135,12 @@ namespace wiScene OceanParameters oceanParameters; std::string skyMapName; - std::shared_ptr skyMap; + std::string colorGradingMapName; // Non-serialized attributes: uint32_t most_important_light_index = ~0; + std::shared_ptr skyMap; + std::shared_ptr colorGradingMap; void Serialize(wiArchive& archive, wiECS::EntitySerializer& seri); }; diff --git a/WickedEngine/wiScene_Serializers.cpp b/WickedEngine/wiScene_Serializers.cpp index 6a2d5ce63..0b8e44b9e 100644 --- a/WickedEngine/wiScene_Serializers.cpp +++ b/WickedEngine/wiScene_Serializers.cpp @@ -945,6 +945,14 @@ namespace wiScene { archive >> windSpeed; } + if (archive.GetVersion() >= 62) + { + archive >> colorGradingMapName; + if (!colorGradingMapName.empty()) + { + colorGradingMap = wiResourceManager::Load(dir + colorGradingMapName, wiResourceManager::IMPORT_COLORGRADINGLUT); + } + } } else @@ -978,23 +986,34 @@ namespace wiScene archive << oceanParameters.surfaceDetail; archive << oceanParameters.surfaceDisplacementTolerance; + // If detecting an absolute path in textures, remove it and convert to relative: + if (!dir.empty()) + { + size_t found = skyMapName.rfind(dir); + if (found != std::string::npos) + { + skyMapName = skyMapName.substr(found + dir.length()); + } + + found = colorGradingMapName.rfind(dir); + if (found != std::string::npos) + { + colorGradingMapName = colorGradingMapName.substr(found + dir.length()); + } + } + if (archive.GetVersion() >= 32) { - // If detecting an absolute path in textures, remove it and convert to relative: - if (!dir.empty()) - { - size_t found = skyMapName.rfind(dir); - if (found != std::string::npos) - { - skyMapName = skyMapName.substr(found + dir.length()); - } - } archive << skyMapName; } if (archive.GetVersion() >= 40) { archive << windSpeed; } + if (archive.GetVersion() >= 62) + { + archive << colorGradingMapName; + } } } diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 83d0af943..e1d109c55 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates, breaking compatibility changes const int minor = 53; // minor bug fixes, alterations, refactors, updates - const int revision = 2; + const int revision = 3; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);