October 04, 2007
Hydra: Noise

I mentioned the Hydra limitations before - especially if you aim for the use of your filters in Flash there are a lot of them. One feature that is entirely missing for example is a random number generator in form of a rnd() function. This wouldn't be such a bad thing, if there were at least some binary operators available. Since with the help of a little bitshifting, xor and bitmasking you can build your own random number generator pretty easily - here is a typical C# example:

function Noise(int x, int y)
{
int n = x + y * 57;
n = (n<<13) ^ n;

return ( 1.0 - ( (n * (n * n * r1 + r2) + r3) & 0x7fffffff) / 1073741824.0);
}

Well, it looks like we don't have that in Hydra (yet). Still there is an alternative. By using some nested sine functions with very high frequencies we can get something that looks pretty much like noise:

I admit that this doesn't look too exciting, but I think that there are quite a few things that can be created based on that. So here's the source: sineNoise.hydra

Posted at October 04, 2007 01:42 PM | Further reading
Comments

Just use parameters. Filters should always produce predictable results. You can provide random parameter at higher level. In ex. PerlinNoise::randomSeed parameter.

Posted by: maliboo on October 4, 2007 02:43 PM

But how do you want to provide a random number for every single pixel? And BTW this function actually will produce a predictable result since it is purely mathematical.

Posted by: Mario Klingemann on October 4, 2007 02:53 PM

The problem is, that it is supposed to be performed on the GPU. But there is no standard in bit-based operations in the GPU industry. Non of the major shader languages, such as GLSL or HLSL support bitwise operations.
It's really sad. It would give sooo many more opportunities.

Posted by: sam7 on October 18, 2007 08:18 AM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Site Search

Google
quasimondo.com
incubator.quasimondo.com
lectures.quasimondo.com
Most Visited Entries
Experiments
Lectures
Contact
Backlog
In Love with
Powered by