Search Unity

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

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

  1. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    I get quite a lot of requests for third-party asset support. I'm certainly happy to consider adding support if there's something specific that I can do to make it easier to use with CityGen3D.
    With BuildR2 for example, there's an obvious interface I can provide to make the process easier and remove the need for coding.
    In some cases, it may be a case of just trying it out and seeing how you get on with it though.

    Something like MicroSplat already works quite well with CityGen3D because both are designed to work on Unity terrain with no coding.
    I just use the CityGen3D Splatmap panel to texture the terrain as normal, effectively using them as control textures. Then drop Microsplat into the project and let it do it's thing. I can then use features via the MicroSplat interface to add detail to these control textures, such as changing one grass texture into several using the built in features of MicroSplat.
    All the MicroSplat add-ons should work with CityGen3D as normal, but if there is something specific I can do to make the workflow better with these assets, please let me know, and if it's feasible I can certainly try.

    One of the key features of CityGen3D is that it gives you a lot of data you can use in code however you want to use it.
    Up to now the whole focus has been on the UI so you can use CityGen3D with no coding at all, but there's loads of cool stuff you can do in code too.
    I think in a lot of cases, once the BuildR2 integration is released and you can see how relatively easy the CityGen3D API can be used to return waypoints for building shapes, then I hope that will encourage a few others to try integrations of other assets too.

    For instance, it's also fairly trivial to get all waypoints for rivers.
    CityGen3D has built-in functions for spline generation so you could get the OSM waypoints from a river in CityGen3D, create a higher resolution spline, then pass the spline into RAM, and then set flow maps etc as normal.
    I'm speaking from a point of view of not having used RAM yet, but any asset that can work from inputs via an API instead of manually through the Editor, then basic integration is broadly fairly simple.
    If you know your favourite asset does have an API then integration should definitely be doable.
    Hopefully just needs an example like BuildR2 to get things going... :)
     
    Santa36 likes this.
  2. Santa36

    Santa36

    Joined:
    Dec 1, 2018
    Posts:
    25
    Hey there, another idea. Just to post it here before i forget it. Just ignore it for now. If someday the AI module will be developed I think it would be great to have a built in Zoning/Spawning System. Like I said its just another idea, like you can zone in City Skylines except here you also can input which type of AI Entity should spawn in the designated area. Maybe it saves time. Like: The area is zoned and another menu pops up and you tick the entity you like too spawn in the designated area.

    And as always thanks for your time.
     
    CityGen3D likes this.
  3. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Beta 0.5 is now available:-

    • Faster heightmap generation via Unity Jobs and GPU Terrain processing.
    • Heightmap interpolation setting: Bilinear (faster) or Bicubic (smoother).
    • New heightmap smoothing options.
    • Option for applying heightmap offsets only if far enough away from highways as not to distort them.
    • Road markings now generated as part of highway generation where rules say they should be applied.
    • Fix for UnityEngine.ExitGUIException when attempting to select Database or Coastline JSON via pop-up.
    • Max area now 16x16 terrains.
    • MapQuest now available as heightmap data source (key required), in addition to Bing Maps.
    • Buttons for shifting data location 1024 metres (1 terrain tile) in any direction.

    There's a known issue when working with very large multi-terrain environments where heightmapping can fail.
    Both Bing and MapQuest servers get a bit upset if you make lots of data requests in a short amount of time and CityGen3D needs to make one request per terrain.
    This can result in "Too Many Requests" or "Gateway Timeout" errors when you have lots of terrains.

    What I want to do is remove the reliance on third party servers for the heightmap data and provide a solution that works with NASA's Shuttle Radar Topography Mission data directly, which is freely available for download.
    The interface would basically be the same as it is now where you simply click the button and CityGen3D does all the work.
    But instead of getting elevation data from Bing or MapQuest servers in real time, CityGen3D would be able to read SRTM files from your PC and use that as the source data for the heightmaps.

    The good news is I basically have this working already, just not quite in time for last update.
    So hopefully not long to wait for that fix.
     
  4. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    FormatException: Input string was not in a correct format.
    System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Single.Parse (System.String s) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    CityGen3D.MapBuildings.Process () (at <e0089ef0bbd24fa09f044dae3cc42393>:0)
    CityGen3D.EditorData.ShowLocationProcessingPanel () (at <e0089ef0bbd24fa09f044dae3cc42393>:0)
    CityGen3D.EditorData.OnGUI () (at <e0089ef0bbd24fa09f044dae3cc42393>:0)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:342)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:336)
    UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:310)
    UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean customBorder, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:361)
    UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:320)
    UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:266)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:438)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:421)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleEvent (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:401)
    UnityEngine.Experimental.UIElements.EventDispatcher.ProcessEvent (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:511)
    UnityEngine.Experimental.UIElements.EventDispatcher.Dispatch (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:307)
    UnityEngine.Experimental.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.Experimental.UIElements.EventBase e, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:176)
    UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:245)
    UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:68)
    UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

    I'm trying to create 3D model of Staten Island, NY with US coastline. I disabled automatic light mapping.
     
  5. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Something I'd like to see improved in CityGen3D is the forest creation. As it is now, I can have four trees and they all have the same scale and rotation. It would be great to have more options for generating more realistic and diverse forest and woodlands. Also, when generating details there's an option for outputting prefabs but that doesn't seem to be working for me.

    Thanks for the great work you've put into it so far!
     
    Santa36 and CityGen3D like this.
  6. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Looks like it’s having problems processing one of the buildings.
    In the short term if you untick the Buildings checkbox on the Location panel it won’t process the buildings, which should bypass the issue. (You can always process them later once the bug is fixed).

    Please could you indicate the Lat/Lon location you are using and the map Area size so I can reproduce.
     
  7. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Each tree instance should have a different height and scale within the ranges specified for the tree type on the Data->Trees panel.
    The downside to this approach is that you have to decide before processing. I'll see how I can give you more freedom on the Generator->Trees panel to make changes.

    The default Unity shader used for detail mesh rendering is very selective about what prefabs you can use with it so you may just be experiencing that.
    I commented on a thread about it here, which includes some tips on how to setup prefabs to use with it:
    https://forum.unity.com/threads/does-terrain-detail-mesh-work.629176/#post-4221541

    I think it’s likely it will be improved as part of their Terrain improvements eventually, but for now if you want to use detail prefabs a third party shader is probably best bet.
    I’ve had good results with GPU Instancer where I use CityGen3D to auto paint the detail and GPUI for the actual rendering.
     
  8. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    I think I know what this is, so it should be fixed in next release.
    Thanks for reporting it.

    In the meantime I'm fairly sure it's specific to processing the Buildings so you should be able to avoid the error by turning that off in the meantime.
     
  9. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Beta v0.51 is available now:
    • Automatically create terrain heightmaps from NASA's Shuttle Radar Topography Mission data.
    • Fix for parsing error when processing some OSM buildings.

    NASA SRTM requires manual download of NASA’s Shuttle Radar Topography Mission data, but is the most reliable method as it doesn’t require communication with a third party server each time you use it.

    SRTM data is freely available from several online sources, but the easiest way to identify the files you need is to download via this website: http://dwtkns.com/srtm30m/

    You will need to register for free on the NASA website in order to access the files. Once you have signed in, simply find your location on the map and download the required data files.

    After downloading the zip files you need, you should unzip them and put them in your Unity project here: Assets\CityGen3D\Resources\Data\SRTM

    Then all you need to do after Generating Terrains is click Apply Heightmap and CityGen3D will create heightmaps for all your terrains from the SRTM data using specified interpolation method.

    With recent optimisations you can have a terrain heightmapped and textured really quickly now, in just a few clicks. I'm going to try and release a new video soon showing the workflow as the existing one is quite dated.
     
  10. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    If I create 4X4 terrain, it works. If I try to create huge terrain, Unity 3D "locks up". After creating a group of 4X4 terrain, I moved the gray box 4 times and create new group of 4X4 terrain, the old group disappears. Am I supposed to see 3D buildings?
     
  11. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Hi,

    Which version of CityGen3D are you running and what’s the total size of environment you wish to create?

    Each time you Process the data on Location panel you will lose what was there previously.
    You’ll probably want to create a separate scene for each 4x4 chunk each with its own data set, save it, then move position and create another one.

    With the aim of supporting world steaming tools (and hopefully having a built in solution for this one day), CityGen3D can also split your environment into scenes automatically.
    The Save As Scenes button will save each Landscape as it’s own scene which can then be loaded and unloaded at runtime (because once an environment gets too big it’s not feasible to have it all in memory at same time).

    The Roadside panel in the Generator allows you to spawn prefabs on different surfaces. By default it is setup to instantiate houses and street lights with the provided prefabs.
    Note that houses are set only to be spawned over surfaces marked as residential, so you may want to change that in order to get results in locations that don’t have residential areas mapped.

    Work is being done on BuildR2 integration which will support generation of buildings based more specifically on OSM map data.
    This should be available fairly soon. It was delayed a bit to implement recent optimisations based on Unity Burst and Terrain GPU processing.
     
  12. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I'm using version 0.51. I tried to use 16X16 terrain but Unity3D "locked up". I'll try the "Save as Scenes" after generating 4X4 terrain.
     
    CityGen3D likes this.
  13. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Do you have "Auto-Generate" disabled for Lighting? I have that problem when I forget to uncheck that.
     
    CityGen3D likes this.
  14. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    I believe I may be able to switch it off in code to prevent this problem using
    Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;

    I will test this and add it to next release if all is well.

    If your lock-up isn't related to auto generating lightmaps while using CityGen3D, please can you confirm your lat/lon settings and exactly when the lock-up occurs. Is it after you click Process, Generate Terrains, or something else?
     
    Last edited: Apr 3, 2019
    StevenPicard likes this.
  15. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I generated 4X4 group of terrain, saved the group as scenes, moved the gray box to new group of terrain, generated new group of terrain, and try to save the new group but I got error messages and the new group couldn't be saved. Do I have to create a new scene for each group of terrain? If so, how can I do that? How can I merge the scenes into one new scene?
     
  16. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Staten Island is really densely mapped, with quite a lot of detail.
    I had a go at creating a 16x16km area (Lat: 40.579, Lon: -74.145), which is very nearly big enough for the whole island.
    Download took a few mins, but processing did take a little over an hour, even with buildings, entities and trees switched off.
    I will see if I can optimize this further but there is loads of data to process. But at minimum I can improve the progress bar feedback so you know if the Editor is still alive.
    Here's a screenshot of the 2D map:
    staten island.png

    Intended workflow when CityGen3D was conceived was that you select an Area big enough for your entire world so you end up processing just one data set (as above) and create your 3D environment from that.
    Originally I had in mind using CityGen3D to create environments up to around 8km, which is comparable to a large Battle Royale map, and this approach works really well for environments up to this size.
    Naturally though, you give people a tool like CityGen3D and they want to start creating even bigger worlds! :)

    So I do think there's a need to be able to support working on smaller chunks at a time and being able to join them up later.
    This will allow you to download smaller data sets (say 4km as you suggested), process the data, generate the terrains, and move into adjacent location and repeat the process (infinitely if you wanted to).
    As I've stated before, when working with really large worlds you will need either a custom solution to world streaming or a third party tool for this. I hope to build in a world streaming solution into CityGen3D a bit later on, but we are not there yet.

    The Save As Scenes was the first step towards that in that splitting up your world into individual terrains should make a world streaming solution viable in that terrains around the player could be loaded in and terrains far away are unloaded, all at run-time.

    But the current approach still requires a massive data set to start with (and that's limited to 16km at the moment).
    So how to get around that?
    Well first step was to implement the location offset buttons, the little arrows next to the Lat/Lon selection.
    These move the location 1024km in each direction, the size of one CityGen3D terrain.

    The idea is that you could work with smaller Area sizes (eg 4km) by processing the data, generating the terrains and other 3d objects and save it.
    Then shift position 4km along and process a new data set and repeat the process.

    I tried this workflow which you can hopefully replicate in your project:

    • Load "New City" scene
    • Give appropriate name in Location-Settings (eg "Location1")
    • Select area size and starting location
    • Click Download
    • Click Process
    • Click Load Generator
    • Save Scene eg "Location1"
    • Click Generate Terrains (and texture them, add trees, etc)
    • Click Save As Scenes (will give you new scenes name "Location1 0", "Location1 1", "Location1 2", etc).
    • After CityGen3D has split all the terrains into different scenes, unload them from Hierarchy (Right Click - Remove Scene)
    • Shift location over using arrow buttons to adjacent location
    • Give appropriate name in Location-Settings (eg "Location2")
    • Click Download
    • Click Process
    • Save Scene eg "Location2"
    • Click Generate Terrains (and texture them, add trees, etc)
    • Click Save As Scenes (will give you new scenes name "Location2 0", "Location2 1", "Location2 2", etc).

    This approach basically works, but there are some issues with alignment that will need fixing (so its not really production ready at the moment).

    When done the original way (one big data set and generate all your terrains from it), each terrain lines up seamlessly with the next.
    The problem with the new way (multiple smaller data sets, shift position with buttons, and repeat), is that the terrains don't line up seamlessly at the edges of one chunk to another.
    Also the origin of each chunk is 0,0,0 so they need to be moved manually to be in correct place.
    This is something I need to look at further to improve the end result.

    BuildR2 integration is main priority this month, but after that I really want to see if I can nail down a really good workflow for making unlimited size worlds and even get to a point where I can start experimenting with run-time scene streaming to make this as easy as possible.
    So at the moment the workflow for making really big environments (using the smaller chunk method) is a bit work-in-progress and it does have it's limitations, but further improvements should be coming soon.
     
  17. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Making some good progress with the updated interface for managing massive multi-terrain environments.

    Up to now, seamless tiling of terrains is only guaranteed when you create them from the same data set, which is a problem when you want to create really big environments because you have to download and process one really large OSM database.

    These changes are about ensuring that if, for example, you create a 4x4km environment and want to create another 4x4 environment adjacent to it, that both groups tile seamlessly with each other even though you downloaded two smaller data sets and processed them separately (or even had different users working on them).

    New workflow will be that you click the map to set your location origin, the bottom-left most position of your environment, and create your first group of terrains as normal.
    Then you click the arrow buttons to move around the map and download a new data set.
    But because the stored origin is the same, any other terrains you create in this way will be positioned correctly and have seamless texturing and heightmapping to adjacent terrains in a previously generated group.

    A few issues I need to fix, but overall really pleased with the progress.
    These changes will hopefully make a build later this month.
     
    Santa36 and StevenPicard like this.
  18. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Beta v0.6 is now available!

    Although the UI is familiar there are quite big changes underneath it all to support the new terrain tiling system as mentioned previously.
    So it's recommended to only upgrade for new projects, unless it's feasible to regenerate your environment again in your existing project (because existing landscapes wont contain required data that the new system needs in order to function properly).

    Here's a video showing how I download data for a single terrain environment and then extend it by shifting position using the arrow buttons and downloading another data set for another terrain. This ensures the new terrain aligns with the previous one.


    Because CityGen3D generates a lot of objects I've also added in code to disable automatic light baking when CityGen3D windows are active. This prevents Unity from constantly restarting the light mapping while CityGen3D is busy making changes to your scene.

    As you can see from the video I've updated to Unity 2019.1 and CityGen3D seems to largely work fine with it.
    The only known issue is the Heightmap Smoothing function doesn't work properly, hence I avoided using it in the video.
    I think Unity have made some changes to the GPU smoothing system in 2019.1 so I'll need to take a look and update the code accordingly.

    Please report bugs as normal indicating whether you are already on 2019.1 or still on 2018.3, thanks.
     
    Last edited: Apr 24, 2019
  19. Santa36

    Santa36

    Joined:
    Dec 1, 2018
    Posts:
    25
  20. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Historically, working with real world heightmaps in game dev can be a bit tricky and time consuming, because you manually have to calculate what you need from an image and apply it to you terrains.

    CityGen3D now does all the work for you just from the raw HGT file, so you don't specifically need an image file, although the website at http://dwtkns.com/srtm30m/ also allows you to download an image preview of your chosen segment for reference as well.

    From the HGT file, CityGen3D will take the appropriate portion of the heightmap for each of your terrains and apply interpolation when you click Apply Heightmap. So there's no manual work required other than downloading the file, although I may automate that in a future release so it downloads any missing files for you from within Unity, if possible.
     
    StevenPicard likes this.
  21. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I tested CityGen3D with Unity3D 2019.1 and it worked but train tracks don't show up. Did I do something wrong?
     
  22. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Hi Jeff,

    No you haven’t done anything wrong. This isn’t in the current build, but will be included before we are out of Beta.

    The main reason the highway generation is slow is that the current mesh extrusion system in CityGen3D needs improving.
    I’m working on this right now, which in turn will help with adding features such as railways, walls and fences.

    So where Entities panel is for spawning prefabs at a OSM node position, a new Features panel will be used for extruding meshes along a OSM way (series of nodes).

    A very early test of this can be seen in some screenshots where road barriers, fences, bushes, and railways have been extruded. But unfortunately it’s not quite up to scratch for release yet.

    It’s something I’m really excited about and hope to have more news on soon, because adding this extra geometry to cities really brings them to life.
    So all being well an up-coming update will have faster road generation as a result of improving the underlying tech, before introducing the Features panel soon thereafter.

    Meanwhile I’ve also been working on BuildR2 integration, although I’m aware Jasper is working on a big update so will likely tie-in release of that with his update.
     
  23. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    If I have to stop generating the city, quit Unity3D, turn off the computer before going to bed, will Unity3D remember where I was working on after turning on the computer and running Unity3D tomorrow morning?
     
  24. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Yes, as long as you save the scene you are working on you can load the scene back up again and resume where you left off.
     
  25. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I don't know why Unity3D stops responding when trying to process data for a city the size of Staten Island, NY. My computer has 16GB of system memory.
     
  26. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    The progress bar feedback isn't great at the moment when processing really large areas and it can look like it's frozen. I will look to fix that for next update.

    As mentioned previously, I did manage to process 16km of Staten island but it did take around an hour (16mb, i7-6700k 4Ghz).

    There's a lot going on when you click Process to identify objects from the XML, which in a OSM file that big will contain hundreds of thousands of individual OSM nodes and thousands of OSM ways.

    The last update made it possible to work on smaller areas and have them align with each other. So the recommended workflow is to work on smaller areas at a time and build up your city that way.
    The latest manual has more info on this in: "4.2 Location - Settings".
    I also want to speed up this processing as much as possible before coming out of Beta. Recent updates have seen massive improvements on terrain heightmapping and texturing speeds through the use of Unity Burst/Jobs. So it may be possible to refactor some of the data processing to utilise this as well.
     
  27. Santa36

    Santa36

    Joined:
    Dec 1, 2018
    Posts:
    25
    How many tiles have you used? I had a similar thing with 64 tiles, I converted them all to scenes that seem to work better, but as Richard said if you want to be on the save side try the new workflow like postet in the Video.
    Don't forget to save once in while so that you don't lose your progress.

    After I used Splatmap the RAM was at 8 to 13 gigs, after some time it got back to roundabout 5 to 6 gig. Just open the Taskmanager to see how much RAM is occupied and close Programm like Browsers or other things before generating.
     
  28. Santa36

    Santa36

    Joined:
    Dec 1, 2018
    Posts:
    25
  29. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    I'm working on automatic terrain flattening under buildings for the next update.
    Here's a "Before & After" example:

    The terrain slopes down from left to right, so the back of the house isn't touching the terrain in the first screenshot.
    But with Flattening applied, the terrain is aligned to the bottom of the house.

    without.png
    with.png
    Note that modifying terrain in this way will be completely optional, of course.
    It's perhaps better suited to larger buildings and was developed mainly for upcoming procedural building generation where CityGen3D will generate larger buildings direct from OSM data, but this shows it working with the roadside house prefabs.

    For smaller buildings you can approach it in a different way and not use terrain flattening at all.
    Below is an old screenshot where a building has been designed with a lower level and steps to the doors. Every house in the screenshot is the same mesh.

    When spawning roadside objects, CityGen3D will always align them to the terrain across the prefabs y-axis at local 0.
    So here I designed steps leading up to the doors of the house so there's never any gap between the houses and the terrain, and no need to modify original heightmap.

    steps.png

    Hopefully this gives you a few ideas on how you can approach the issue of aligning buildings on uneven terrain.
    But having the terrain flattening option should be very useful in future and give you more options, especially for larger buildings.
     
  30. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    When the next update of CityGen3D?
     
  31. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    0.63 was released earlier this month. That has the terrain flattening feature and faster road generation.

    Next update will be 0.7 and will include a new module for mesh extrusion, to create railway, walls, fences, hedges, etc.
    So it's quite a big update and will likely come out early next month. But I'll give out more info on that before next release so you can see progress.

    If you are asking for a particular bug fix or feature please let me know and I'll try and include in next update if possible.

    Note that both the terrain flattening and mesh extrusion features are prerequisites for getting CityGen3D to be able to generate buildings direct from OSM data. So that's being worked towards as well.
    We also have the BuildR2 integration in progress, but a big update is planned for BuildR2 so just seeing how that pans out before first release. However there'll definitely be a OSM to 3D building solution for CityGen3D over the summer, one way or another.
     
  32. DiscoJustice

    DiscoJustice

    Joined:
    Aug 21, 2013
    Posts:
    15
    This is an amazing project, well done for everything you've done so far!

    I've not made much progress yet, as I'm getting an error on the "Generate Highways" step, causing the bar to hang. I'm using Unity 2019.1.7. Any ideas?

    NullReferenceException: Object reference not set to an instance of an object
    CityGen3D.ShapeNode.SetFriendNode (CityGen3D.Shape fromShape, System.Single maxRadius) (at C:/Dev/CityGen3D/CityGen3D/Core/Shape/ShapeNode.cs:112)
    CityGen3D.ShapeMesh.CalculateSegments () (at C:/Dev/CityGen3D/CityGen3D/Core/Shape/ShapeMesh.cs:538)
    CityGen3D.ShapeMesh.Extrude (CityGen3D.Shape outer, CityGen3D.Shape inner, UnityEngine.Transform parent, System.Single yAxis, System.Collections.Generic.List`1[T] prefabs, System.Boolean orientation, System.Boolean isStatic, System.Int32 layer, System.Boolean closed, CityGen3D.Generator generator) (at C:/Dev/CityGen3D/CityGen3D/Core/Shape/ShapeMesh.cs:68)
    CityGen3D.Highway.Construct (System.Int32 _index, System.Collections.Generic.List`1[T] _points, System.Boolean _orientation) (at C:/Dev/CityGen3D/CityGen3D/Core/Generator/Highway.cs:83)
    CityGen3D.Highways.ProcessHighways (CityGen3D.Landscape landscape) (at C:/Dev/CityGen3D/CityGen3D/Core/Generator/Highways.cs:171)
    CityGen3D.Highways+<GenerateHighways>d__15.MoveNext () (at C:/Dev/CityGen3D/CityGen3D/Core/Generator/Highways.cs:59)
    Unity.EditorCoroutines.Editor.EditorCoroutine+YieldProcessor.MoveNext (System.Collections.IEnumerator enumerator) (at Library/PackageCache/com.unity.editorcoroutines@0.0.2-preview.1/Editor/EditorCoroutine.cs:79)
    Unity.EditorCoroutines.Editor.EditorCoroutine.ProcessIEnumeratorRecursive (System.Collections.IEnumerator enumerator) (at Library/PackageCache/com.unity.editorcoroutines@0.0.2-preview.1/Editor/EditorCoroutine.cs:133)
    Unity.EditorCoroutines.Editor.EditorCoroutine.MoveNext () (at Library/PackageCache/com.unity.editorcoroutines@0.0.2-preview.1/Editor/EditorCoroutine.cs:114)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)
     
  33. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Thanks very much for supporting the project!

    Have you tried generating the default location (currently Watton-at-Stone, UK)? May be worth a try just so we know you are all setup correctly.

    If all is well there, please send me the lat/lon coords you are trying and area size so I can attempt to reproduce.

    If the default location also gives similar errors it may mean something isn’t setup correctly and we can work out what’s going on.
     
  34. DiscoJustice

    DiscoJustice

    Joined:
    Aug 21, 2013
    Posts:
    15
    Thanks - the default location works fine.

    The location I'm trying is:
    Lat: 52.9010314941406
    Lon: -1.06927871704102

    The size is 3x3 terrains (ie 3072m x 3072m). Some of the terrains work, but one ("Landscape 102" as named by the generator) gives the above error.
     
    CityGen3D likes this.
  35. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I give up on CityGen3D V0.63. It stopped responding when trying to generate 3D model of Staten Island, NY.
     
  36. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Thanks for the info, I've managed to reproduce this.
    I will work on a fix this weekend and get another update out with this in early next week.
     
  37. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Is this after clicking "Process" on Data window?
    Staten Island is really big to process in one go.
    Have you tried to work on smaller areas and build up the scene in smaller chunks as discussed in post #226?

    When I tried it myself (16km x 16km), it did work, but it does take a really long time to process all the data in one go.
    That's why I spent time on adding in better support for a segmented workflow, where you can work on smaller areas and build up very large scenes in smaller chunks.
    If you need help with that please let me know and I can try and walk you through it.

    I mentioned I'd improve progress bar feedback during data processing, which I haven't got round to yet. I'll try and include that in the upcoming hotfix as well.
     
  38. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I used 4m X 4m area and CityGen3D stopped responding after clicking "Process" on Data Window.
     
  39. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Please could you give me the lat lon coords you are trying and I’ll take a look at this over weekend as well.
    I have a few ideas on what may be happening but need to test it out.
     
  40. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    Top: 40.6544
    Left: -74.2668
    Right: -74.0300
    Bottom: 40.4913

    I got the lat lon coords from Open Streets Map
     
  41. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Sorry I meant the Latitude Longitude as shown next to the sliders on the Data panel.
    (When you click a location on the map in CityGen3D it updates the sliders for you).

    With any bug report it's great to get the coords and area size you selected if possible, because it
    allows me to enter the same location and experience exactly what you are seeing, just like I did with DiscoJustice's issue.
     
  42. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    40.49553,-74.25711 (lower-left corner of Staten Island, NY)
    4X4 terrains
     
    CityGen3D likes this.
  43. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Please try this Jeff:
    • Go to Data panel and click the Surfaces tab.
    • In the Parsing section find the entry Place - Island and delete it by clicking the [X] button to the right of it.
    • Remember to select the US East Coast coastline file as the Coastline JSON on Location panel.
    • Now when you click Process you should find CityGen3D processes the area for you successfully. (On my PC it takes around 90 seconds).
    I'll be updating the default CityGen3D prefab in next update that has this removed.
    This is left over from when we didn't have the separate coastline processing, but OSM relations like this can be ignored now because we get the data from the coastline file.

    staten_island.png
     
  44. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    Following the steps above, I created 16X16 terrains in one go and it worked after about an hour. Because the 16X16 terrains didn't cover the whole island, I created 2X2 terrains but it was slow, each area took over an hour. If I could create 20X20 terrains in one go, I would be very happy.
     
  45. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Are you talking about just the time taken after clicking "Process"?
    It shouldn't take that long for 2x2 area size. Perhaps there's something else to fix.

    I will likely change the UI so the Area selection can be whatever you want it to be and not limited to 16x16.
    Although you can probably get around this already if you really want to by selecting the CityGen3D prefab in your scene and changing the Area value in the Data component in the Inspector.

    But I think there are big advantages to working on smaller areas at a time and it would perhaps be best to work out why the smaller areas are still processing so slowly for you. So I can look into that if you give me a specific example of a 2x2 area that took an hour.
    (Make sure "Place - Island" has been removed from the Data->Surfaces panel as noted previously, because if you add a new CityGen3D prefab to your scene this will still be there unless you remove it again and would slow down the processing considerably. As I say, I will remove that from the prefab in future release so it wont appear by default anymore).
     
  46. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    682
    Beta v0.64 has been released.
    This includes a fix for the error caught by @DiscoJustice

    There's also a few minor improvements to the Location UI including wider latitude/longitude input boxes; slider for area (now goes up to 32 tiles) & axis; and a processing filter instead of multiple checkboxes.

    location_settings.png
    location_processing.png

    Bigger update coming next month, all being well, to take advantage of the new "Features" processing.
    Some previews coming for that shortly
     
  47. trig-ger

    trig-ger

    Joined:
    Sep 1, 2018
    Posts:
    31
    Hi.
    Will automatic object generation after zoning (zoning sketch drawing) be available after the implementation of "More control over editing map in 2D", something like here (SketchaWorld, very similar btw):

    ?
     
    CityGen3D likes this.
  48. trig-ger

    trig-ger

    Joined:
    Sep 1, 2018
    Posts:
    31
    I have a very coarse-grain game view (unlike scene view):
    Screenshot_20190625_181652.png

    How to make it more hi-res?
    (looks like the integrated graphics card is used for some reason, however NVIDIA is set to higher priority)
     
    Last edited: Jun 25, 2019
  49. DiscoJustice

    DiscoJustice

    Joined:
    Aug 21, 2013
    Posts:
    15
    Thank you, working well now!
     
    CityGen3D likes this.
  50. DiscoJustice

    DiscoJustice

    Joined:
    Aug 21, 2013
    Posts:
    15
    It looks like your zoom level (the small "scale" slider just above the game view) is set at 1.63. Dragging this back to 1.0 should fix it.
     
    CityGen3D likes this.