Hi, I'm trying to set a vector layers noise settings from script.
These are the settings you would use layer settings -> vector panel in the UI to set:
to produce this effect:
I found most of the settings in the Mesh Layer properties, with a few caveats :
1. fNoiseAmp and fNoiseInterval appear to be in moho units in the script whilst they are in pixels in UI, so unless you want to see wildly jumping lines you need to divide the values by 1080 (on a 1080p canvas) before using them in the script. (This should be documented in the API guide - it actually has no documentation on these fields other than their name and type)
2. In the UI there is a 'Line Count' box, in the script there is fExtraLines , so obviously fExtraLines has to be set to one less than Line Count.
But the problem I'm having is setting the Noise Interval - by default its 1 frame, too fast for me, I need it at 3 frames. But I can't find the field in the Moho API documentation. I did come across a script in Mohoscripting.com which refers to fNoiseInterval in a comment. I tried setting it but it was ignored.
I cannot believe the API would leave out one of the key parameters to setting layer noise whilst including all the others, but I can't find it. Any help would be much appreciated. Thank you.
Vector layer Noise Settings
Moderators: Víctor Paredes, Belgarath, slowtiger
- hayasidist
- Posts: 3564
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Vector layer Noise Settings
oh the joys of being a pioneer! all those "nuggets" to discover.
Formal request for access to "interval" has been lodged. I also can't see a workaround short of hacking the .mohoproj ...
as for the other observations - I'll aim to get an update to mohoscritping done "soon"!
Formal request for access to "interval" has been lodged. I also can't see a workaround short of hacking the .mohoproj ...
as for the other observations - I'll aim to get an update to mohoscritping done "soon"!
- hayasidist
- Posts: 3564
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Vector layer Noise Settings
Updates to mohoscripting done.
and
Found this http://lostmarble.com/forum/viewtopic.php?p=137698 from nearly a decade ago! Might be useful!
Re: Vector layer Noise Settings
Ah, I forgot about that thread.hayasidist wrote: ↑Sun Jul 24, 2022 6:43 pmUpdates to mohoscripting done.
and
Found this http://lostmarble.com/forum/viewtopic.php?p=137698 from nearly a decade ago! Might be useful!
I'll share the scripts we ended up creating and using for a Dutch TV-Show called Buitenspelen / Outside, here's a link to an epsisode about: penguins and gnomes
No idea if these still work in the latest Moho, but maybe they're useful to you as a starting point. I haven't checked them out or tested them. If I recall correctly, the first one turns on a jiggle vector effect for all(?) layers, the second one too but with more extreme values, the third one turned it off (we needed it to be turned off while animating).
We called it the Schaaik-effect because that was the directors name and he established the style before we got on board. It was a fun project.
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "LK_Schaaikeffect"
-- **************************************************
-- General information about this script
-- **************************************************
LK_Schaaikeffect = {}
function LK_Schaaikeffect:Name()
return "Het Schaaik effect standaard"
end
function LK_Schaaikeffect:Version()
return "0.1"
end
function LK_Schaaikeffect:Description()
return ("Schaaik-effect standaard")
end
function LK_Schaaikeffect:Creator()
return "Lukas"
end
function LK_Schaaikeffect:UILabel()
return("Schaaik-effect standaard")
end
-- **************************************************
-- The guts of this script
-- **************************************************
function LK_Schaaikeffect:Run(moho)
moho.document:PrepMultiUndo()
moho.document:SetDirty()
for j = 0, moho.document:CountLayers()-1 do
local layer = moho.document:Layer(j)
self:ConvertLayer(moho, layer)
end
LM.GUI.Alert(LM.GUI.ALERT_INFO, "Alle lagen zijn klaar om buiten te spelen!")
end
function LK_Schaaikeffect:ConvertLayer(moho, layer)
if (layer:LayerType() == MOHO.LT_VECTOR) then
local vectorLayer = moho:LayerAsVector(layer)
vectorLayer.fNoisyLines = true
vectorLayer.fNoisyShapes = true
vectorLayer.fAnimatedNoise = true
vectorLayer.fExtraSketchy = false
vectorLayer.fExtraLines = 0
vectorLayer.fNoiseAmp = 6.0 / moho.document:Height()
vectorLayer.fNoiseScale = 48.0 / moho.document:Height()
local mesh = vectorLayer:Mesh()
for k = 0, mesh:CountShapes() -1 do
local shape = mesh:Shape(k)
shape:MakePlain()
local brush = LM.String:new_local("Brush001.png")
shape.fMyStyle:SetSoftEdge(18.0 / moho.document:Height())
shape.fMyStyle.fBrushName = brush
end
elseif layer:IsGroupType() then
local groupLayer = moho:LayerAsGroup(layer)
for i = 0, groupLayer:CountLayers()-1 do
local subLayer = groupLayer:Layer(i)
self:ConvertLayer(moho, subLayer)
end
end
end
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "LK_Schaaikeffect_More"
-- **************************************************
-- General information about this script
-- **************************************************
LK_Schaaikeffect_More = {}
LK_Schaaikeffect_More.BASE_STR = 2480
function LK_Schaaikeffect_More:Name()
return "Het Schaaik effect"
end
function LK_Schaaikeffect_More:Version()
return "0.1"
end
function LK_Schaaikeffect_More:Description()
return ("Schaaik-effect plus")
end
function LK_Schaaikeffect_More:Creator()
return "Lukas"
end
function LK_Schaaikeffect_More:UILabel()
return("Schaaik-effect plus")
end
-- **************************************************
-- The guts of this script
-- **************************************************
function LK_Schaaikeffect_More:Run(moho)
moho.document:PrepMultiUndo()
moho.document:SetDirty()
for j = 0, moho.document:CountLayers()-1 do
local layer = moho.document:Layer(j)
self:ConvertLayer(moho, layer)
end
LM.GUI.Alert(LM.GUI.ALERT_INFO, "Alle lagen zijn klaar om buiten te spelen!")
end
function LK_Schaaikeffect_More:ConvertLayer(moho, layer)
if (layer:LayerType() == MOHO.LT_VECTOR) then
local vectorLayer = moho:LayerAsVector(layer)
vectorLayer.fNoisyLines = true
vectorLayer.fNoisyShapes = true
vectorLayer.fAnimatedNoise = true
vectorLayer.fExtraSketchy = false
vectorLayer.fExtraLines = 0
vectorLayer.fNoiseAmp = 12.0 / moho.document:Height()
vectorLayer.fNoiseScale = 70.0 / moho.document:Height()
local mesh = vectorLayer:Mesh()
for k = 0, mesh:CountShapes() -1 do
local shape = mesh:Shape(k)
shape:MakePlain()
local brush = LM.String:new_local("Brush001.png")
shape.fMyStyle:SetSoftEdge(18.0 / moho.document:Height())
shape.fMyStyle.fBrushName = brush
end
elseif layer:IsGroupType() then
local groupLayer = moho:LayerAsGroup(layer)
for i = 0, groupLayer:CountLayers()-1 do
local subLayer = groupLayer:Layer(i)
self:ConvertLayer(moho, subLayer)
end
end
end
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "LK_Schaaikeffect_Off"
-- **************************************************
-- General information about this script
-- **************************************************
LK_Schaaikeffect_Off = {}
LK_Schaaikeffect_Off.BASE_STR = 2480
function LK_Schaaikeffect_Off:Name()
return "Het Schaaik effect"
end
function LK_Schaaikeffect_Off:Version()
return "0.1"
end
function LK_Schaaikeffect_Off:Description()
return ("Zet Schaaik-effect uit")
end
function LK_Schaaikeffect_Off:Creator()
return "Lukas"
end
function LK_Schaaikeffect_Off:UILabel()
return ("Zet het Schaaikeffect uit")
end
-- **************************************************
-- The guts of this script
-- **************************************************
function LK_Schaaikeffect_Off:Run(moho)
moho.document:PrepMultiUndo()
moho.document:SetDirty()
for j = 0, moho.document:CountLayers()-1 do
local layer = moho.document:Layer(j)
self:ConvertLayer(moho, layer)
end
LM.GUI.Alert(LM.GUI.ALERT_INFO, "Alle lagen zijn weer binnen televisie aan het kijken als een stel zombies!")
end
function LK_Schaaikeffect_Off:ConvertLayer(moho, layer)
if (layer:LayerType() == MOHO.LT_VECTOR) then
local vectorLayer = moho:LayerAsVector(layer)
vectorLayer.fNoisyLines = false
vectorLayer.fNoisyShapes = false
vectorLayer.fAnimatedNoise = false
vectorLayer.fExtraSketchy = false
vectorLayer.fExtraLines = 0
vectorLayer.fNoiseAmp = 0 / moho.document:Height()
vectorLayer.fNoiseScale = 0 / moho.document:Height()
--[[
local mesh = vectorLayer:Mesh()
for k = 0, mesh:CountShapes() -1 do
local shape = mesh:Shape(k)
shape:MakePlain()
end
]]
elseif layer:IsGroupType() then
local groupLayer = moho:LayerAsGroup(layer)
for i = 0, groupLayer:CountLayers()-1 do
local subLayer = groupLayer:Layer(i)
self:ConvertLayer(moho, subLayer)
end
end
end
Re: Vector layer Noise Settings
Thank you Hayasidist for updating mohoscripting.hayasidist wrote: ↑Sun Jul 24, 2022 6:43 pmUpdates to mohoscripting done.
and
Found this http://lostmarble.com/forum/viewtopic.php?p=137698 from nearly a decade ago! Might be useful!
The forum link you shared seems to be kinda identical to what I discovered.. only it over 12 years old! If it was pointed out 12 years ago and still hasn't been fixed then I don't see much chance of it ever being fixed.
Re: Vector layer Noise Settings
Thank you Lukas for sharing.Lukas wrote: ↑Mon Jul 25, 2022 9:45 am
I'll share the scripts we ended up creating and using for a Dutch TV-Show called Buitenspelen / Outside, here's a link to an epsisode about: penguins and gnomes
No idea if these still work in the latest Moho, but maybe they're useful to you as a starting point. I haven't checked them out or tested them. If I recall correctly, the first one turns on a jiggle vector effect for all(?) layers, the second one too but with more extreme values, the third one turned it off (we needed it to be turned off while animating).
The Dutch TV_Show is kinda unique in that its a Moho animated feature which is NOT character focused and yet won a Dutch Academy Award. It shows the potential Moho had back then when it was truly an all in one 2d animation solution, before it just started focusing on character animation. A pity for such a lost opportunity.
I see the scripts could not fix the missing fNoiseInterval API and ended up compromised, 12 years later its still not fixed. Such a shame that Moho owners have apparently failed to see the potential in using Moho for 2d non-character animation, and hence have let it fall behind so badly.