# Gradient from a height map

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

## Recommended Posts

I'm working on an Ecosystem Game, specifically I'm modelling erosion and river formation at the moment. I have a heightmap that is determined and modified by the player. I need to determine a gradient from the heightmap to find the direction and strength of erosion and water flow. Basically I need a direction and a magnitude, ie: a vector.
A--B--C
|  |  |
D--E--F
|  |  |
G--H--I


From the above diagram, I'm trying to find the gradient vector at point E using the other points heights' as my only input. I'd like to weight A C G and I differently since they're further away. It's been a while since Calc 3, how do I do this?

##### Share on other sites
Something like the Sobel operator can be applied to your height-map to generate a gradient-map. I don't believe it's extremely accurate, but it's simple enough to implement. Check out edge detection for some more information and operators.

##### Share on other sites
Yes, that's pretty much what I'm after.

What are the units that the gradient is expressed in from the Sobel operator?

For instance, this grid:

0-5-100-5-100-5-10

is going to produce a Gx of 40 isn't it? Should I then divide this by 4 to get the actual gradient along x or what?

1. 1
Rutin
19
2. 2
3. 3
JoeJ
16
4. 4
5. 5

• 27
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001789
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!