Skip to content

Commit

Permalink
#5532: Add parsing code for TDM's lightFalloffCubeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 19, 2021
1 parent 94c326c commit 006bab2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion include/ishaders.h
Expand Up @@ -321,9 +321,12 @@ class Material

virtual TexturePtr lightFalloffImage() = 0;

// The expression of the lightFalloffMap
// Return the expression of the light falloff texture for use with this shader.
virtual shaders::IMapExpression::Ptr getLightFalloffExpression() = 0;

// Return the expression of the light falloff cubemap for use with this shader.
virtual shaders::IMapExpression::Ptr getLightFalloffCubeMapExpression() = 0;

// greebo: Returns the description as defined in the material
virtual std::string getDescription() const = 0;

Expand Down
2 changes: 1 addition & 1 deletion install/ui/materialeditor.fbp
Expand Up @@ -4307,7 +4307,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_textCtrl511</property>
<property name="name">MaterialLightFalloffCubeMap</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand Down
2 changes: 1 addition & 1 deletion install/ui/materialeditor.xrc
Expand Up @@ -688,7 +688,7 @@
<option>0</option>
<flag>wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND</flag>
<border>0</border>
<object class="wxTextCtrl" name="m_textCtrl511">
<object class="wxTextCtrl" name="MaterialLightFalloffCubeMap">
<value></value>
</object>
</object>
Expand Down
3 changes: 3 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -362,6 +362,9 @@ void MaterialEditor::updateMaterialPropertiesFromMaterial()
auto lightFalloffMap = _material->getLightFalloffExpression();
getControl<wxTextCtrl>("MaterialLightFalloffMap")->SetValue(lightFalloffMap ? lightFalloffMap->getExpressionString() : "");

auto lightFalloffCubeMap = _material->getLightFalloffCubeMapExpression();
getControl<wxTextCtrl>("MaterialLightFalloffCubeMap")->SetValue(lightFalloffCubeMap ? lightFalloffCubeMap->getExpressionString() : "");

// Surround the definition with curly braces, these are not included
auto definition = fmt::format("{0}\n{{{1}}}", _material->getName(), _material->getDefinition());
_sourceView->SetValue(definition);
Expand Down
6 changes: 5 additions & 1 deletion radiantcore/shaders/CShader.cpp
Expand Up @@ -64,12 +64,16 @@ bool CShader::isEditorImageNoTex()
return (getEditorImage() == GetTextureManager().getShaderNotFound());
}

// Return the falloff texture name
IMapExpression::Ptr CShader::getLightFalloffExpression()
{
return _template->getLightFalloff();
}

IMapExpression::Ptr CShader::getLightFalloffCubeMapExpression()
{
return _template->getLightFalloffCubeMap();
}

/*
* Return the light falloff texture (Z dimension).
*/
Expand Down
7 changes: 2 additions & 5 deletions radiantcore/shaders/CShader.h
Expand Up @@ -53,13 +53,10 @@ class CShader
// Return the light falloff texture (Z dimension).
TexturePtr lightFalloffImage();

/**
* Return the name of the light falloff texture for use with this shader.
* Shaders which do not define their own falloff will take the default from
* the defaultPointLight shader.
*/
IMapExpression::Ptr getLightFalloffExpression() override;

IMapExpression::Ptr getLightFalloffCubeMapExpression() override;

/*
* Return name of shader.
*/
Expand Down
4 changes: 4 additions & 0 deletions radiantcore/shaders/ShaderTemplate.cpp
Expand Up @@ -375,6 +375,10 @@ bool ShaderTemplate::parseLightKeywords(parser::DefTokeniser& tokeniser, const s
else if (!fogLight && token == "lightfalloffimage")
{
_lightFalloff = MapExpression::createForToken(tokeniser);
}
else if (token == "lightfalloffcubemap")
{
_lightFalloffCubeMap = MapExpression::createForToken(tokeniser);
}
else if (token == "spectrum")
{
Expand Down
7 changes: 7 additions & 0 deletions radiantcore/shaders/ShaderTemplate.h
Expand Up @@ -44,6 +44,7 @@ class ShaderTemplate

// Map expressions
shaders::MapExpressionPtr _lightFalloff;
shaders::MapExpressionPtr _lightFalloffCubeMap;

/* Light type booleans */
bool fogLight;
Expand Down Expand Up @@ -266,6 +267,12 @@ class ShaderTemplate
if (!_parsed) parseDefinition();
return _lightFalloff;
}

const MapExpressionPtr& getLightFalloffCubeMap()
{
if (!_parsed) parseDefinition();
return _lightFalloffCubeMap;
}

// Add a specific layer to this template
void addLayer(ShaderLayer::Type type, const MapExpressionPtr& mapExpr);
Expand Down

0 comments on commit 006bab2

Please sign in to comment.