[RELEASED] CityGen3D | Procedural city generation from map data

Edit 08/Jul/20: The early access Beta has now finished. Thanks to everyone that supported CityGen3D in the last 18 months or so. CityGen3D is now available to purchase from the Unity Asset Store!
There is a new forum thread in the Assets forum here .

Hi,

Creating a 3D city environment complete with terrain, roads, street lighting, railways, buildings, trees and other prefabs can be a very time consuming process.
It usually involves learning several different tools and getting them to work in sync with each other, then manually creating and placing many game objects.
Even before the creation of the scene, a lot of planning is required to design a believable city, which if you simply want to prototype an idea very quickly can be a big hurdle to overcome, especially when working on your own or in a small team.

So I’ve been experimenting with how to automatically convert 2D map data into a 3D scene in Unity, with a view to improving the workflow and allow creation of city environments with relatively little effort.
Rendering 3D maps is nothing new, but other approaches are usually not detailed enough to be suitable for game development.
A key goal of this project is to be able to create cities detailed enough to be explorable at ground level and therefore useable in first-person games.

CityGen3D is a work-in-progress Unity Editor extension and requires no additional coding. Simply specify a location using latitude & longitude and real world map data will be downloaded and parsed by CityGen3D within Unity ready for scene generation.
You can then use the CityGen3D interface to choose your textures and prefabs, before CityGen3D generates your scene using a combination of procedural geometry, texturing, terrain deformation, and prefab spawning.

Perhaps the best way of explaining what CityGen3D actually does is to show some screenshots and to say that nothing you see was manually placed in the scene.
All the terrain, roads, buildings and trees were created or spawned using real world map data and rule sets.

Please note that some of the art assets shown are third-party and used just to demonstrate the system. These include lovely trees by SpeedTree and fantastic buildings by rik4000.

Over the coming weeks and months I’ll be releasing more information on this thread (and via www.citygen3d.com and @CityGen3D) on how CityGen3D works and what it can do, but here are a few of the notable features:

  • Downloads and parses 2D map data from OpenStreetMap, ready for conversion into a 3D scene using user definable rules from within the Unity Editor.
  • Generates and textures Unity terrains to create the base of the environment.
  • Adds trees and detail to the environment automatically based on surface data.
  • Procedurally generates geometry for creation of roads. The unique way in which the scene is created means that complex junctions and intersections are created automatically.
  • Spawns road-side objects, such as street lighting and safety barriers.
  • Automatically spawns prefab buildings in realistic locations.

Please let me know if you have any questions, and I look forward to sharing more progress with you.

8 Likes

One of the most time consuming tasks when creating a 3D city scene is making roads. This is particularly the case when attempting to build complex junctions and intersections.

However, CityGen3D can be used to generate a large network of roads based on real world map data, all at the click of a button.
The unique way in which roads are generated means it’s capable of building different types of layouts such as roundabouts, without the need for custom mesh creation in advance.

It can also handle multi-lane highways, as well as junctions to join and leave the motorway.
The end result is an organic looking road network that’s diverse and fun to explore!

3 Likes

Once map data has been downloaded, CityGen visualizes it within Unity using Map View.
Different map objects are selectable in this view so you don’t have to find specific points of interest from the heirarchy alone.
It’s possible to toggle between this view and your normal scene view via the menu and a keyboard shortcut.

Much of the UI is still work-in-progress, but I’ll be providing more details and screenshots of this soon. That should make the workflow a bit clearer, so you can see how you would go about customizing your scene through rule sets before generation into 3D.

Before CityGen3D can generate your scene (terrains, roads, buildings, etc), you need to specify a real world location.
Up until recently this meant looking up the latitude and longitude of your desired location on the internet.
Now that I’m starting to think about tutorials and walkthroughs, it didnt feel right that one of the first things you needed to do was to use an external tool.
So I’ve been implementing a 2D map within Unity so you can browse around and pick a location without leaving your development environment at all.

At the heart of CityGen is a powerful terrain generator, so you don’t have to make city scenes with CityGen. I’m doing a lot of work at the moment in getting the terrain generation working well in different environments, so here I’m trying the sparsely populated island of St Mary’s.

Terrains are generated and stitched together automatically. Different biomes and landuses are textured differently depending on the rules you set via the CityGen UI within Unity.
In a future update I’ll show how all that works, with some close-ups of the generated island.

2 Likes

I saw your post in the Terrain Workflow, Interesting tool btw.
Is there any reason why the generated terrain is entierly flat?

Thanks for your interest in CityGen3D.

All the screenshots posted so far do look decidedly flat.
Although strictly speaking none of them are entirely level because a heightmap is automatically applied to form the coastline and other bodies of water.

I’m doing a lot of tests at the moment with the island in the last screenshot, which is sixteen terrains in a 4x4 grid (although a few of them are entirely underwater).

However the land above sea level is essentially flat in all the above screenshots, so its a fair question. This is mainly because OpenStreetMap doesn’t have detailed elevation data included in its database and the terrain wasn’t manually modified in any way.

