From 60a10f43340dfb7d581ad568083d7e269b314306 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 3 Jan 2021 01:26:19 +0100 Subject: [PATCH] Add global blendDepth slider and update default blendDepth for mats --- Engine/source/terrain/terrCellMaterial.cpp | 9 +++- Engine/source/terrain/terrMaterial.cpp | 2 +- .../game/core/rendering/Core_Rendering.cs | 4 ++ .../gui/guiTerrainTextureSettingsDlg.ed.gui | 51 +++++++++++++++---- .../terrainTextureSettingsDlg.ed.cs | 9 +++- 5 files changed, 62 insertions(+), 13 deletions(-) diff --git a/Engine/source/terrain/terrCellMaterial.cpp b/Engine/source/terrain/terrCellMaterial.cpp index 0c892a967..0f3b64e14 100644 --- a/Engine/source/terrain/terrCellMaterial.cpp +++ b/Engine/source/terrain/terrCellMaterial.cpp @@ -803,7 +803,14 @@ bool TerrainCellMaterial::setupPass( const SceneRenderState *state, mConsts->set( mFogDataConst, fogData ); } - mConsts->setSafe( mBlendDepthConst, Con::getFloatVariable("$Terrain::BlendDepth", 0.2f) ); + if (String::isEmpty(Con::getVariable("$Terrain::BlendDepth"))) + { + mConsts->setSafe(mBlendDepthConst, 0.2f); + } + else + { + mConsts->setSafe(mBlendDepthConst, Con::getFloatVariable("$Terrain::BlendDepth")); + } mConsts->setSafe( mFogColorConst, sceneData.fogColor ); diff --git a/Engine/source/terrain/terrMaterial.cpp b/Engine/source/terrain/terrMaterial.cpp index 8a99fdd12..47f0b3190 100644 --- a/Engine/source/terrain/terrMaterial.cpp +++ b/Engine/source/terrain/terrMaterial.cpp @@ -68,7 +68,7 @@ TerrainMaterial::TerrainMaterial() mMacroStrength( 0.7f ), mMacroDistance( 500.0f ), mParallaxScale( 0.0f ), - mBlendDepth( 0.5f ), + mBlendDepth( 0.0f ), mBlendContrast( 1.0f ), mIsSRGB(false), mInvertRoughness(false) diff --git a/Templates/BaseGame/game/core/rendering/Core_Rendering.cs b/Templates/BaseGame/game/core/rendering/Core_Rendering.cs index 8ed5daf45..c9dd19d05 100644 --- a/Templates/BaseGame/game/core/rendering/Core_Rendering.cs +++ b/Templates/BaseGame/game/core/rendering/Core_Rendering.cs @@ -12,6 +12,7 @@ function Core_Rendering::onCreate(%this) $pref::ReflectionProbes::BakeResolution = ProjectSettings.value("Rendering/ProbeCaptureResolution", "64"); $Terrain::LerpBlend = ProjectSettings.value("Terrain/LerpBlend"); + $Terrain::BlendDepth = ProjectSettings.value("Terrain/BlendDepth"); $Terrain::DetailTextureSize = ProjectSettings.value("Terrain/DetailTextureSize"); $Terrain::MacroTextureSize = ProjectSettings.value("Terrain/MacroTextureSize"); @@ -24,6 +25,7 @@ function Core_Rendering::onCreate(%this) $Terrain::OrmTextureFormat = ProjectSettings.value("Terrain/OrmTextureFormat"); exec("./scripts/graphicsOptions.cs"); + exec("./scripts/terrainSettings.cs"); exec("./scripts/renderManager.cs"); exec("./scripts/gfxData/clouds.cs"); exec("./scripts/gfxData/commonMaterialData.cs"); @@ -32,6 +34,8 @@ function Core_Rendering::onCreate(%this) exec("./scripts/gfxData/terrainBlock.cs"); exec("./scripts/gfxData/water.cs"); exec("./scripts/gfxData/warningTerrainMat.cs"); + + loadTerrainSettings(); } function Core_Rendering::onDestroy(%this) diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui index 72801178d..47c3549a2 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui @@ -61,13 +61,44 @@ }; new GuiControl() { - position = "20 80"; + position = "20 70"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Global Blend Depth:"; + profile = "ToolsGuiTextProfile"; + tooltipProfile = "ToolsGuiToolTipProfile"; + tooltip = "Controls the general level of bleding across all textures, has no effect if Lerp Blend is enabled."; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiSliderCtrl() { + internalName = "blendDepthSlider"; + profile = "ToolsGuiSliderProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + altCommand = "TerrainTextureSettingsDlg.updateBlendDepth();"; + + position = "130 0"; + extent = "170 20"; + + range = "0.01 1.0"; + }; + }; + + new GuiControl() { + position = "20 100"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; new GuiTextCtrl() { text = "Detail Texture Size:"; profile = "ToolsGuiTextProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; position = "0 0"; extent = "120 20"; @@ -85,7 +116,7 @@ }; new GuiControl() { - position = "20 110"; + position = "20 130"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -109,7 +140,7 @@ }; new GuiControl() { - position = "20 140"; + position = "20 160"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -133,7 +164,7 @@ }; new GuiControl() { - position = "20 170"; + position = "20 190"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -157,7 +188,7 @@ }; new GuiControl() { - position = "20 200"; + position = "20 220"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -181,7 +212,7 @@ }; new GuiControl() { - position = "20 230"; + position = "20 250"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -205,7 +236,7 @@ }; new GuiControl() { - position = "20 260"; + position = "20 280"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -227,7 +258,7 @@ }; new GuiControl() { - position = "20 290"; + position = "20 310"; profile = "ToolsGuiDefaultProfile"; extent = "300 20"; @@ -258,9 +289,9 @@ profile = "ToolsGuiButtonProfile"; position = "0 0"; - extent = "145 30"; - command = "TerrainTextureSettingsDlg.applyAndSave();"; + + extent = "145 30"; }; new GuiButtonCtrl() { diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs index 59b72e82b..7f21583fb 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs @@ -31,12 +31,12 @@ $TerrainTextureSettingsDlg::TerrainTextureFormat = function TerrainTextureSettingsDlg::show( %this ) { - //%this.onWake(); Canvas.pushDialog( %this ); } function TerrainTextureSettingsDlg::onWake( %this ) { %this-->lerpBlendCheckBox.setStateOn(ProjectSettings.value("Terrain/LerpBlend")); + %this-->blendDepthSlider.setValue(ProjectSettings.value("Terrain/BlendDepth")); %this-->detailTextureFormatPopUpMenu.clear(); %this-->macroTextureFormatPopUpMenu.clear(); @@ -63,8 +63,13 @@ function TerrainTextureSettingsDlg::onWake( %this ) { %this-->ormTextureSizeTextEdit.setText(ProjectSettings.value("Terrain/OrmTextureSize")); } +function TerrainTextureSettingsDlg::updateBlendDepth( %this ) { + $Terrain::BlendDepth = %this-->blendDepthSlider.getValue(); +} + function TerrainTextureSettingsDlg::apply( %this ) { $Terrain::LerpBlend = %this-->lerpBlendCheckBox.isStateOn(); + $Terrain::BlendDepth = %this-->blendDepthSlider.getValue(); $Terrain::DetailTextureFormat = %this-->detailTextureFormatPopUpMenu.getSelected(); $Terrain::MacroTextureFormat = %this-->macroTextureFormatPopUpMenu.getSelected(); @@ -112,6 +117,7 @@ function TerrainTextureSettingsDlg::validate( %this ) { function TerrainTextureSettingsDlg::cancel( %this ) { $Terrain::LerpBlend = ProjectSettings.value("Terrain/LerpBlend"); + $Terrain::BlendDepth = ProjectSettings.value("Terrain/BlendDepth"); $Terrain::DetailTextureFormat = ProjectSettings.value("Terrain/DetailTextureFormat"); $Terrain::MacroTextureFormat = ProjectSettings.value("Terrain/MacroTextureFormat"); @@ -134,6 +140,7 @@ function TerrainTextureSettingsDlg::applyAndSave( %this ) { %this.apply(); ProjectSettings.setValue("Terrain/LerpBlend", $Terrain::LerpBlend); + ProjectSettings.setValue("Terrain/BlendDepth", $Terrain::BlendDepth); ProjectSettings.setValue("Terrain/DetailTextureFormat", $Terrain::DetailTextureFormat); ProjectSettings.setValue("Terrain/MacroTextureFormat", $Terrain::MacroTextureFormat);