[Closed] interpolation experiments
Hello,
after reading [1] and [2] I slowly started to think about interpolation.
I’d like to hear some comment from you about this approach:
The following script creates a bezier_float in the globaltracks and uses it as some kind of Lookup Table. An dummy holds global scale and offsets to post-process the LUT.
As a sampe a row of spheres is created, whose radii are controlled by the LUT.
You can adjust the curve in the Trackview to modify the size of the spheres.
The global controlls can be used to offset an scale this curve.
-- interpolation fragment
-- 2007 Georg Duemlein
-- http://www.preset.de/
-- create a bezierfloat and add it to globaltracks:
bc = bezier_float()
defaultKeys = #(#(0,.5),#(100,3))
addTrackViewController Globaltracks bc "sampleLUT"
for i = 1 to defaultKeys.count do (
k = addNewKey bc (defaultKeys[i][1])
at time defaultKeys[i][1] animate on k.value = defaultKeys[i][2]
k.inTangentType = #custom
k.inTangent = 0
k.outTangentType = #custom
k.outTangent = 0
)
-- set out-of-range-keys
setBeforeORT bc #cycle
setAfterORT bc #cycle
-- create a dummy to hold offset and scale slider
dm = dummy()
em = emptymodifier()
the_cadef = attributes sampleValues (
parameters main rollout:params (
thego type:#float ui:uigo default:0
thegs type:#float ui:uigs default:1
)
rollout params "Globals" (
spinner uigo "Offset" range:[-100, 100, 0] type:#float
spinner uigs "Scale" range:[0.1, 10, 1] type:#float
)
)
custAttributes.add em the_cadef
addmodifier dm em
em.sampleValues.thego.controller = bezier_float()
em.sampleValues.thegs.controller = bezier_float()
dm.name = "sample_global"
-- create some spheres and controll their radius through the LUT
spaceing = 3
for sc = 1 to 50 do (
s = sphere pos:[(spaceing * (sc - 1)), 0, 0] radius:1
scont = float_script()
--scont.addTarget "ref" globalTracks.sampleLUT
scont.addConstant "me" (sc * 2)
scont.addTarget "go" $sample_global.modifiers[#Attribute_Holder].sampleValues.thego.controller
scont.addTarget "gs" $sample_global.modifiers[#Attribute_Holder].sampleValues.thegs.controller
scont.addConstant "ref" globalTracks.sampleLUT
scont.script = "rt = (me + go) * gs
at time rt ref.value"
s.radius.controller = scont
s.wirecolor = [255, 255, 255] * (at time (sc * 2) globalTracks.sampleLUT.value)/3
)
-- open trackview
trackview.open "rdg sample"
Georg
[1] http://forums.cgsociety.org/showthread.php?f=98&t=470089
[2] http://forums.cgsociety.org/showthread.php?f=98&t=475669&highlight=ease
Here is a max9 sample scene.
Start the playback and adjust the sampleLUT to change the shapes.
Georg
Nice man, I love interpolation math. I tend to use fourier_transforms or sigmoid interpolation (slow in/slow out), remember the math of a bezier curve, can be used for anything, not just actually curves. For instance you could have 4 values as floats/integers: #(0,0,1,1) this is basically slow in slow out. If you had #(0,.3,1,1) thats fast out to slow, #(0,.3,.6,1) – uniform etc etc. Curves are very very powerful because all you feeding it is (t) time, and 4 variables. Most of my functions (well there getting there) use pure data as inputs and generally a variable [0,1] inclusive if needed.
Thats all a bezier curve is, it uses 2 vectors and 2 tangents of nth degree 3: (k-1) and combines a binormial coeficiant – so a random variable based on factorial of [n,i] which is for i = 0 to n (being nth degree). Essentially this means your working in 3 segments to derive your curve. If you made n:4 then 4 segments, n-5 5 segments. But the problem is the great the n-degree over a series of point the greater the generalisation i.e you lose detail and control of the curve. So this is why piece-wise curves where invented, firstly to prove as de-casteja found out that you could make a b-spline curve from a series of smaller curves glued together using mid-point method. And then by de-boor with the (3rds rule), basically deriving a subset of vectors from a set of global vectors to build a seried of curves from.
Then Nurbs came along, which added a variable of weight into the math, all this did was to multiply the value of each polynormial, divided by the polynormial itself i.e as to normalise the curve. Now to glue multiple versions of these you need to work with both a global weight, and a local weight – i find this math hard. Nurbs are essential first rational-bezier curves, and ontop of this non-uniformity. A cubic curve is uniform.
So in the end, if nth order over generalization thats the key to control of a curve. I.e the amount of segment the curve works in and how these segements themselves are generated.
The f-curve which is a TCB curve, uses koch-bartel polynormials which are just a generalized form of hermite curves, but with multipliers t -tension, c – continuity and b – bias. They were designed specifically for animators funnily enough.
Nice man
thanks, eek.
Curves are very very powerful because all you feeding it is (t) time, and 4 variables.
yeah, see my port of easing euquotations here.
The intention for this approach was:
If we want to go beyond simple fades it becomes very hard to do all this fourier-what-ever-curve-sketching to get the math. Especially if you are an animator/artist.
I thought if we could use the build in tools of max to get a lookup system that can be used to interpolate/transform values/data such task would be much easier.
You can even draw you interpolation spline and max does the calc part for us.
I haven’t tested this yet, but if we use an xyz_list controller we can preadd/multiply/dived different curves/interpolations …
You should add your post to the wiki, I you haven’t already.
Georg
Nice work Georg, I have look at doing LUT tables just not get around to it. I need to do some speed tests to see where is gets me as well. I’ll have a poke around your set up.
Thanks PEN!
I attached an updated version that uses a float_list with bezier and noise float.
Using the weights we can interpolate between interpolation types
That speed thing … I don’t know about real world usage of this stuff …
I tried 500 spheres and it is responding quite nice.
Georg