This is a simple as I can make to show the difference between the My method and the L3dt method..
The Blue line is the path that L3DT would take.
The Red Line is the path mine would take.
Terry
Let me see if I get Nickadimos's algorithm right:
1.- Find the highest, lowest and mid points
2.- Let one highpoint be the actual pixel
3.- Starting from an actual pixel, test the 8 non-used adjacent pixels looking for the lower color (or altitude) that is the closest to the starting center point. (Not the lowest one, but the color closest one, in other words look for the minimun nonnegative difference between the center and the 8 neighbors)
4.- Mark this neighbor "used" and make it the actual one.
5.- Repeat from 3 until we reach one nonmarked midpoint pixel, or we get out of the map. Mark this midpoint
6.- Do the same, but in reverse order from a lowpoint until we reach a midpoint
Is that correct?
If so, I'm not getting the expected results... Look at the pic...
If your able to run this through then it would be great. I was expecting to have to write something to show what it might do later this evening so if you have the framework available that would save me some time. Are you able to show whats happening with zoomed up tiles so that the black line doesn't obscure the height map underneath. If not, are you able to show the height map before the line was drawn too so that we could clip out that section and follow it through ? What we need to do is pin down either why its not working or why what your doing is different to what we think we need to do to follow the algorithm.
I agree with Wordman in that water would flow to lowest point and thats what most people have done but we also know that it tends to stall quickly by hitting locally low points with higher pixel values all around it. You can avoid this by accumulating water in that ditch, filling it up until it overflows and that's what Aaron of L3DT has called a continuum model instead of the drip model. This is the kind of model I think he has programmed and not released because its a lot slower as it means you have to iterate a lot before it starts to overflow. It is the basis of how I do it in GTS however which is why it takes hours for my app to run.
Heres a link to Aarons posts on L3DT, its a bit old tho - maybe he has done more work in this area.
http://www.bundysoft.com/phpBB2/viewtopic.php?t=404
The original heightmap (without black lines) is attached in the first message of the thread...
Here is the code I'm using:
actualX and actualY are the starting point coordinates. W is the width and h is the height or the image. Sealevel is... well... guess what!
Code:actual = (GetPixel(picMap.hdc, actualX, actualY) And &HFF) Do used = False modX = 0 modY = 0 dif = 255 min = 255 For i = -1 To 1 For j = -1 To 1 used = ((GetPixel(picMap.hdc, actualX + i, actualY + j) And &HFF) = 0) If actualX + i > 0 And actualY + j > 0 And actualX + i < w And actualY + j < h And Not used Then testValue = (GetPixel(picMap.hdc, actualX + i, actualY + j) And &HFF) dif = actual - testValue If dif >= 0 And dif <= min Then If i = 0 And j = 0 Then Else min = dif modX = i modY = j End If End If End If Next Next actualX = actualX + modX actualY = actualY + modY actual = (GetPixel(picMap.hdc, actualX, actualY) And &HFF) Call SetPixel(picMap.hdc, actualX, actualY, 0) picMap.Refresh Loop Until (modX = 0 And modY = 0) Or (actual < seaLevel) Or actualX < 0 Or actualY < 0 Or actualX > w Or actualY > h
Last edited by covatex; 11-24-2008 at 04:12 PM.
Sorry didnt spot that. I took the height field that you posted and your color and made a 3D view. Also, I took the output from the river run and put that on top for reference. If you like these images then you can have the app - its a freebie.
Anyway - here's some pics. I guess Nick will have to verify if you have the right method.
I did some more tests using my GTS to see if it could predict the river flow but it struggled with this height map too. The first image is what its like if I set it like soft mud and let it erode wildly. It cuts deep channels into it because of the large drops in height.
Trying again with lower erosion and also adding what I call frost erosion in that when the gradient gets too high it smooths out steep cliffs then it drops out those spikes and also does a better job with the erosion. I was having fun so I rendered it with some textures too. I really like the result - looks like a waterfall type scene. Anyway - either of the two images get some basic similarities in the water flow so there's some general / vague consensus here about where the water might go. Its still a sim tho - its all guesswork.
Off Topic
Redrobes, I've downloaded ViewingDale. I put the Height.bmp and Color.bmp, but only see grayscales... What's happening?
Don't know ! Can you resize or make the dimensions of the images 512x512 each ? And it might be helpful if using full color images though its not supposed to matter. Other than that you might have an older type of graphics card or a driver issue.
Cova-
Can you provide the source greyscale in png? the jpg artifacts mess up any processing.
Attached is a incise based precip run using wilbur to show where it places rivers.
w_incise.png
-Rob A>
My tutorials: Using GIMP to Create an Artistic Regional Map ~ All My Tutorials
My GIMP Scripts: Rotating Brush ~ Gradient from Image ~ Mosaic Tile Helper ~ Random Density Map ~ Subterranean Map Prettier ~ Tapered Stroke Path ~ Random Rotate Floating Layer ~ Batch Image to Pattern ~ Better Seamless Tiles ~ Tile Shuffle ~ Scale Pattern ~ Grid of Guides ~ Fractalize path ~ Label Points
My Maps: Finished Maps ~ Challenge Entries ~ My Portfolio: www.cartocopia.com