Missing Lua API bindings for Layer Shading "Inverted" and "Threshold"?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
tiendat414
Posts: 3
Joined: Mon Dec 12, 2022 5:04 am

Missing Lua API bindings for Layer Shading "Inverted" and "Threshold"?

Post by tiendat414 »

Hi everyone,

I'm currently developing a custom Lua script for Moho 14 to automate my shading workflow. My goal is to create a pure, one-click tool that instantly applies specific Layer Shading settings to multiple selected layers without needing to interact with the UI dialogs.

I have successfully accessed and synced most of the Layer Shading properties using the existing API:

fLayerShadingOn

fShadingOffset

fShadingBlur

fShadingContraction

fShadingAngle

fShadingColor

However, I've hit a major roadblock: I cannot find any API methods or properties to toggle the "Inverted" and "Threshold" checkboxes via script.

Here is what I have tried so far:

Brute-forcing property names: I tried setting various logical names using pcall (e.g., fShadingInvert, fShadingInverted, fThreshold, ShadingThreshold, etc.), but none of them worked.

Are these two features simply not exposed to the Lua API yet?

Thanks in advance for any insights!
User avatar
synthsin75
Posts: 10472
Joined: Mon Jan 14, 2008 2:20 pm
Location: Oklahoma
Contact:

Re: Missing Lua API bindings for Layer Shading "Inverted" and "Threshold"?

Post by synthsin75 »

I don't remember what these do:
fShadingNoiseAmp
fShadingNoiseScale

From: https://mohoscripting.com/classes/mohol ... properties
tiendat414
Posts: 3
Joined: Mon Dec 12, 2022 5:04 am

Re: Missing Lua API bindings for Layer Shading "Inverted" and "Threshold"?

Post by tiendat414 »

synthsin75 wrote: Fri May 15, 2026 11:33 pm I don't remember what these do:
fShadingNoiseAmp
fShadingNoiseScale

From: https://mohoscripting.com/classes/mohol ... properties
I also don't know what these two parameters are for. Are they included in these two parameters?
User avatar
hayasidist
Posts: 3995
Joined: Wed Feb 16, 2011 11:12 am
Location: Kent, England

Re: Missing Lua API bindings for Layer Shading "Inverted" and "Threshold"?

Post by hayasidist »

"inverted" means changing the sign of the fOffset value (an AnimVal channel) -- so for example if you have animated layer effects on and you start with an offset of (say) 50 pixels then click the "invert" checkbox at (say) frame 20 - what will happen is that the offset interpolates between 50 and -50 over that 20 frame interval and (assuming a gradual interp mode - i.e. not step) at some point (e.g. frame 10) the offset will pass though zero and that's when the "invert" checkbox will show.
[NOTE: the value in the file, and thus the value that needs to be set by the script, is NOT in pixels - it's converted to moho units - so (depending on your project resolution etc) you might need to set values of, say, 0.05]

However, the shading threshold channel (an AnimBool) does, indeed, not seem to be accessible through the API.

And, curiously, the fShadingNoiseAmp and fShadingNoiseScale that Wes mentioned don't seem to be in the UI for shading (there are other noise settings for the layer) (but are in the API??) and the moho file has them as Value, not AnimVal, in the Layer Shading section???

I've logged an enhancement request.
tiendat414
Posts: 3
Joined: Mon Dec 12, 2022 5:04 am

Re: Missing Lua API bindings for Layer Shading "Inverted" and "Threshold"?

Post by tiendat414 »

hayasidist wrote: Sat May 16, 2026 1:57 am "inverted" means changing the sign of the fOffset value (an AnimVal channel) -- so for example if you have animated layer effects on and you start with an offset of (say) 50 pixels then click the "invert" checkbox at (say) frame 20 - what will happen is that the offset interpolates between 50 and -50 over that 20 frame interval and (assuming a gradual interp mode - i.e. not step) at some point (e.g. frame 10) the offset will pass though zero and that's when the "invert" checkbox will show.
[NOTE: the value in the file, and thus the value that needs to be set by the script, is NOT in pixels - it's converted to moho units - so (depending on your project resolution etc) you might need to set values of, say, 0.05]

However, the shading threshold channel (an AnimBool) does, indeed, not seem to be accessible through the API.

And, curiously, the fShadingNoiseAmp and fShadingNoiseScale that Wes mentioned don't seem to be in the UI for shading (there are other noise settings for the layer) (but are in the API??) and the moho file has them as Value, not AnimVal, in the Layer Shading section???

I've logged an enhancement request.
I also hope the moho team will soon fix the missing APIs. Honestly, moho software has been great for me; ever since I discovered the scripting feature, it's felt like I've created my own workspace. I feel very sorry that from moho version 13.5 onwards, 3D model support isn't as good as in moho 13. Because sometimes it would be great if moho really supported 3D models well; I think my projects, or others' projects, would have so many more solutions and ways to create animations with moho. Thank you for the explanation.
Post Reply