springs back to original position

my understanding of the spring sop was that it would “pull the points back toward their original positions”. However I can’t seem to get the points to go anywhere near their original positions after being moved by a force. I’ve changed all the parameters, small and large values, but nothing seems to do it.
for instance, if I have a grid of points, after they are moved by a force, I would like them to eventually go back to a grid.
I must be missing something.

thanks
simplespring.toe (6.02 KB)

In the Sprint SOP State / Reset Pulse or on/off

thanks anodin, but I don’t want to reset the simulation. I know how to do that very well now from trying out so many different settings on the spring sop :frowning: . what I do want is for the grid to be the points’ rest state, and for the points to settle back into their rest state after being disturbed by a force.

It’s a slightly different approach, but you might look at the blend SOP. Here you can provide different inputs with point locations and then blend between those sets - this would give you the ability to return to a true reset / resting state. A few different noise variations and some clever logic around blending would also create the illusion of unique return paths every time the process is started.

I often use SOPtoCHOP and Lag to smooth the return to point rest positions. Of course if you need to have a SOP in the end you would have to convert back with CHOPtoSOP, probably using the pre-Spring source geometry as reference input, etc.

I covered this briefly near the end of my particle tutorial (when I go back to the halloween example):
twitch.tv/cutmod/v/98697099 around 1:20:00

You can also use the blend CHOP to avoid some of the trickery around the lag and filter CHOPs.

You can find an example here:

[url]https://github.com/raganmd/td_fb_forum_examples/blob/master/example_explorer/tox_files/container_blend_chop_spring_reset.tox[/url]

thank you both for your suggestions. both suggestions are edifying (i have a lot to learn in TD), but missing the springiness I was looking for.
While trying to understand the spring sop, i looked at some Houdini examples. one used a lattice, which after some thrashing around, i was able to get working in TD. Although not perfect, it is closer to what i was hoping to achieve. perhaps i won’t have to do this in openframeworks after all. i still have plenty of questions about the spring and lattice sops, but i’m close. perhaps the spring sop page should have a link to the lattice sop for people who are actually looking for the “pull the points back toward their original positions” and oscillating behavior mentioned on the spring sop page, since the spring sop doesn’t seem to do it. I’ve attached my file below. suggestions always welcome.

i learned plenty from your video cutmod, and am still working through all of your examples raganmd. you are making understanding TD much easier.
springAndLattice.toe (8.06 KB)

Ahhhh.

This makes it much easier to understand what you’re after.

Some of the tricky things in TouchDesigner are how different operators function on a given machine. SOPs are all calculated on the CPU, which is wonderful but often means that you can be bottlenecked in terms of performance by using them.

The metaball2 costs about 15ms, the force2 costs close to 17, the spring runs around 6-8ms.

Take a look here to get see some other thoughts about how to approach these kinds of problems:
[url]https://matthewragan.com/2015/07/21/touchdesigner-email-shrink-instance/[/url]

Here’s a modification of that tox file with some feedback used to mimic the spring behavior you’re talking about… at least, I think it’s close to what you’re after:
dynamicInstancingShrink.tox (249 KB)

Make sure to look in the base called “displacement_with_slow_return” to see an example running at 60fps for 1450 instances

thanks Matt. I had been looking at that project as a possible alternate approach. your new version is definitely along the lines of where i’m trying to go. now i have to sit down and figure out what you are doing in there. of course, i’m not trying to work with so many instances but i do want more “forces”. definitely stretching my td knowledge of td.

i altered matt’s example to use a video input. to get the directions from the video, i used a normal map. it could still use some improvement, but it works.

dynamicInstancingShrinkVideo.toe (254 KB)

pretty glad i stumbled upon this. i had a client ask for an interactive particle system, where particles get pushed away with your hand, and i spent a fun few days creating a stylish looking system, and afterwards they corrected themselves and requested that they want a static amount of particles that drifted back to their original position (instead of being birthed back like with the Particle SOP). So i spent some time creating an elaborate/muddled system of a few Spring SOPs and Blending them, and resetting them stealthily, so I could apply my Metaball Force to a fresh Spring SOP while the previous one got reset so it too can be fresh during it’s next time being used, and well… it just wasn’t pretty.

Is there already a feature request for an easing function for the reset option of Spring SOP? I love the inherent dynamics of the particle system, but the reset pulse is super ugly, and Magnet/Lattice SOPs don’t quite get you there. Even with how amazing and quite straighforward Matthew’s solution is, it’d take some math and number crunching to get the look and feel of the Forcefield system.

