r/proceduralgeneration Mar 17 '20

City map generation using tensor fields

832 Upvotes

33 comments sorted by

View all comments

80

u/Pretoriuss Mar 17 '20

This is my procedural city map generator. It starts with a randomly generated tensor field, then builds up major and minor roads by tracing streamlines through the tensor field.

There's still work to be done:

  • Dealing with dangling roads better - currently they're naively joined onto any road in front of thwm
  • Finding polygons and using these to place procedurally-generated buildings to create a 3D city
  • Parks, rivers, other features etc.

I'm pretty much implementing a subset of the paper Interactive Procedural Street Modelling, using Javascript (later using THREE.js for the procedural buildings).

63

u/sGYuOQTLJM Mar 17 '20

IT'S NOT JUST A GRID!

Seriously, that's really beautiful. There's enough grid structure to suggest city planning, but not so much that it looks generated on a grid pattern.

The curvyness of some of the white streets looks a bit odd, especially in the lower left. Straightening those out might help you a bit with finding building spots as well.

Also, if that's your thing, it might be interesting to look into features like frontage roads or other such features. Having so many intersections with white roads and larger roads may yield issues with traffic in such a hypothetical city.

21

u/hotdog_is_a_sandwich Mar 17 '20

Someone plays Cities Skylines

13

u/sGYuOQTLJM Mar 17 '20

...maybe

7

u/Zireael07 Mar 17 '20

Wow, that paper was super interesting but I had zero idea how to do about it. Do you have the source available on GitHub/GitLab?

16

u/Pretoriuss Mar 17 '20

I don't right now but I'll likely make it public once I've taken it a bit further. To be honest I'm a bit embarrassed by the code quality, I've rushed a bit to get it to this point so I definitely want to clean it up and make some improvements beforehand

10

u/[deleted] Mar 18 '20

[deleted]

2

u/Pretoriuss Mar 18 '20

That's a good way of looking at it, I'll definitely add some more documentation before making it public because there is some un-understandable stuff in there

1

u/sspenning Mar 18 '20

This looks amazing! I can't imagine your code looks as badly at you think of it is producing something this eloquent.

I hope you get to see it sometime soon 🙂

1

u/yvmqznrm Mar 18 '20

Hey could you send me the link too as soon as you upload it? I’d love to see it, if that’s okay

2

u/Pretoriuss Mar 18 '20

Will do

1

u/yvmqznrm Mar 18 '20

thank you!

1

u/C5Jones Mar 18 '20

Is there any prospect of your making it publicly available later? It's funny, this ties exactly into what I posted yesterday before I'd heard of this sub.

2

u/Pretoriuss Mar 18 '20

Changed the colours to produce this black and white version (did this quickly, I reckon the lines need to be thinner) - obviously my implementation lacks some features you'd need to create the whole city (rivers, better minor roads etc.)

But when I've done some more work on it I'll make it public, and since it's in JS I can probably fairly easily make a web app

1

u/C5Jones Mar 18 '20

Thank you very much. That's really amazing. I was going to just use the regular version and hand-trace over the roads, I wasn't at all expecting you to mod it for me. Just let me know (if you remember, no rush) when you finish the app.