The good news is that CityGen3D will also support downloading and applying of heightmap data from another source, most likely Bing Elevations API. I’ve had this working on a single terrain for a while, where CityGen provides an interface to the API so you just click a button to get the heightmap data for your location.

I was actually working on the multi-terrain implementation of this over the weekend, so your question was good timing, and I hope to share some more interesting topography with you soon!

It’s certainly worth emphasizing that CityGen3D is built upon Unity terrains, so all the tools for adjusting heightmaps and painting terrains will function as normal after CityGen3D has provided you with a starting point.

It also means that any shaders and assets you use already should work really well in scenes generated using CityGen. I’m having lots of fun enhancing my scenes with MicroSplat at the moment.

Some progress on auto heightmap generation…

CityGen already knows your chosen location, so will download the raw data for you from the internet within Unity.
It samples data every 32 metres (so 1024 times for one 1024x1024 terrain), which is very quick to download in my tests.
It masks that relatively low resolution data with the detailed OSM surface data and applies a smoothing function. This takes a bit of time, but you can adjust the number of iterations it runs.
You also can apply an offset for different surface types. I tend to increase rock heights and decrease sand, for example.

The end result is realistic environment, resembling the real life topography of the desired location.
Here’s a few screenshots of St Mary’s again, now with with the final heightmap applied.

Note that the roads are built and aligned to the heightmap automatically as well.
Similarly the terrain is textured and detailed procedurally by CityGen, although it’s being rendered with the MicroSplat shader for additional detail.

2 Likes

Hey @CityGen3D - I have a few questions

  1. Is there a planned price for this asset?
  2. Is the world generated at run time or Is it saved as a scene file?
  3. Will this work with other services such as Google Maps, MapBox, etc?

Thanks for your questions!

1). The price hasn’t been finalised yet, but one of the main purposes of CityGen3D is to help indie devs prototype their game ideas quickly. So the aim is to make it as affordable for hobbyists as possible.

The current plan is to release a beta version first, for no more than $50. Early adopters will get to download future updates for free, so it will be worth getting it early and help to influence certain aspects of it. The final price would most likely be somewhere around $100.

CityGen is royalty free, so there are no additional costs beyond the fixed price of the asset.

2). That’s a very good question and it’s worth emphasising that CityGen is an Editor extension for creating detailed scenes at design time, instead of relatively low detailed scenes on the fly at run-time.
In other words, you wouldn’t use CityGen to make a game similar to Pokémon Go, where the location changed dynamically at run-time, but you could use it to make a scene based on a fixed location anywhere in the world.
For example, a first-person shooter or street racing game with levels in London, Miami and New York (or wherever).

You can think of it as a terrain generator, but where the functionality of most terrain generators stops after the creation of trees and foliage, CityGen also has an integrated road and buildings solution. So prototyping ideas in more detailed game worlds can be done so much quicker.

The downloaded raw map data is saved as an asset within your project, so it doesn’t have to be downloaded each time you load Unity.

The resulting environment is simply saved as a standard Unity scene file and CityGen effectively doesn’t exist at run-time. So there’s no additional processing cost or memory overhead once your scene has been created.

3). CityGen uses OpenStreetMap as its main data source. Elevation data is currently downloaded via Bing Elevations API. There aren’t currently any plans to integrate with Google Maps or MapBox, but I certainly keep an eye on what’s happening with thoses services. So further down the line if you can see a particular area in which integration would help, please let me know.

There are a few areas of integration with other Unity assets that I am exploring. For instance, the developer behind BuildR has been very encouraging and we are both keen on integrating that into CityGen.
Although CityGen will have an integrated solution for procedurally generated buildings, that’s an example of where an existing asset could slot in nicely to supplement CityGen.

But in the short term, especially while in beta, the main focus will be on ensuring CityGen does the fundamentals well.

I hope that answers your questions, but let me know if something isn’t clear, or you have any more.

1 Like

Hey @CityGen3D - A few more questions from me.

  1. When Can we expect the beta version of CityGen3D?
  2. What is the artist workflow like with CityGen3D?
  3. What versions of Unity will this be compatible with?

Hi, thanks again for your questions:

1). There is no fixed date, other than to say as soon as possible! I’d like to have an initial release out over the Summer though. I’ve been greatly encouraged by the feedback and response so far, so I’m really keen on getting it out there so people can try it out and help shape it’s development.

Short term goals will be to start sharing more information on the work-flow, UI and get some tutorial videos ready for release. The plan is to release both via the website at www.citygen3d.com and eventually via Unity Asset Store.

2). I’m conscious of the fact that most of what’s been shared so far is of generated scenes, rather than the process of how you get there. So I’m working hard to fine-tune the UI, and I’ll be giving out more info on this very soon.
But the goal is to make it user friendly so it should be usable by artists and designers. CityGen has a custom UI for specifying rules and assigning textures and prefabs (more screenshots coming).
You’ll be able to define what different surfaces look like (eg farmland, beach, swamp, etc), by assigning textures to them with noise filters. You’ll be able to define how each surface spawns trees and foliage and how each road type is rendered.

