Procedural roads for open worlds

   847   6   1
User Avatar
Member
37 posts
Joined: June 2019
Offline
Hello

Creating the terrain and do layers is pretty easy:

Im using a layer by feature node to isolate village areas ( in red )

Im scattering some point for main roads placement and just add a line between them for now

Then i scatter some box that represente houses

I searched alot but didn't find anything to help me doing some sort of pathfinding between all road points.

Attachments:
aaaa.png (911.3 KB)

User Avatar
Member
401 posts
Joined: Feb. 2013
Offline
I don't think there is one right answer to this. You could do some form of shortest path, or you could maybe use something like triangulate 2D (save the point positions in an attribute, flatten the whole thing horizontally with a transform node, then triangulate 2d, then turn into lines with convert line sop, transfer original positions on there with attribute transfer then restore those positions with vex).

I am certain there is something easier, but it escapes me right now.
User Avatar
Member
37 posts
Joined: June 2019
Offline
Okay, it seem triangulate just flat the thing by itself, and i can check to unflat it on output !

So i will probably have to do some codding, and dunno where to start…

Here is the Idea

The script start at point 0, then it check the distance of all neightbour points to point 1, and select the closest.

He move to the next point and do the same

It also have to choose a good slope for road, lets say, it take the 3 closests point to 1 and choose the one with the smaller slope
Edited by samuelbrunner - July 31, 2019 19:14:37

Attachments:
point.png (417.8 KB)

User Avatar
Member
2 posts
Joined: Nov. 2018
Offline
if you just wanna connect between each point, it will be easy.

I have try to use foreach to iterate more nature landscape road.

here is simple idea

scatter some point from mask, sort it and connect it.build a foreach number loop,use polyframe sop to get point tangent, it will be help you adjust some bed point with each step(like tangent is ({0,-1,0})), then use volume sample to ray into heightfield surface, and then let position offset little.
User Avatar
Member
401 posts
Joined: Feb. 2013
Offline
The scripts you described could be made in Vex/Vops.
User Avatar
Member
37 posts
Joined: June 2019
Offline
Thx for your ideas !

I tryied to build the road with a foreach point loop, but failed since im a big noob in houdini.
Same for Vex, i learned C# so i could write some code but VEX is pretty obscur for me…

Well i find some sort of workaround :

1. Using findshortestpath to connect all road point (but before i hade to place a triangulate node, it will create all the paths beetween road points and terrain points.)

That mean, findshortestpath will use all triangulated edge to find shortest path beetween road point, wich is pretty awesome. ( Start Points and end Points are roadpoints)

2. Using Fuse to merge all close points and make road look more natural.

3. Finally i added more terrain point ( screen 2-3 )

I'll upload the project if anyone wanna try, the cool thing, it use only node and no code at all.

The goal is to provide an easy tool that is just fun to play with and create some nice terrain with road, veg, rivers, houses, etc

Btw i found this pretty usefull tutorial for scripting in VEX :http://www.tokeru.com/cgwiki/?title=Houdini#Attributes_as_groups.2C_or_groups_with_.40_syntax [www.tokeru.com]


Next step would be to remove every edge that have a slope too high…
Edited by samuelbrunner - Aug. 2, 2019 08:10:11

Attachments:
001.png (1.1 MB)
002.png (1.6 MB)
003.png (1.6 MB)
Terrain.hiplc (563.5 KB)

User Avatar
Member
37 posts
Joined: June 2019
Offline
Using only nodes… Still not able to calculate edge slope or code anything, but i found some workaround

Layers are strange, lost alot of time just trying to make layer spawn were they should

You can see forest layer or grass layer overlapping road layer even i removed them on road
Edited by samuelbrunner - Aug. 8, 2019 07:17:52

Attachments:
road.png (3.8 MB)
LandscapeV3.hiplc (581.2 KB)

  • Quick Links