diff options
author | Bottinator22 <59987380+Bottinator22@users.noreply.github.com> | 2024-12-28 20:07:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-28 20:07:34 -0800 |
commit | f7dc97965dd245a1d9272bdb48d1f16dc0b82233 (patch) | |
tree | 9b0fac69a617325458438e6868fb98a49f0dba7e /source/client/StarRenderingLuaBindings.cpp | |
parent | 1a0bf768f071d26a04ac20c5f0eb43056b14cc8f (diff) |
Update StarRenderingLuaBindings.cpp
Diffstat (limited to 'source/client/StarRenderingLuaBindings.cpp')
-rw-r--r-- | source/client/StarRenderingLuaBindings.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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<void, String, bool, Maybe<bool>>("setPostProcessGroupEnabled", bind(mem_fn(&ClientApplication::setPostProcessGroupEnabled), app, _1, _2, _3)); callbacks.registerCallbackWithSignature<bool, String>("postProcessGroupEnabled", bind(mem_fn(&ClientApplication::postProcessGroupEnabled), app, _1)); + // not entirely necessary (root.assetJson can achieve the same purpose) but may as well callbacks.registerCallbackWithSignature<Json>("postProcessGroups", bind(mem_fn(&ClientApplication::postProcessGroups), app)); + + // typedef Variant<float, int, Vec2F, Vec3F, Vec4F, bool> 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<float>()) { + renderer->setEffectScriptableParameter(effectName, effectParameter, (int)value.get<float>()); + } 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; } |