Buildings can either be prefabs or procedurally generated. For the procedural buildings you’ll be able to specify the use of different textures and meshes to make the buildings, depending on the type of building it is (eg. so skyscrapers can look different to houses).

You’ll be able to hook up different map features to different spawning systems. This will allow you to auto extrude walls and fences where they are mapped in real life, for example.

Essentially though you will have full control over the look of your scenes, whether you are making a sci-fi game or medieval game, you are really only limited by the art assets you have.

3). CityGen3D doesn’t rely on any specific Unity features, so this will largely be decided by the community during beta testing. But technically there’s no reason that it can’t work on old versions of Unity, we’d just have to have a sensible cut-off to avoid a large testing overhead. So definitely 2017.x (and 2018.x), possibly 5.x if there’s enough demand for it, but unlikely to go back further than that. But like I say, certainly open to suggestions on this.

More info on the CityGen3D user interface coming, I promise!..

But for now, here’s another screenshot showing how prefab buildings are auto spawned to align with terrain and roads.

The other screenshot is from the same scene and only the car was manually dropped into the environment.
The terrain, roads, buildings and plants were all auto generated from OSM data and Bing Maps Elevation data, either by using procedural geometry, or instantiating prefabs.


My first video!
A CityGen3D scene with a few props added to make a racing circuit.

Car and track prefabs from Edy’s Vehicle Physics Pro.

I’ve now destroyed productivity as I need to beat my best lap! :wink:

3 Likes

This looks pretty good so far :slight_smile:

Keep up the awesome work!

1 Like

Thanks for the encouragement, HeadClot88!

Also thanks to Edy and Dreamback that set me on the right path so I could code support for my racing wheel on this thread Vehicle Physics Pro beta, feedback welcome page-2
Knocked off at least 7 secs once I ditched the keyboard for my wheel & pedals :slight_smile:

Just in case anyone wondered, in the following image I’ve highlighted where I put the sector markers to create the race track in the video.

As noted earlier in the thread, I’ve been testing a lot with the largest of the Scilly Isles in the UK. The whole island was created by CityGen3D but only a relatively small portion of it is shown in the video: the red line route. The blue markers are where the start line and two sectors were placed.

If you want to replicate real world locations in great detail using CityGen3D, you can with a bit of research and suitable models & textures. But equally, you can use the raw data to create largely fictional environments that are realistic but organic looking. You have the whole world to choose from - that’s a lot of data!

Even with the same source data, you are free to play around with how you use it. I could decide the forests were actually the residential areas and the large built up area of Hugh Town was actually a dense forest.

I quite like the island location with the mix of beach, countryside and small towns. But I’ll be showcasing more built up locations soon as well (to more closely fit the name of CityGen!), when my testing turns more to the building generation as opposed to the terrain.

2 Likes

A Unity terrain is a single mesh, so you can only assign one physical material to it.
However CityGen3D gets round that by allowing you to assign a physics material to each of your terrain textures.

In this video you can see how the car struggles for traction on the grass compared to the road.
The tyre marks and particle effects are also different depending on the surface each wheel is on.

This technique is useful in lots of gameplay situations, not just driving games.
Such as deciding what sound your stealth character would make on a creaky wooden floor versus a soft carpet… :slight_smile:

5 Likes

As you can see from earlier screenshots, CityGen3D can auto fill your environments with prefab buildings based on rules you set.
However, OpenStreetMap often has building data available which can be processed by CityGen3D to make specific buildings.

CityGen3D will have BuildR2 integration so users of this asset are able to auto generate buildings based on map data from within the CityGen3D UI in Unity, which can be then modified further using the BuildR2 interface.

I’ll release more info on this later, but here’s a few test screenshots in London showing auto generated BuildR2 buildings on top of a CityGen3D environment.

2 Likes

Time for a new video showing a park in London!

Water fountains are often mapped in OSM, so I always had the idea of putting a nice particle system together and have it spawn in the right place :slight_smile:

Almost everything in this scene is generated or spawned by CityGen3D using the UI within Unity, but I added the birds manually using the cool Bird Flock asset.

The buildings are generated using BuildR2 integration and the terrain detail is rendered using GPU Instancer, although it was originally all placed automatically by CityGen3D.

5 Likes

This is amazing :slight_smile:

1 Like

Here’s a screenshot of the CityGen3D interface within Unity showing how you tell the tool to find different map entities within the OpenStreetMap XML data.

You can assign a little icon to each type for easy identification on the map.

This is a 2D representation of the 3D park in the video. You can toggle between 2D and 3D very easily and the 2D view is quite handy for finding and selecting objects (rather than always using the hierarchy, or getting lost in 3D).

Once the data is processed any entities will show up on the map and you can assign prefabs to each one ready for 3D scene generation.

3 Likes