diff --git a/include/ShaderLayer.h b/include/ShaderLayer.h index 9a0a69f9f7..f0071e3f71 100644 --- a/include/ShaderLayer.h +++ b/include/ShaderLayer.h @@ -217,6 +217,9 @@ class ShaderLayer */ virtual Vector2 getShear() = 0; + // Returns true if this layer has an alphatest expression defined + virtual bool hasAlphaTest() const = 0; + /** * \brief * Get the alpha test value for this layer. diff --git a/install/ui/materialeditor.fbp b/install/ui/materialeditor.fbp index 23fdb56012..c98bb8ea1c 100644 --- a/install/ui/materialeditor.fbp +++ b/install/ui/materialeditor.fbp @@ -10669,11 +10669,11 @@ - + 0 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -10687,6 +10687,7 @@ 1 0 + 0 1 1 @@ -10702,7 +10703,6 @@ 0 wxID_ANY Alphatest: - 0 0 @@ -10710,7 +10710,7 @@ 0 1 - m_staticText11 + MaterialStageHasAlphaTest 1 @@ -10721,13 +10721,16 @@ 1 - + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - -1 @@ -10746,11 +10749,11 @@ none 0 0 - + 0 - wxRIGHT|wxALIGN_CENTER_VERTICAL + wxALL 0 - + 1 1 1 @@ -10768,6 +10771,7 @@ 1 0 + 1 Dock 0 Left @@ -10778,7 +10782,8 @@ 0 0 wxID_ANY - 1 + 0.1 + 0 1 0 @@ -10788,7 +10793,7 @@ 0 1 - MaterialEditorStageFadeInFrac + MaterialStageAlphaTestValue 1 @@ -10797,9 +10802,9 @@ Resizable 1 - 70,-1 + wxSP_ARROW_KEYS - + ; ; forward_declare 0 diff --git a/install/ui/materialeditor.xrc b/install/ui/materialeditor.xrc index 7bf7bd69d3..d9b5ce8cfc 100644 --- a/install/ui/materialeditor.xrc +++ b/install/ui/materialeditor.xrc @@ -1807,9 +1807,9 @@ wxALIGN_CENTER_VERTICAL 0 - + - -1 + 0 @@ -1825,14 +1825,15 @@ - wxRIGHT|wxALIGN_CENTER_VERTICAL + wxALL 0 - + - 70,-1 - 1 + 0 0 1 + 0.1 + 1 diff --git a/radiant/ui/materials/MaterialEditor.cpp b/radiant/ui/materials/MaterialEditor.cpp index 3151de89e0..2ce679a92c 100644 --- a/radiant/ui/materials/MaterialEditor.cpp +++ b/radiant/ui/materials/MaterialEditor.cpp @@ -340,6 +340,12 @@ void MaterialEditor::setupMaterialStageProperties() setupStageFlag("MaterialStageFlagMaskAlpha", ShaderLayer::FLAG_MASK_ALPHA); setupStageFlag("MaterialStageFlagMaskColour", ShaderLayer::FLAG_MASK_RED|ShaderLayer::FLAG_MASK_GREEN|ShaderLayer::FLAG_MASK_BLUE); setupStageFlag("MaterialStageFlagMaskDepth", ShaderLayer::FLAG_MASK_DEPTH); + + _stageBindings.emplace(std::make_shared>(getControl("MaterialStageHasAlphaTest"), + [=](const ShaderLayerPtr& layer) + { + return layer->hasAlphaTest(); + })); } void MaterialEditor::_onTreeViewSelectionChanged(wxDataViewEvent& ev) @@ -654,7 +660,12 @@ void MaterialEditor::updateStageControlsFromSelectedStage() getControl("MaterialEditorStageSettingsPanel")->Enable(selectedStage != nullptr); + if (selectedStage) + { + selectedStage->evaluateExpressions(0); // initialise the values of this stage + getControl("MaterialStageAlphaTestValue")->SetValue(selectedStage->getAlphaTest()); + } } } diff --git a/radiantcore/shaders/Doom3ShaderLayer.cpp b/radiantcore/shaders/Doom3ShaderLayer.cpp index ac9d28a5cc..2adcc6ad20 100644 --- a/radiantcore/shaders/Doom3ShaderLayer.cpp +++ b/radiantcore/shaders/Doom3ShaderLayer.cpp @@ -215,6 +215,11 @@ ShaderLayer::CubeMapMode Doom3ShaderLayer::getCubeMapMode() const return _cubeMapMode; } +bool Doom3ShaderLayer::hasAlphaTest() const +{ + return _alphaTest != REG_ZERO; +} + float Doom3ShaderLayer::getAlphaTest() const { return _registers[_alphaTest]; diff --git a/radiantcore/shaders/Doom3ShaderLayer.h b/radiantcore/shaders/Doom3ShaderLayer.h index c3d4f11a61..eba2240976 100644 --- a/radiantcore/shaders/Doom3ShaderLayer.h +++ b/radiantcore/shaders/Doom3ShaderLayer.h @@ -123,7 +123,9 @@ class Doom3ShaderLayer Colour4 getColour() const; VertexColourMode getVertexColourMode() const; CubeMapMode getCubeMapMode() const; - float getAlphaTest() const; + + bool hasAlphaTest() const override; + float getAlphaTest() const override; // True if the condition for this stage is fulfilled // (expressions must have been evaluated before this call)