Oldschool effects

Started by
3 comments, last by Samith 10 years, 5 months ago

Here is some nice old school effect of plasma.

Does someone knows any other good tutorial for old school effect ?

Advertisement

Anyway why the author in the mentioned tutorial is using PI when he is calculating color on per component basis rgb ?

I think it has to do something with continuity of a vector rgb but I don't know how PI makes it again continuous.

He's using Pi because the vector v has a range from [-4, 4] (because v is basically 4 sins added together) and he wants to map it to [-4*pi, 4*pi] before passing it into the sin/cos funcs. He needs the range of inputs to those final sin/cos funcs to be multiples of pi so that there aren't discontinuities at the edge of the range.

I'm sorry I didn't quite understand. Why the multiples of pi will make sure that there are no discontinuities at the edge of range ?

Also why does he wants it in [-4*pi, 4*pi], isn't it good enough to be in [-4, 4] ? At the end he is putting them in sin/cos so the result will be in [-1, 1].

A few things: I just looked at his code again and I noticed he divides v by two, so the range of v is actually [-2,2].

For your first question: look at it this way. What does sin(4pi) equal? Zero. How about sin(-4pi)? Also zero. But what about sin(4) and sin(-4)? sin(4) roughly equals -0.75, and sin(-4) is roughly 0.75. So sin(4) != sin(-4). This is the same for 2 (sin(2pi) == sin(-2pi) and sin(2) != sin(2)). If two neighboring pixels have values of v = 4 and v = -4, then the sin of their values won't be equal unless you multiply v by pi. Looking at his glsl code again, it's hard to evaluate whether this is really an important property or not. It looks like (at least for the fullscreen quad case) values of v will probably be continuous.

The other important part of multiplying v by pi, though, is that you more evenly use the range of sin. [0, 2] after sin has a range of [0, 0.9], and [-2, 0] has a range of [-0.9, 0]. So your total range is only [-0.9, 0.9]! Some values will never get used. But, if you multiply by pi, then your range is the full [-1, 1]. And this is true for any value of v. If instead of dividing by 2, he had divided by 100, pi*v would still result in a range of [-1, 1] (though not multiplying by pi would only offer a range of [-0.04, 0.04]).

This topic is closed to new replies.

Advertisement