Scripted smoke idea - may need math help

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Scripted smoke idea - may need math help

Post by heyvern »

So I was playing around with the motion blur and some shapes moving around. I noticed that just by accident the resulting image looked like some really cool smoke.

The problem of course is that this can't be animated... yet. The points are moved around over a long number of frames (1000), the motion blur frame count is set to 1000 (length of the animation), beginning and end is 100%, frame skip is 1 with no blur. The image below, is a single stroked vector with a wiggly moving curve profile so it I could get more complexity without having to animate a ton of points. It is moved around sort of randomly over time. The shape opacity is 5. I kept the movement smaller at one end and more extreme at the other end to simulate the motion of smoke.

My theory on how to animate this:
So, the motion blur that creates the smoke effect requires ALL the frames, from frame 1 to frame 1000. There is no way to animate this because the motion is included in each frame. They all look the same, same position, but build to the end over time.

The trick I need to make this work is to be able to script movement of bones controlling the points of the "smoke" to create a mathematical wave function on "previous" frames on each frame, to create a "new" still image that moves in a "smoky" way.

So... phew... on each frame, I want to change the translation (or rotation. I prefer translation) of multiple bones ONLY on frame 1, in a mathematically calculated way to simulate a wave function. I don't want to use rotation because that changes the length of the smoke too much... but of course I can live with rotation if it's easier.

By moving the bones a set amount on frame 1 ONLY, each frame moving forward is a NEW image with a different position for the smoke path. So the frame number would be used to increment the bone movement to create a smooth animation on frame 1. Basically what I am trying to do is create an animation on 1 frame. The value to make this happen can be pulled from the frame number as the project renders.

The bad news... holy crapola batman.... this thing will take a VERY long time to render. I think the effect could be worth it. I could probably get it down lower using some blur and fewer frames. The trade off... with no blur it renders much faster. With blur it requires fewer frames but blur adds time to the render... it's a trade off.

Help needed:

Basically some advice or links to some math formulas for creating "wave" motion. I am going to poke around on my own but I suck at math and it will be trial and error.

Image
videodv
Posts: 69
Joined: Tue Feb 08, 2011 10:17 am

Re: Scripted smoke idea - may need math help

Post by videodv »

Have a look at this link it may help

http://en.wikipedia.org/wiki/Wave

Regards
Chris.
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Re: Scripted smoke idea - may need math help

Post by Rudiger »

Sounds like you want the a variant of the "Travelling Wave Equation":

Code: Select all

x = A.y.sin(b/(y+c.t+d))
where: 
    t = time (frame/frame_rate),
    y = y-coord of bone,
    x = x-coord of bone,
    A = amplitude coefficient,
    b = wavelength coefficient,
    c = velocity coefficient,
    d = min period constant
Note that period and amplitude both increase with y-coord, which I'm guessing is what you want.

It would probably look a lot better if you added a fair bit of vector noise on top of the wave movement though.

It might also be interesting to make the x-coord relative instead of absolute, so you create a sort of path with the bones and they oscillate about their base point.
Post Reply