From 3379021b7d96c77c47bef9be34a5a4c69bb01bde Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 11 Apr 2021 12:49:06 +0200 Subject: [PATCH] #5585: Preliminary exposure of IShaderLayer::MapType in the Material scope --- install/scripts/materialtest.py | 1 + .../interfaces/ShaderSystemInterface.cpp | 14 +++++++++++ .../script/interfaces/ShaderSystemInterface.h | 23 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/install/scripts/materialtest.py b/install/scripts/materialtest.py index 0d9e100e1a..37ba453a90 100644 --- a/install/scripts/materialtest.py +++ b/install/scripts/materialtest.py @@ -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) diff --git a/plugins/script/interfaces/ShaderSystemInterface.cpp b/plugins/script/interfaces/ShaderSystemInterface.cpp index fdf8705a51..6746e14bde 100644 --- a/plugins/script/interfaces/ShaderSystemInterface.cpp +++ b/plugins/script/interfaces/ShaderSystemInterface.cpp @@ -208,6 +208,16 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa .value("TRANSLUCENT", Material::MC_TRANSLUCENT) .export_values(); + py::enum_(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()); material.def("getName", &ScriptMaterial::getName); material.def("getShaderFileName", &ScriptMaterial::getShaderFileName); @@ -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 diff --git a/plugins/script/interfaces/ShaderSystemInterface.h b/plugins/script/interfaces/ShaderSystemInterface.h index 1b45c11487..ad653b4cc1 100644 --- a/plugins/script/interfaces/ShaderSystemInterface.h +++ b/plugins/script/interfaces/ShaderSystemInterface.h @@ -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() {