unexpected behaviour with noisy interpolation - can anyone confirm?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

unexpected behaviour with noisy interpolation - can anyone confirm?

Post by ggoblin »

Hi, I'm experiencing some strange behaviour using noisy keyframe interpolation in a script. I am finding that when I set the noisy interpolation scale parameter to values other than 1 then they get changed in the UI. The smaller the value I set the larger the value appears in the UI.

I created a test script. Can anyone confirm the behaviour I'm experiencing with this test script? Is it a UI bug?

The test script is a tool script GG_NoistTest.lua but sorry it doesn't have an icon.

Code: Select all


-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "GG_NoisyTest"

-- **************************************************
-- General information about this script
-- **************************************************

GG_NoisyTest = {}


function GG_NoisyTest:Name()
	return "GG_NoisyTest"
end

function GG_NoisyTest:Version()
	return "1.0"
end

function GG_NoisyTest:Description()
	return "GG_NoisyTest"
end

function GG_NoisyTest:Creator()
	return "GGoblin"
end

function GG_NoisyTest:UILabel()
	return "GG_NoisyTest"
end




-- **************************************************
-- The guts of this script
-- **************************************************


function GG_NoisyTest:Run(moho)
	
	local veclayer = moho:CreateNewLayer( MOHO.LT_VECTOR)   -- create vector layer
	local mesh = moho:Mesh()
	
	-- draw square
	local v = LM.Vector2:new_local()
	
	v.x = -0.2
	v.y = 0.2
	mesh:AddLonePoint(v, 0)

	v.x = -0.2
	v.y = 0.2
	mesh:AppendPoint(v, 0)

	v.x = 0.2
	v.y = 0.2
	mesh:AppendPoint(v, 0)

	v.x = 0.2
	v.y = -0.2
	mesh:AppendPoint(v, 0)

	v.x = -0.2
	v.y = -0.2
	mesh:AppendPoint(v, 0)

	mesh:WeldPoints(firstpoint, mesh:CountPoints() - 1, 0)
	
	mesh:Point(0):SetCurvature(0,0)
	mesh:Point(1):SetCurvature(0,0)
	mesh:Point(2):SetCurvature(0,0)
	mesh:Point(3):SetCurvature(0,0)

	mesh:SelectConnected()	
	
	local shapeid = moho:CreateShape(true,false,0)	
	local shape = mesh:Shape(shapeid)
	



	-- move square with different noisy interpolation scale values
	local pos = LM.Vector3:new_local()
	pos.x = -1
	pos.y = 0
	pos.z = 0
	
	veclayer.fTranslation:SetValue(0,pos)
	veclayer.fTranslation:SetKeyInterp(0,MOHO.INTERP_NOISY,0.30,0.25)
	
	pos.x = -0.5
	veclayer.fTranslation:SetValue(24,pos)
	veclayer.fTranslation:SetKeyInterp(24,MOHO.INTERP_NOISY,0.30,0.5)
	
	pos.x = 0
	veclayer.fTranslation:SetValue(48,pos)
	veclayer.fTranslation:SetKeyInterp(48,MOHO.INTERP_NOISY,0.30,0.75)

	pos.x = 0.5
	veclayer.fTranslation:SetValue(72,pos)
	veclayer.fTranslation:SetKeyInterp(72,MOHO.INTERP_NOISY,0.30,1)

	pos.x = 1
	veclayer.fTranslation:SetValue(96,pos)
	veclayer.fTranslation:SetKeyInterp(96,MOHO.INTERP_NOISY,0.30,1.25)
	
	
end



The script just creates a square and then it uses layer fTranslation to move it across the screen horizontally with keyframes every second with Noisy interpolation with different scale parameters at each keyframe:

frame 0 x=-1 noisy scale = 0.25 -> scale in UI: 4
frame 24 x=-0.5 noisy scale= 0.5 -> scale in UI: 2
frame 48 x=0 noisy scale= 0.75 -> scale in UI: 1.333
frame 72 x=0.5 noisy scale= 1 -> scale in UI: 1
frame 96 x=1 noisy scale= 1.25 -> scale in UI: 0.8

Image

Interestingly when we visually look at the noisy path generated its scale seems to be increasing as per my scale in the script. Is it just the UI reading that is screwed up?

Any insight would be appreciated. Thank you.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by ggoblin »

The relationship between what I set in the script and what appears in the UI is :

UI scale = 1/ script scale

Maybe just a simple bug in the UI code?
User avatar
synthsin75
Posts: 10005
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by synthsin75 »

Like it implies here: https://mohoscripting.com/classes/InterpSetting
There may be a limited range of legit values.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by ggoblin »

synthsin75 wrote: Tue Jul 19, 2022 2:45 am Like it implies here: https://mohoscripting.com/classes/InterpSetting
There may be a limited range of legit values.
Thanks Wes, for the quick reply.

I saw that, but some of the values it suggests are 'good' are the ones that are getting corrupted:

Image

In the above example

0.5 gets corrupted to 2

And I am pretty sure any 'good' value you pick will follow the formula and be displayed corrupted. The only value that does not get corrupted is 1 , as by the formula 1/1 = 1.

I think the noisy scale is the frequency of the noise? Is that correct?

I don't think its a serious problem though, as when I called GetKeyInterp to show me what the noise scale value it has stored, it returned the correct uncorrupted value suggesting that this is just a display bug.
User avatar
hayasidist
Posts: 3551
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by hayasidist »

FWIW there are many instances where what you see on the screen is not what is stored in the .moho (and is not what will be supplied via the API) -- particularly when it comes to angles which are displayed in degrees and stored in radians. (IIRC, another example is camera zoom.) So the fact that Scale is stored as 1/x is not, as such, unusual - and it will probably be this way because that's the computationally effective way to use the number.

http://www.lostmarble.com/forum/viewtopic.php?p=193342 explains Noisy (and frequency = 1/period)
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by ggoblin »

hayasidist wrote: Tue Jul 19, 2022 7:26 am FWIW there are many instances where what you see on the screen is not what is stored in the .moho (and is not what will be supplied via the API) -- particularly when it comes to angles which are displayed in degrees and stored in radians. (IIRC, another example is camera zoom.) So the fact that Scale is stored as 1/x is not, as such, unusual - and it will probably be this way because that's the computationally effective way to use the number.

http://www.lostmarble.com/forum/viewtopic.php?p=193342 explains Noisy (and frequency = 1/period)
Radians and degrees are understood standard units, using 'scale' to represent 'frequency' is an arbitrary unit, it should be properly documented. This is all very confusing, the documentation says a good value is 0.5, if I give it that 'good' value 0.5 in my script the UI says its actually 2. If in the UI I give it value 0.5, the API will tell my script its actually 2.. :roll:
User avatar
hayasidist
Posts: 3551
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by hayasidist »

ggoblin wrote: Tue Jul 19, 2022 2:34 pm ... using 'scale' to represent 'frequency' ... should be properly documented. This is all very confusing ...
I've updated mohoscripting. (I don't have edit rights to the manual.)
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: unexpected behaviour with noisy interpolation - can anyone confirm?

Post by ggoblin »

Thats great Hayasidist, I'll check it out.
Post Reply