Sign in to follow this  

How to use a heightmap for particle motion?

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, basically like the title say I am looking reference material to understand how to use a heightmap for particle motion in 2D. So I can draw a noise background, throw a bunch of particles, and the particles will move to the white areas, so as the noise background change the particles will move accordingly. Any reference material, links tutorials, will be much appreciated Cheers rS

Share this post


Link to post
Share on other sites
Hi, basically I need to work out the following algorithm.

// INI

1->Generate Perlin in black and white

2->Generate text, place in center

3->Imagine the whiteness to be a height value. Darker == lower, ligher == higher.

4->Convert the bitmap into a slope / normal map. Follow this process :
1.Convolution with a 3x3 kernel, y-1 and y+1 as 1,div by 2 bias 127, copy to red channel
2.Convolution with a 3x3 kernel x-1 and x+1 as 1, div by 2, bias 127, copy to blue channel

Now red and blue are converted into slope values for every pixel. Use this slope value to accelerate or decelerate your particles.

Use a linked list with small datatypes for your particles. Read out from the slope map to move them, add some elastics...et voila.

A position on your normal / slope map has a color. This color encodes x in red and y in green. If you read the green value, you divide it's value by 128 and -1 one that value.

That will give you a value between -1 and +1. Depending on the speed you want to add to the particles, you multiply that value and add it to the velocity of the particle. Same goes for the red channel.

// END

Now 1, 2, and 3 are dead easy, but I am having problems working out how to build step 4, any advice will be great

Thanks
rS

[Edited by - nardove on March 2, 2010 10:51:37 AM]

Share this post


Link to post
Share on other sites

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this