# Gradient from a height map

This topic is 4109 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?

##### Share on other sites

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