@Matt: Is there anything you’d change about your “displacement_with_slow_return” system? Now that you seem more involved with writing out GLSL, would you instead lean more on that? If i’m going to use a Kinect to do hand tracking, do you suggest those hand coordinates and scale just control that yellow+pink ball you already created?

Thanks for the example, it’s easy to branch out from and create something nice. Cheers!

hey @why.

There are a few things I’d do differently now I think. Looking back This example is all the more interesting as I can see my past self fighting against learning some gl directly… while still using some gl principles.

The place I’d start now would be to take a close look at the new opticalFlow comp in the palette. That’s another way of encoding movement / change as pixels, and you can use that do all sorts of other interesting things like introducing displacement. Vincent posted a cool example in 3D but the same ideas will still work in 2D (instagram.com/p/BVSaPBonvKN/?hl=en).

I’d probably also skip some of the more esoteric CHOP math that I’m doing here for scaling and displacement of instances. Instead I’d skip instances and use point sprites instead displaced by a vertex shader, all of the displacement math could be written directly into a GLSL material rather than a series of CHOPs. Displacement would happen at the vertex stage and shouldn’t be to terrible to sort out. You could sample directly from the texture that comes out of the optical flow processes (and whatever post process you add), and you could add in another GLSL TOP to encode the scaling operation in the alpha channel. That way all of your displacement would be encoded as a single texture in rgba.

If you needed to put a unique texture on each instance you could use a point SOP to add a custom attribute for index to your verts, and then use that to retrieve a texture from a 2D array. That’s not an insignificant rewrite - but if you’re comfortable with GL it should be mostly straightforward.

If that’s not in your wheelhouse (and it wasn’t in mine for a long time), I’d stick with this kind of approach. You could drive the location of that ball with tracking info from your kinect - you should just think though how you’re going to calibrate those values so they make sense in screen space.

Hope that helps and let us know if you get stuck!

I took your advice with looking into optical flow and it is pretty great, and Vincent just posted his own here: [url]Optical Flow - Shared .tox Components - TouchDesigner forum (the difference between the glsl code he used vs. the one used in Derivative’s official opticalFlow isn’t very visible, however Derivative helped expose some of the parameters for easy tinkering). Although in the end i still might go with Kinect and having hands control the pink+yellow balls, because the end result is a little less chaotic than optical flow.

Anyways, here’s my displacement example using Optical Flow, mashed up from Vincent’s example in the above link. I stuck with instances because that’s what he had, and actually didn’t change too much, kept most of his methods, while incorporating yours for x/y displacement (math addition :stuck_out_tongue: ). He was using a Math Chop for getting the length between R + G which would control the scale, so i’m not sure how to use your Alpha method because alpha is a constant 1 for every pixel. Maybe use black instead?

edit: [previous non-scaling issue has been solved, got my Lag values backwards :confused: ]

Let me know if i messed up anything in here. it still doesn’t seem right…
flowTicles.toe (10.2 KB)

You might play with some feedback that’s floating point - don’t have too much time to dig in now, but this might have legs.

New ops are magenta, removed your lag CHOP.
flowTicles.3.toe (10.3 KB)

once you run it through Blur and Feedback it loses all the negative values for some reason. [check out the attachments] making the data unusable(?). I guess you could have two videos come out of the optical flow shader in parallel and one of them invert those R+G pixel values and then run that through it’s own blur/feedback as well. I’m also not sure why optical flow couldn’t use the blue and alpha channels for directional data, instead of doubling up on red and greed.


normal_no_blur_feedback.png

It’s just the composite type that’s giving you that result - if you experiment with different operation types you’ll get negative vals.

ah ya, true, Add Negate or Screen all will give good results.

edit: blurs + feedback + lag gives some really nice flowy results

having a bit of fun with this now. here’s an example with rotation. i’m imagining one of those split flap displays you see at train station. would be awesome to attach each instance to a sound, so as it rotated, it clapped. wave something in front of your camera, you’ll see them flip

@matt how do you make sure the scene’s light is hitting the instances correctly? i had to create two Lights to kinda fake the effect, but you can notice some flittering in between rotations. is this a normals issue, and if so, is it possible to rotate normals per instance so that they always point towards the light?
flipTicles.toe (12.8 KB)

@why can you say a little more about what you’re seeing?

I changed around the use of lighting here and replaced your grid with a box SOP - which I think is essentially the same thing you were doing. This looks right to me, but I might be missing something.
flipTicles.light.toe (12.3 KB)

you’re not missing anything, you nailed it. looking at your example made me realize the way i was building my cube, that was the issue, the normals were wrong from the beginning. Box SOP with Cube Map texture coordinates was the perfect solution. Thanks for all the help, i’ll try to keep it updated here with any big progress or videos i make.

Cheers!