Resampling and Interpolation

Hi all,

I’ve recently started exploring Touchdesigner as someone from a VVVV background.

Right now, I’m trying to resample a pattern chop so that the hard edges in my pattern are preserved, but the number of samples are increased proportionally along it’s length. Using both the Resample and Stretch chops, I can increase the number of samples and use linear interpolation for something that’s almost right, but because of how linear interpolation works the edge points are blended and no longer follow the lines in the original pattern shape exactly.

I’ve looked around and there doesn’t seem to be an inbuilt interpolation method that preserves edges in the way I’m after. I’ve managed to bodge something that almost works by converting the chop to a sop, then using the resample sop with “resample by polgyon edge” turned on and converting back to chop data, but for some reason I lose 3 samples while doing this. The resampling behaviour I want works, but the pattern no longer matches the length of other patterns I want to merge it with, and this is creating problems.

Is there any way I can achieve what I need solely with chops?

Can you post a simplified example of where you are working with CHOPs and your current work around approach? I have an idea of what you’re after, but I don’t want to make any assumptions.

I’ve attached a simplified version of the patch I’m experimenting with. I’ve kept in the main functionality since it might help make it clear what I’m trying to do, and commented the important parts explaining what I’m stuck on.

The broader functionality I’m trying to achieve with this experiment is a ‘transformation hierarchy’ behaviour within a control array for instanced geometry. In this case I’ve made a short infinite tunnel loop, and I’d like to be able to control the rotation of each XY shape slice in the tunnel array without affecting the local rotation of individual geometry instances. In VVVV something like this is pretty straightforward, you just connect a transform node to another transform node and it treats your group of points as a single object to be transformed, while still letting you target individual points using the next transform node down in the heirarchy. I haven’t been able to find any information on how people might approach this kind of thing in touch unfortunately, so I’ve been experimenting to see if I can work something out myself.

(I’m also happy to make a separate thread if it’d be better to do that to discuss transformation hierarchies specifically)
resampling interpolation simplified.1.toe (11.8 KB)

both chops are identical now,
strech1 end parameter =
op(‘globalVariables’)[‘zIterations’] * op(‘globalVariables’)[‘circlePoints’] * op(‘globalVariables’)[‘subPoints’] - op(‘globalVariables’)[‘zIterations’] * op(‘globalVariables’)[‘circlePoints’] - (op(‘globalVariables’)[‘subPoints’]-1)
resampling interpolation simplified.2.toe (11.8 KB)

I think I came up against a similar problem in the post on the FB group.

My solution was to time slice the CHOP so every sample point was it’s own channel, and then use a resample chop. This produced the correct interpolation. Then I used a shuffle chop to sequence all the channels back into a single channel, and it worked as expected.

I hope this helps, apologies if I’ve got the wrong end of the stick.

Nick

The situation described in the FB group is a little different I think. My goal isn’t abc to aaabbbccc so much as linear interpolation that doesn’t round hard corners in the original shape wave. More like abc to a.1-a.2-a.3-b.1-b.2-b.3-c.1-c.2-c.3.

Regarding the fact that deleting a chunk of the end samples (equivalent to one side segment) makes the interpolation respect the shape edges properly, does anyone have an explanation of what’s going on here? Chop resampling now respects the corners properly, but unfortunately it has the same problem as my original workaround: There are slightly too few samples (2045 instead of 2048 in this case) and the mismatch throws the loop out of alignment.

I’m thinking maybe there’s a way to split every line segment using the shuffle chop, resample them to a higher point count, then reassemble back together in a way that preserves the corners properly and also has the correct number of samples. I haven’t quite been able to nut out how to do it yet unfortunately, since I’d need to interpolate between samples 1-2, then 2-3, then 3-4, etc. I’m not sure how to go about that, and it seems like it could be a slightly convoluted solution anyway.

looks ok now:
resampling interpolation simplified.3.toe (13.4 KB)