"Least Cost Path" for Blender Terrains?

this uses A* to map each quad as a node -> it then pathfinds and uses a cost function to decide the shortest path

in the cost function I am using linear distance + (Z-height difference *Z-height difference)

so the greater the difference in height - the more expensive the cost - leading to ‘road like paths’ that follow the least steep paths.

most of my code is already in BPY for this - I will see if I can make a lib for you.

he did also spec that slope cannot be more the 3%
so that is a major constraint
and I guess there is like a start and end point on the mountain or landscape

some model might not even have a min path solution too!

a bit of a challenging math problem in 3D

thanks
happy bl

yeah this will get the ‘flatest path’
I can also color the road by grade - so if it’s over 3% it turns red.

interesting
would like to test that LOL

thanks
happy bl

Ha, gmail stopped sending me updates.
Thank you both for pushing it forward. I have less time for now.

This is great @BluePrintRandom!
I’d love to test it too on a landscape when I can.

Hello there. Any news on the library and colorisation based on slope?
This is still important for me :slight_smile:
Thank you!

step 1 for each quad find it’s adjacent neighbors, also collect what edge loops belong to each vertex

step 2 calculate the difference in elevation and use this to color the edge_loops vertex color that the vertex ‘owns’

Ah, well, thank you @BluePrintRandom
Unfortunately, I’m not a coder but an artist. Even if I understand the “python for dummies”, I have no idea how to define “quads”, “collect edges loops”.

Maybe you or someone could adapt some python from https://github.com/search?q=slope+path+A* to get a BPY script?

If you can’t, I still wanted to thank you for pointing it in the right direction with the right algorithm names and providing links to explain.

EDIT:
The only usable solution I found so far … https://www.youtube.com/watch?v=1c6UmnJDdV0
well …

Adding a blender resource to add road on heightmap (but not path finding it): https://beamng.com/threads/tutorial-adding-heightmap-roads-with-blender-v2.39903/
Pretty old though

there is an addon to project an helix curve onto an object shape
might work better then the skrinkwrap modifier

old addon and to find this script

but still does not check the slope of the path !

happy bl

Thanks @RickyBlender :wink:
You’re right, doesn’t check the slope.

Hmmm, do you know an addon to get iso lines? You see what I mean?
Lines which are at same level in topologic maps.

Because if you can set the elevation step between 2 isolines, and have a segment (fixed distance to respect the slope angle depending on 2 isolines distance) maybe, by (programmatically) searching to link isolines with this segment, it could simply work.

Here’s an example:
If you have a 5.8m elevation between 2 isolines and you have a segment measuring 100m that starts at one isoline and join the next isoline above (from one vertex of the segment to the other without changing length), you basically draw a straight path with a 5.8% (3.3°) slope.
You might start from this new point to try to join the isoline above or continue on the isoline (take a curve for example).
Of course, it means that you might have a ditch under the segment, so you might add some gravel under your road or a bridge, or avoid this route.

2nd idea, an isoline with an angle (slope), starting at point A and ending at extremum (highest point before going down and back to A).
Like a series of planes starting at the top intersection with the landscape:


From there you have a boolean and only keep one side, so you could go helix or hair pin curves on one side of the mountain or mix both.
OK, you might have with some negative slopes. But they exist in life too.

No idea how to implement this in code though :smile:

What’s the addon?

cant find this isoline thing !
saw something this year but can’t remember for now where !

has something to do do with contour lines may be or photogrammetry

if i remember will be back

may be open a new thread for this isoline function of Z thing

happy bl

That thread seems to be well beyond my meager Blender skills

And you’re way beyond my artistic level on Blender,
Like @RickyBlender and @BluePrintRandom, your portfolio is impressive!

you could also open up a thread on blenderstack
might get lucky !

happy bl

can you upload a sample blend file with a typical 3D shape
to add some isolines

for a Z value you could set a circle at that level Z and shrinkwrap it

after doing several isolines you could use the min path in blender
between 2 levels

happy bl

Here’s a blend file. Circle’s not happy to shrinkwrap around it though.

StackOverflow in general is not my friend. Too many patronizing, and sometimes yelling, people.

ANT landscape terrain for isolines.blend (2.1 MB)

did a quick test here

and seems to work fine

and horizontal

note
i’m stuck on 2.9 only and 2.79
no later version

now depends what the ultimat goal is here

you can make as many iso line at different levels Z
but after that not certain what else you need

happy bl

In a different domain: If your photo colors matter, I just PR a github Blender add-on to help you calibrate images with a color checker : Color Checker Calibrator - #5 by MagnussonProductions
Since the project is almost one year old and it has a bug, if you know code enough, you might be able to help.