Public Group

# How to use a heightmap for particle motion?

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

## 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 on other sites
Just move the particle to the brightest neighbor of its current pixel...

Or are you looking for something different?

##### 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 on other sites

is it the sobel operator the kernel need to use?

Cheers
rS

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 16
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632928
• Total Posts
3009265
• ### Who's Online (See full list)

There are no registered users currently online

×