16 October 2010

Noise

So I really need to let you in on a little tip. This is something that I found so amazingly helpful. So you made your sim. You're emitting particles or fluids or whatever; and it looks pretty good. But it's missing something. It just looks a little off or fake. It doesn't feel quite organic. Well, let me tell you about something that will help you solve that problem.

Do a little research, you'll see that everything moves. This might sound self-evident, but it's also important. I'll use fluids as an example, since I've been applying the technique most with them. Say your making a fire. (Yeah, I talk about fire a lot, I like fire; deal with it.) And you've got some nice turbulence and swirl and emission and all that good stuff, but there's something wrong with just playing with the sliders, finding something you like, and simulating. The sliders don't change. Think about it. In nature, fire burns from fuel, which is converted into heat. But the heat being converted is never constant. And the fuel being used up is never constant. It's always changing. Your fluid needs to replicate this behavior.

Enter expressions: These guys are life savers. Now you could keyframe all your attributes, but what you want is randomness, and managing keyframes is sooo incredibly tedious. So I'll teach you a little expression that will save you tons of time. This isn't a make awesome button, it's just a little tweaking that adds character to your already good sim. If you didn't guess from the title: Noise. This function is awesome. Think of it like a sin wave, but with randomness built into it. It's basically like mapping a noise texture to your attribute and animating it over time. The expression works like this:

fluidShape1.attr = currentValue + amountScalar * noise(time * frequencyScalar)

Now this formula might not make sense. Hopefully, you've taking some math classes in college. Really, this is just preCalc level stuff so don't be too scared. Anyway it works like this: Noise generates a wave-like curve. Time tells us where to look on the noise function. The frequencyScalar is a float value that compresses the noise function. Or in layman's terms: makes it go faster. The amountScalar tells you how much you want the noise to effect your attribute. A value of zero means it will do nothing. A value of 1 means it will change your attribute by a range of -1 to 1. The currentValue is the value you want your attribute to be centered on. Here's a diagram of the noise function (or more accurately a sin function but it works the same way):

So here's what it might look like on an attribute:
fluidEmitterShape.heatEmission = 2 + 0.3 * noise(time*10);
So I want my temperature to emit at about 2 and vary by 0.3. So my values for temperature emission will be between 1.7 and 2.3. The noise function will change based on time given in seconds. So at 12 frames, time = 0.5. And time is then multiplied by 10 to speed it up.

So I hope I've explained this well enough. So now you have a new mel function to call and how and where you can use it.

No comments:

Post a Comment