Skip to content

Commit

Permalink
#5585: Preliminary exposure of IShaderLayer::MapType in the Material …
Browse files Browse the repository at this point in the history
…scope
  • Loading branch information
codereader committed Apr 11, 2021
1 parent 50653db commit 3379021
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions install/scripts/materialtest.py
Expand Up @@ -50,6 +50,7 @@
print('DecalInfo.startColour: {0}'.format(newMaterial.getDecalInfo().startColour))
print('DecalInfo.endColour: {0}'.format(newMaterial.getDecalInfo().endColour))
print('Coverage: {0}'.format(newMaterial.getCoverage()))
print('Light Falloff Map Type: {0}'.format(newMaterial.getLightFalloffCubeMapType()))

# There are a couple of pre-defined sort requests, corresponding to the engine code
newMaterial.setSortRequest(dr.Material.SortRequest.NEAREST)
Expand Down
14 changes: 14 additions & 0 deletions plugins/script/interfaces/ShaderSystemInterface.cpp
Expand Up @@ -208,6 +208,16 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa
.value("TRANSLUCENT", Material::MC_TRANSLUCENT)
.export_values();

py::enum_<IShaderLayer::MapType>(material, "MapType")
.value("Map", IShaderLayer::MapType::Map)
.value("CubeMap", IShaderLayer::MapType::CubeMap)
.value("CameraCubeMap", IShaderLayer::MapType::CameraCubeMap)
.value("VideoMap", IShaderLayer::MapType::VideoMap)
.value("SoundMap", IShaderLayer::MapType::SoundMap)
.value("MirrorRenderMap", IShaderLayer::MapType::MirrorRenderMap)
.value("RemoteRenderMap", IShaderLayer::MapType::RemoteRenderMap)
.export_values();

material.def(py::init<const MaterialPtr&>());
material.def("getName", &ScriptMaterial::getName);
material.def("getShaderFileName", &ScriptMaterial::getShaderFileName);
Expand Down Expand Up @@ -252,6 +262,10 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa
material.def("setSpectrum", &ScriptMaterial::setSpectrum);
material.def("getDecalInfo", &ScriptMaterial::getDecalInfo);
material.def("getCoverage", &ScriptMaterial::getCoverage);
material.def("getLightFalloffExpressionString", &ScriptMaterial::getLightFalloffExpressionString);
material.def("setLightFalloffExpressionFromString", &ScriptMaterial::setLightFalloffExpressionFromString);
material.def("getLightFalloffCubeMapType", &ScriptMaterial::getLightFalloffCubeMapType);
material.def("setLightFalloffCubeMapType", &ScriptMaterial::setLightFalloffCubeMapType);

// Expose the MaterialVisitor interface

Expand Down
23 changes: 23 additions & 0 deletions plugins/script/interfaces/ShaderSystemInterface.h
Expand Up @@ -251,6 +251,29 @@ class ScriptMaterial
return _material ? _material->getCoverage() : Material::MC_UNDETERMINED;
}

std::string getLightFalloffExpressionString()
{
return _material && _material->getLightFalloffExpression() ?
_material->getLightFalloffExpression()->getExpressionString() : std::string();
}

void setLightFalloffExpressionFromString(const std::string& expressionString)
{
throwIfMaterialCannotBeModified();
if (_material) _material->setLightFalloffExpressionFromString(expressionString);
}

IShaderLayer::MapType getLightFalloffCubeMapType()
{
return _material ? _material->getLightFalloffCubeMapType() : IShaderLayer::MapType::Map;
}

void setLightFalloffCubeMapType(IShaderLayer::MapType type)
{
throwIfMaterialCannotBeModified();
if (_material) _material->setLightFalloffCubeMapType(type);
}

private:
void throwIfMaterialCannotBeModified()
{
Expand Down

0 comments on commit 3379021

Please sign in to comment.