Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

World Building [RELEASED] CityGen3D | Procedural city generation from map data

Discussion in 'Tools In Progress' started by CityGen3D, Jan 28, 2018.

  1. IJas13

    IJas13

    Joined:
    Jul 27, 2017
    Posts:
    19
    So here are some screenshots for the sidewalks issue. It was also present in the V0.81 after some tests. Everything was created in a new Project. In the sec picture I moved the sidewalks a little bit up so you can better understand it. The Orginig of these pictures are: Lat.: 52.457736, Long.: 13.332159.

    You can also see this issue in the post of chmodseven, Saturday at 12:53 PM (actually dont know how to reference it :)).

    Edit: didn't know referencing is so easy lol
     

    Attached Files:

  2. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Thanks for providing the screenshots.
    It looks to me as if the sidewalk meshes are being generated (you subsequently move them in the second screenshot).
    So I think what you are referring to is that the curb appears smaller than you'd expect (so the sidewalk is not elevated very much in relation to the road), which is a current side effect of not applying a heightmap.

    By default, terrains have heightmap data at zero.
    This is a problem because Highways are generated by creating sidewalk meshes and road marking decals (both of which seem to be working as normal in the screenshot), but also by offsetting the road terrain to be lower, which can't happen if the heightmap is at zero.

    You can fix this by flattening your terrains to a value higher than zero, say 20, using the Unity Terrain tools shown in the screenshot.
    Flatten All should apply this to all loaded terrains, so its quick and easy to do.
    Then regenerating Highways, should offset the road properly.

    For 0.91 I'll see if I can put a fix in so that Terrain heightmaps don't default to 0 if you don't apply a real-world heightmap.
    But I hope this explanation helps in the meantime.

    If I've misunderstood your issue, please clarify further, thanks.

    terrain_settings.png
     
    hopeful likes this.
  3. IJas13

    IJas13

    Joined:
    Jul 27, 2017
    Posts:
    19
    So basically the texturing scheme of the sidewalks is not quit good. I mean as you can see the texture that they get is most of the time grass. So the left sidewalk is getting the grey texture, but the right one gets the green one, even if on the splatmap there is no green.
     
  4. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    The default setup is that the sidewalks just adopt the terrain texture from a sample at the location.
    However, you are able to assign your own textures to them if you prefer and there are two ways of doing that.

    Either procedurally using the Generator-Highways tab, where you can match up different surfaces to use different sidewalk textures.
    Or manually where you can change the sidewalk material to anything you want by dragging a material onto the mesh (as you would for any other mesh).

    Please have a play with assigning sidewalk textures via the Highways interface (and regenerating them), to see if you can get the results you want and let me know how you get on.
    Please post screenshot of your Highways panel interface if you still have issues so I can see what settings you have, thanks.


    Also note that the Default Land surface for where no OSM surface is defined is set to Grass by default on Data-Location panel. In urban areas it's sometimes better to use a different one, such as Pavement or Residential, if it's to be assumed that unmapped areas are paved over.
    For instance when I generate in London I often set this to Residential so the default is to concrete over unmapped areas and greenery only occurs where its specifically mapped (as parks or woodland, etc).
    Whereas in more remote areas it's often better to assume a default of grass and only have pavement where residential and footways are specifically mapped, if you see what I mean. So the intention is to give you full control over it, but some of the more advanced features are undocumented until v1.0, so I can hopefully point you in right direction in meantime.
     
    Last edited: Apr 23, 2020
    IJas13 likes this.
  5. IJas13

    IJas13

    Joined:
    Jul 27, 2017
    Posts:
    19
    Ok did it by manually dragging those to the meshes. I couldn`t figure it out how to do it correctly with the Generator-Highways tab
     
    CityGen3D likes this.
  6. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Thanks for letting me know. I'll do a demo on this when I can to show you what I mean in more detail.
     
  7. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Here's a video of me driving round a CityGen3D scene after a v0.9 test

    It includes a bit where I drive under Millbank Tower, which shows the flexability of the procedural building system.

    Everything in the scene apart from the car was generated automatically via the CityGen3D UI, in under 30 mins from start to finish.

    Car from Edy Vehicle Physics Pro.

     
    Astirian, chmodseven and IJas13 like this.
  8. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Having run some performance tests, I do think the building processing needs some optimization.
    It's generally much quicker with it off, so I will look into that and hope to improve it before v1.0.

    In the meantime here are some general tips for speeding up the processing (the bit when you click Process button on Data window):
    • Use as small Coastline JSON file as possible for your area (or don't use one at all if your location is inland. You don't need one for rivers & lakes, only seas)
    • @jeffmorris1956 If you are still using the large East Coast USA one, try creating one specific to your location (eg one that just covers Staten Island) Instructions for creating them are included in the manual.
    • If your location does have some coast so you have a coastline file present and referenced, but you are about to process a portion of your map that doesn't cover a coastal boundary, deselect Coastline from the processing filter and turn it back on when you next need it.
    • Don't process Buildings unless you really want them (especially when lots of small buildings are mapped). As stated above, I'll look at optimizing this further as well.
    • Reduce unused data tag combos. CityGen3D has to check each OSM Way and Relation for every tag, so the fewer you have the quicker processing will be, and in some cases it will be obvious to you that you don't need to check for some of them in your location
     
    IJas13 likes this.
  9. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Those lanes are narrow. Is that how it really is?

    I haven't checked yet to see if a lane width value is exposed, but it would be nice to be able to have slightly wider lanes, if possible.
     
  10. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    The single lane service road did feel a bit narrow, but they are service roads so it's probably not far off.
    I think the others are probably quite close to reality because London does have quite narrow roads.

    However, you do have full control over lane width per road type before processing via Data-Roads panel.

    road_editing.png

    You can also modify individual lane widths and number of lanes per road instance via 2D map.

    road_editing2.png

    This actually leads me nicely onto another feature I put in for v0.9, which is the marking priority options that are now modifiable for each road instance.
    By default, roads with higher priority setting clip the markings of lower priority roads where they intersect.

    But what to do when two roads of the same road type intersect?
    Up to now this meant both markings would be shown, which isn't always what you want.
    So tweaking these values gives you a bit more control to create junctions and such like.
    You just click Repaint Road Markings on Highways Generator to reapply the decals.

    Here's a before/after example where I increased the marking priority for the road running left to right. Notice how it now clips the markings of the minor roads to effectively form proper junctions:

    before.png
    after.png


    Eventually I hope to make it easier to add additional marking decals at junctions, like give way symbols. But this was the obvious first step to improving it (and at least allows you to add your own decals in the meantime if you want to).
     
    Santa36 and hopeful like this.
  11. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I think that some of the OSM data is wrong for some roads. For example, Hylan Blvd is usually 6 lanes wide between south of Staten Island Expressway and south-west corner of the island. The generator creates wrong lanes of roads from 2 lane to 6 lanes.
     
  12. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    The number of lanes wont always be specified in OSM data.

    I had a quick look and Hylan Blvd seemed just to be down as Primary Road is some areas.
    In the absence of specific lane data from OSM, CityGen3D will take the defaults that you set for each road type, or you can set the number of lanes yourself for a specific road as detailed previously.

    Although as the name suggests, OpenStreetMap is maintained by the public. Anyone is free to edit the actual map itself (adhering to their T&Cs and guidelines).
    So if you can improve the map data from local knowledge then you can edit the actual map for the benefit for all OSM users around the world :)

    Disclaimer: you must obviously never add fictional data into the actual OSM map to satisfy requirements of your own project. CityGen3D will have it's own 2D map editing features to plot your own cities. More on that soon!
     
    hopeful likes this.
  13. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    CityGen3D was always conceived as a complete level design tool, not just as a means to import real world maps.

    However, I thought it best to start with real world map integration because it’s a really good way of understanding the scope of the problem of how to translate map data into 3D, rather than trying to add in real world map support afterwards.

    So as we approach full release, I want to get the 2D map editing framework in place, ready for further enhancements later on.

    Here’s a short first look video that shows me interacting with a OSM surface to change it’s shape, as well as creating a brand new surface from scratch.



    Hopefully this gives a good indication of how you’ll easily be able to edit real world maps to your liking, and eventually even plot your own 2D maps from scratch, before auto generating them in 3D using the CityGen3D Generator.

    So even if you have no interest in using real world maps in your project, if you like to design your game worlds in 2D first, you will have lots of fun using CityGen3D in the future, because it will allow you to prototype your scenes automatically in 3D from your 2D level designs.

    I've also fixed the annoying perspective issues as you move around the 2D map, which is now rendered in Orthographic camera mode, so the whole experience is much better just for having that.
     
  14. Santa36

    Santa36

    Joined:
    Dec 1, 2018
    Posts:
    25
    If you are working at the 2D map at the moment. Could integrate some Placeholder shaped like circles that can be colored differently and could be used as Spawnpoint for whatever type or AI you want to put into the map? (People, Monster etc.?
    Also a column where i could set: how many will spawn, which types will spawn, endless spawn for enemies (like in Towerdefense games or any game where you have to kill a certain amount of enemies)
    Permanent Spawn if its a house for NPCs.
    If this is not necessary cause there are already some tools out these kind of things or to bothersome to integrate to work with other code and a mess to support it forget that I asked.

    Otherwise: Shapes for 2D map standard.
    all basic shapes for different functions
    • Events
    • Spawn
    • Entry/Exit
    • dependencies between the "shapes" activate 5 "circle" shapes to unlock "square" shape
    ---
    One other thing layering Maps.
    You work on a Dungeon Crawler you download your map you picked out or just finished drawing. Set it to layer 1. Layer 2 would be the first level of the Dungeon etc. That you dont loose track of which layer is which Dungeon either that you could name them or create a Mainlayer where you can group some "Dungeon" Layers into.
     
    Last edited: Apr 30, 2020
    CityGen3D likes this.
  15. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    At first I was afraid to buy this asset. I thought my game would have that same look all the CityGen3D demos had. But I must say this asset is simply amazing and for what it can do the price is kinda low(Not that I'm complaining). It's a bargain. There were so many things I wanted to do in my project. I wanted real world terrain and I wanted a way to be able to quickly populate an area with buildings and automatically add roads. This thing solves a lot of problems I had with developing my game. It can even level the terrain under buildings which is such a time saver for me. It also smooths out the edges of the raised terrain. It's easily one of my favorite assets and it's not even on the asset store and it's still in beta. And if you don't like stuff about certain models it's so customizable. You really can make your game look however you want when using this asset. You don't have to have that CityGen3D look. The stock textures and stock houses and such aren't what I was looking for in my game. That kept me from buying this asset for a while. I'm going to combine assets from this and most of my other assets to create an amazing game.
     
    Astirian, CityGen3D and Freznosis like this.
  16. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Much of what you describe is planned for to some extent by adding map editing functionality for CityGen3D Entities.

    You can already associate OSM Nodes to a prefab using CityGen3D Entities, so the Map Editing feature will simply allow you to add these to your 2D map anywhere you want.

    So what you would do is create a monster spawning prefab with a component appropriate for your game, perhaps with a range setting and timer, or whatever.

    Create a nice little icon for it, then you’ll be able to place your spawner on your 2D map just by selecting it and clicking on the map.

    I’ll also be extending the Entities panel so you can have Entities auto spawn by surface type, just like you can already populate your world with trees on the Trees panel by associating different tree prefabs with different surface types.

    An obvious example that springs to mind would be if you have some animal prefabs, you could easily associate them with Farmland surface so the Generator adds them in for you.

    I’m certainly thinking of adding some preset 2D shapes to aid the drawing of 2D maps. Also being able to draw a 2D building shape and saving it as a template will be quite nice.
     
    Astirian and Santa36 like this.
  17. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Thanks very much, I'm glad you are enjoying using it. :)
    I look forward to seeing what you create with it!

    The versatility of the asset is something that I haven't really demonstrated very well up to now, but like you say, you have full control over what textures and models you use with CityGen3D, so you can use it to develop any type of open world game really (even more so with the upcoming map editing functionality).

    One of the things I'm doing as I approach v1.0 is testing it out with other popular assets.
    I'm currently trying it out with Opsive character controllers, so there's a good chance the next demo video will not be driving, as I've had lots of fun this weekend running around my recent London scene shooting monsters.

    I also intend to create a completely different look in a video soon to show off the versatility, using third-party assets. Perhaps a medieval scene, or something like that.
     
  18. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    I'm making a zombie game. I will show it off soon with what I'm working on. I'm mostly experimenting and creating new assets, buying different assets, and stuff like that.
     
    CityGen3D likes this.
  19. Astirian

    Astirian

    Joined:
    Apr 28, 2018
    Posts:
    15
    Truly awesome asset! Using it is almost as much fun as playing a game!

    I'm all caught up on the forum now, phew. I've been playing around with v0.9 on Unity 2019.3.4f1 and I've noticed a few things. Mostly probably me not fully understanding the tool set yet. :)

    First thing I tried was to try and use MicroSplat. I'm keen to use their anti-tiling solution for the grass terrain textures for example. But when I click on Convert to MicroSplat it seems to mess up the applied terrain textures. Looks like for some reason it's using asphalt and default or something? I don't know enough about Unity Terrains yet but I can affect this by moving the channels around in the MicroSplat config in the inspector...



    After changing the channel order:



    2x Ctrl-Z gets me back to this state but I basically need to re-apply the base textures to reset everything properly:



    Failing MicroSplat I was thinking of doing something like this https://forum.unity.com/threads/improved-terrain-texture-tiling.116509/ but I don't know where to change shader code yet.

    Second issue I'm having is that I can't seem to generate industrial buildings. I click the generate buildings button but nothing happens (maybe the tags are slightly off or something):



    Or I'm wondering if it has something to do with this underground waterway. That one's causing some interesting side effects of its own with the weird holes there in the terrain, and it overwrites the woodland terrain too a little further up:



    The last thing is I don't have any stone walls or hedges or anything. I can see them in the hierarchy here but they all seem to be clustered map feature GameObjects at 0,0. (The Features object under the Landscape parent is empty):



    Oh sorry, one other thing, I also had the water at the very base of the Landscape object bug and had to manually raise it up.

    My co-ords are Lat: 53.3265151977539, Lon: -6.55205726623535 if you wanted to check it out. :)

    I'm excited to be able to make some realistic looking fields by dragging hedgerows around the 2D map and so on, keep up the amazing work!
     
    CityGen3D likes this.
  20. Astirian

    Astirian

    Joined:
    Apr 28, 2018
    Posts:
    15
    Maybe there's a discrepancy in the map data but it also looks like the map generation got a bit muddled too in my test, this is the general area:



    In the 2D Map it correctly identifies the highlighted area as woodland (the right side of the upper riverbank is woodland beside Temple Mills IRL) but it's got the residential area muddled in on both sides of the river, this is wrong, it should all be woodland:



    Clicking on that residential area definitely looks off, it should look like the housing estates on the right-hand side:



    Again, not sure if this is a bug or just poor quality OSM data...

    The other thing I found myself doing is painting grass over the residential areas that didn't proc-gen houses. Will it be possible to do this in the 2D map editor? If I can see the outlines of the generated houses on the map, I think it would be easier to remove the extra "grey" that way. :)
     
    CityGen3D likes this.
  21. Astirian

    Astirian

    Joined:
    Apr 28, 2018
    Posts:
    15
    Oh hang on, I'm a dummy. Buildings have to be marked in OSM right? I just managed to fill up my industrial area with brick wall segments! :D



    And I suspect those holes in the terrain are an artifact from the terrain smoothing down into the underground river.
     
    Last edited: May 6, 2020
    CityGen3D likes this.
  22. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Hi,

    Delighted to hear that you are having so much fun using the tool!

    Microsplat was actually one of the first assets I tried to use with CityGen3D generated environments, back when I did the St Mary's Island tests, but I've not tested it in a while.
    But certainly the intention would be to have that working with it (I also intend to use it for my own projects!), so I'll run some new tests with latest versions.

    I will test your location today and report back as soon as I can.
    Thanks for the detailed feedback.
     
    Astirian likes this.
  23. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    This is a genuine bug so it's a good find, thanks for reporting it.
    If you look at the residential area on OSM you can see that instead of it being one closed Way it is actually a series of unclosed Ways (called a Relation in OSM terms).
    These are not being processed correctly in some instances so I'll work on a fix for this as priority and include it in next update.
     
    hopeful and Astirian like this.
  24. Astirian

    Astirian

    Joined:
    Apr 28, 2018
    Posts:
    15
    Awesome, happy to be of some help!
     
    CityGen3D likes this.
  25. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Still on course for submission to Unity Asset Store this summer, so with that in mind here's the first promo video :)

     
    chmodseven, Astirian, Santa36 and 3 others like this.
  26. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    I've been testing some third party assets alongside CityGen3D ahead of full release.
    Here's a screenshot of a prototype I'm working on using CityGen3D, GPU Instancer Crowd Anims, and A* Pathfinding Project. All work nicely together!
    There's over 1000 NPCs in this scene which is 1km in size, being chased by 100 monsters.
    I'll see if I can get a video together to show it off a bit better at some point.

    Along with my racing game prototype, if it ever gets anywhere interesting I'll create a dedicated thread for it, but it's mainly another testing ground for third party asset compatibility at this stage.

    I was shooting and trying to take screenshot at same time, which is my excuse for bad aim! :)

    bad_aim.png
     
  27. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    When I finally get my hands on it, I'm interested in testing a bit to see if it's possible to automate waypoint route generation using your system with my traffic system.
     
    CityGen3D likes this.
  28. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    That would be great!

    I was actually asked to recommend a traffic system for use with CityGen3D the other day and admitted I hadn’t used one enough to say, but that I had followed development of your asset and recommended they take a look at it.

    So we have to get it working with CityGen3D now anyway! ;):)

    I have tentatively started exposing lane info in CityGen3D.
    (The asset already needs to know this in order to generate the road markings, so the data is already there).
    So even in current version it's actually possible to access it in code and selecting MapRoads in Hierarchy will draw Gizmos on screen to show the lanes.

    If I remember correctly the y-axis always returns 0 at the moment so you'd have to raycast to get proper 3D terrain position for the lane waypoints, but you can get lane data from code like this:

    Code (CSharp):
    1. foreach ( MapRoad road in Map.Instance.mapRoads.GetMapRoads() )
    2. {
    3.     List<List<Vector3>> lanes = road.GetLanes();
    4. }
    I haven't had chance to actually do anything with this yet, but it may give you a starting point.
     
    Last edited: May 24, 2020
    Stephen_O likes this.
  29. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    This looks like a solid starting point, thanks for the info. I'm looking forward to doing some testing. :)
     
    CityGen3D likes this.
  30. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    By far the biggest cause of problems in the Beta was the initial setup of the asset regarding Unity Layers.
    Most reported bugs were just setup issues and as someone that regularly gets assets and doesn't bother to read any documentation before diving in, I really want to make the setup process as easy as possible :)
    Currently it's all too easy to miss the TagManager setup step and it was something that's been on my mind for quite a while.

    The good news is that I've spent some time improving the code to remove the manual step of setting up the Layers and it should be done for you automatically from v0.91, which will be out soon.
    You'll still need to remember to add the additional preview packages (Burst etc), but overall I think the setup is much easier now.

    So the only reason for worrying about Layers specifically will be if you need to make changes to avoid a conflict with a third party asset. The New LayerManager component on the CityGen3D Map game object will provide a mechanism for changing the layers CityGen3D uses if you need to do that.
    It's purpose is to remap the layers CityGen3D uses for different object types and have them automatically named appropriately in the Unity TagManager if you make changes.

    You can see what the LayerManager looks like in this screenshot, as well as the new Map Editing toolbar.

    layer_manager.png
     
  31. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Latest update now available from the website.

    It's given a minor revision number, mainly because I've run out of numbers before I get to v1.0 :)
    There's actually some fun stuff in there to try out, as well as fixes for some issues reported recently in this thread.

    v0.91 (31 May 2020)
    • Layers now setup automatically from within Unity after importing CityGen3D package into new project. No need to manually copy TagManager asset anymore.

    • Improved rendering of 2D map with orthographic projection.

    • Indicate bounds of 2D map on Map View with white rectangle.

    • Handles to edit shape of existing 2D map objects.

    • New map editing toolbar for creating your own 2D map objects with on screen help (Tools->CityGen3D->Toolbar)

    • Fix for unwanted heightmap drops at terrain edges after applying some heightmap actions.

    • Fix for some OSM relations not being processed correctly resulting in wrong 2D shapes.

    • UI now warns of 32 limit for types of map objects.

    • Camera variable exposed in LandscapeManager.

    • Fix for Unity freeze when selecting a database asset in Project view.

      You can expect more map editing functionality and usability improvements after full release, so this is just the start. But even now it's quite handy to be able to change shapes and positions of real world map data.

      It's also possible to create your own map from scratch using the Editing tools, although the intended workflow for creating your own 2D map has't really been defined yet (and may change in 0.92 to be more explicit).

      But for now, if you want to create your own 2D map and try out the editing tools that way, I recommend just picking a location and area size as normal and then simply not processing the OSM data. Or clicking Process and removing what you don't want afterwards, perhaps leaving some surfaces as a starting point.

      I'll release a video as soon as possible to demonstrate more clearly what you can do with it.

      As always, please ensure your project is backed up if you intend to import v0.91 into an existing project.


     
  32. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    116
    Sounds great. I'll try to check out the new features next week when I get the chance.

    Will all (or even just some) of these editing tools and map creation features also eventually be accessible via exposed API functions? That would be the most ideal for me, to allow me to integrate with other external data sets and even cooperate with other relevant assets, by being able to write integrating and bridging scripts between them.
     
    CityGen3D likes this.
  33. nikto42

    nikto42

    Joined:
    Mar 23, 2014
    Posts:
    9
    hello i wanted to ask will EasyRoads3D work with terrain creation in the citygen?
     
    CityGen3D likes this.
  34. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Oh yes definitely.
    At the moment the functions that create a new 2D map object either takes a reference to a OSM way/relation (for when processing OSM data), or takes a starting position (for when user is going to complete the shape via nodes in Map Editor).

    So I simply need to extend that to allow support for actually passing in a list of points that define a shape and you'll be able to call that from code.
    There's already functions for converting unity world cords to lat/lon position and vice versa, so combined with that you would easily be able to take third party map data and pass it into CityGen3D with a fairly simple script.

    If these API changes don't make it in before v1.0 it will be very soon after.
    You may remember I looked at Voronoi cell generation algorithms over Christmas as research for some post release features where I also intended to expand the map editing functionality by allowing randomly generated maps (with user definable inputs for biasing towards different surface types etc). So I'll need that flexibility myself to implement those features fairly soon.
     
    Astirian and chmodseven like this.
  35. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    I had another query regarding this the other day, so did have them loaded into the same project to try it out and had no obvious problem, but I haven't done extensive testing yet.
    But CityGen3D just uses standard Unity terrains, so if you want to use it for terrain/heightmap/building generation and use EasyRoads for your road network, that should work fine.

    CityGen3D exists partly because of the difficulty I had in replicating some real world highway networks using traditional road building tools.
    But I can imagine for some projects it would be great to use CityGen3D for rapid prototyping, and then use EasyRoads for final geometry. So if anyone does run into any specific problems in using them together, please let me know.
     
    Astirian likes this.
  36. nikto42

    nikto42

    Joined:
    Mar 23, 2014
    Posts:
    9
    doesn't work for me, it doesn't work Update Heightmap for easyRoads3d
     
  37. nikto42

    nikto42

    Joined:
    Mar 23, 2014
    Posts:
    9
    it works, enough change the Layer to Default
     
    CityGen3D likes this.
  38. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    That's very useful info, thanks for letting me know.
    CityGen3D looks for terrains specifically in the Landscape layer, so you may want to change them back after using EasyRoads.

    Edit: From v0.92 the Landscape layer will no longer be defaulting to 31, which should allow EasyRoads to adjust the heightmap when required.
     
    Last edited: Jun 1, 2020
    hopeful likes this.
  39. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Some improvements to map processing coming in v0.92 after some optimizations to building processing.

    This is default settings on the default location (no coastline JSON):
    18 seconds to process the map instead of 32. Should feel like a big difference for those working on large multi-terrain environments :)

    building_optimization.png
     
    IJas13 and hopeful like this.
  40. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    From v0.92, you'll be able to generate a simple heightmap from Perlin Noise as a starting point for your custom maps.

    perlin_heightmap.png
     
    overthrowrobotics and hopeful like this.
  41. IJas13

    IJas13

    Joined:
    Jul 27, 2017
    Posts:
    19
    Is there a way of creating traffic lights? Because placing them individually would be really inefficient. And if its not planned, is there any API which could get all of the crossings?
     
    CityGen3D likes this.
  42. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    There are plans to provide a traffic solution for CityGen3D, either as a separate module, or to provide full integration to a third party solution.
    This is in the early research and planning stage, but will be a big focus beyond v1.0.

    An example of what could already be done, is that it is possible to edit the Data-Entities panel to create a Traffic Light entity and have CityGen3D find OSM nodes tagged as "traffic_signals" when you click Process on Data-Location panel.

    You could assign a nice little traffic light icon to the entity and it would also appear on the 2D map.
    So just like post boxes, which are implemented by default, you would then assign an appropriate prefab to it for use in 3D and they would appear in your scene to match up with the mapped locations.
    You can also use the new Map Toolbar to place objects on the 2D map.

    As I say, actually getting the traffic light prefabs to do something useful is currently beyond the scope of CityGen3D and is currently something you'd need to implement yourself, but I hope to have more news on this side of things later in the year.
     
    IJas13 likes this.
  43. overthrowrobotics

    overthrowrobotics

    Joined:
    Jun 19, 2015
    Posts:
    47
    I played with getting traffic_signals in with these instructions and it worked ok. It dropped it into the middle of the intersection so I might need to play with the traffic light prefab to see if I can reposition.
     
    CityGen3D likes this.
  44. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Translating 2D map data into 3D does present a few challenges, because positioning that looks fine in 2D can appear strange in 3D.
    One of the common things to happen will be objects appearing on roads, because road representation on 2D maps doesn't physically represent their actual size (and even if it did you can edit lane widths in CityGen3D).

    So CityGen3D has a few tricks built in that can make the data appear a bit more realistic, to avoid things like objects appearing on the highway.
    One of those is the Location setting for prefab instantiation on the Entities panel.

    Post boxes are set to "DefaultOrRoadside", which will prevent them overlapping the road.
    If CityGen3D detects a postbox position to be on the road, this setting will ensure its moved to the sidewalk.
    Here's a couple of screenshots demonstrating the difference with a postbox in the demo location of West Hendon. In both cases, the actual position CityGen3D chose for the prefab is shown (and is different depending on the Location setting).

    entity_default.png
    entity_roadside.png

    So if you set your traffic lights to spawn with this setting, they should at least not be generated on the road itself.
    As I said previously, there are still challenges specifically associated with complex objects such as traffic lights that I hope to address in more detail when adding traffic support. But for now, I thought it worth showing you one of the tricks built into CityGen3D that can help reduce the amount of manual work you need to do.

    Of course this also means you can throw objects on the 2D map without too much thought if you set up your Generator to sanity check it, which is quite convenient.
    (Note that when trying this out I realised that the postbox faced the road even when moved. I've fixed that by changing the rotation to y=180 on the prefabs Mesh object. That should ensure any post box moved to the sidewalk is rotated to face away from the road, which makes more sense. So this is fixed for v0.92, but explains any differences to what you would see above in the current build).
     
    Bartolomeus755 likes this.
  45. IJas13

    IJas13

    Joined:
    Jul 27, 2017
    Posts:
    19
    I tested traffic_signals and encountered some problems. The Traffic Lights are never facing the right direction to the street. It always have an offset of 90 or 270 degrees. I also checked my Prefab and changed the rotation of it with different values and done the procedure again (processing -> generating). @overthrowrobotics Do you get same results?
     
  46. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    The way Bus Stops are setup by default in the Generator is probably a better example.

    You should find they always appear on the sidewalk and rotated to face the road despite the only data taken from OSM being a position.

    So if you set your traffic light prefab to use “Roadside” location and copy how that prefab is orientated, you should end up with traffic lights always instantiated adjacent to the road.

    The traffic light prefab will currently have no concept of traffic flow direction or anything that. Workflow improvements related to traffic and pedestrian AI will be worked on post v1.0 release, as mentioned previously.

    But hopefully these tips help in the meantime.
     
    IJas13 likes this.
  47. overthrowrobotics

    overthrowrobotics

    Joined:
    Jun 19, 2015
    Posts:
    47
    Is there anyway to automate the process of going through Data and Generator scenes? Can I write a script in Unity that will select the options I predefine? I'd like to automate generating much larger areas than clicking through the same options over and over.
    Using 0.92. Downloaded a second map and Unity crashed. I had saved the scene and project and the scene was gone when I came back. Restarting it and so far I'm on a second map and it's working, will keep an eye on it. 2019.3.3.
     
    CityGen3D and hopeful like this.
  48. overthrowrobotics

    overthrowrobotics

    Joined:
    Jun 19, 2015
    Posts:
    47
    It's definitely hanging on building generation. Shot a video. Going to email it to you.
     
    CityGen3D likes this.
  49. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    116
    This came up a while ago in the thread, and I think the solution offered was to make a prefab of the objects from your hierarchy which contain the settings you want to reuse. If you read back, you can probably find the relevant posts.
     
    CityGen3D likes this.
  50. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    v0.92 out now!
    • Reorganization of layers for improved compatibility with third party assets. Please back-up your work if importing into existing project!
    • Optimised building processing so map data should be processed faster, especially in areas with lots of buildings.
    • Stopped CityGen3D windows refreshing while in Play mode for improved game performance in Editor.
    • Blueprints will now alternate between stories of the same type when generating 3D buildings instead of ignoring all but the first one.
    • Reduced maximum Area size from 32 to 8 to encourage intended workflow of building very large environments using the tile system and avoid overloading your system with too much data at once.
    • Improved API so 2D map objects can be generated in code.
    • New workflow for fictional map creation: select Custom as Data Source on Location panel.
    • New Perlin Noise heightmap generation option.
    • Improved UI by automatically showing Map View after processing data and automatically going back to Scene View after generating terrains.
    • Fix for sidewalk texturing interface.
    • Some Undo support for CityGen3D window widgets.
    • Fix water generation for custom 2D water objects.
    • Prevent erroneous culling of building polys in some instances.
     
    hopeful and Bartolomeus755 like this.