diff --git a/source/client/StarRenderingLuaBindings.cpp b/source/client/StarRenderingLuaBindings.cpp index 4c9e7a2..39dc1a1 100644 --- a/source/client/StarRenderingLuaBindings.cpp +++ b/source/client/StarRenderingLuaBindings.cpp @@ -1,6 +1,8 @@ #include "StarRenderingLuaBindings.hpp" +#include "StarJsonExtra.hpp" #include "StarLuaConverters.hpp" #include "StarClientApplication.hpp" +#include "StarRenderer.hpp" namespace Star { @@ -11,8 +13,30 @@ LuaCallbacks LuaBindings::makeRenderingCallbacks(ClientApplication* app) { callbacks.registerCallbackWithSignature>("setPostProcessGroupEnabled", bind(mem_fn(&ClientApplication::setPostProcessGroupEnabled), app, _1, _2, _3)); callbacks.registerCallbackWithSignature("postProcessGroupEnabled", bind(mem_fn(&ClientApplication::postProcessGroupEnabled), app, _1)); + // not entirely necessary (root.assetJson can achieve the same purpose) but may as well callbacks.registerCallbackWithSignature("postProcessGroups", bind(mem_fn(&ClientApplication::postProcessGroups), app)); + + // typedef Variant RenderEffectParameter; + // feel free to change this if there's a better way to do this + // specifically checks if the effect parameter is an int since Lua prefers converting the values to floats + callbacks.registerCallback("setEffectParameter", [app](String const& effectName, String const& effectParameter, RenderEffectParameter const& value) { + auto renderer = app->renderer(); + auto mtype = renderer->getEffectScriptableParameterType(effectName, effectParameter); + if (mtype) { + auto type = mtype.value(); + if (type == 1 && value.is()) { + renderer->setEffectScriptableParameter(effectName, effectParameter, (int)value.get()); + } else { + renderer->setEffectScriptableParameter(effectName, effectParameter, value); + } + } + }); + + callbacks.registerCallback("getEffectParameter", [app](String const& effectName, String const& effectParameter) { + auto renderer = app->renderer(); + return renderer->getEffectScriptableParameter(effectName, effectParameter); + }); return callbacks; }