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:
    681
    Yes CityGen3D now supports streaming of large environments via the Landscape Manager component which loads your terrains on demand at runtime using the Unity SceneManager API.

    There’s more info on setting this up in the CityGen3D manual which is available from the website.

    I’ve not forgotten about the Andorra screenshots!
    I’m going to use them to show off a new feature in 0.82 as soon as that’s ready.
     
    Lars-Steenhoff and w34edrtfg like this.
  2. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Version 0.82 not too far away now so sharing some screenshots of an Andorra test to demonstrate how CityGen3D works with a hilly environment, as requested originally by @w34edrtfg

    I'll follow this up in a few days with a more detailed explanation of one of the new features: Auto Heightmap Levelling for roads. I'll likely release a video as well of me driving around a bit.

    One of the things I really enjoy with CityGen3D is the organic environments it produces like this, that are genuinely exciting and fun to explore - and that my limited artistic ability could never produce. I don't know if there's a rally stage in Andorra but it looks well suited!
    I dropped the sports car from other demos in favour of this pickup truck as it was more suited to the terrain.:)

    Note that that everything you see (apart from the car) was generated automatically within Unity using the CityGen3D interface. No additional coding or object placement.

    screenshot0.png

    screenshot8.png
    screenshot4.png
    screenshot17.png
    screenshot23.png

    Notable changes in v0.82 will include:
    * Improved coastline support and instructions for how to generate coastline data files for your location anywhere in the world.
    * Improved terrain detail prefabs.
    * Improved terrain textures (added normal maps).
    * Reorganised project into two libraries to better split up Editor functionality and code that needs run-time access. An important first step in tidying up the API.

    Obviously things will look more city-ish from v0.9 when the procedural buildings should finally make an appearance.
     
  3. DJ_Design

    DJ_Design

    Joined:
    Mar 14, 2013
    Posts:
    124
    Curious why this isn't on the asset store? I've had problems buying assets from external sites, them going offline or worse.. when (if at all) do you expect to make an offical marketplace appearance?
     
    CityGen3D likes this.
  4. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Thanks for your interest in the project.

    Up to now, it's simply a case of it not being ready.
    For a project this size I thought it was important to do a smaller scale "early access" release so I could get initial feedback and iron out some issues first.
    The Beta over the last year has been really worthwhile and has helped to create a really exciting tool.
    I can't wait to see what people do with it when it reaches a wider audience!

    Although even without the exposure the Asset Store brings I've been really encouraged with how far and wide it's reached. I'm aware of it being included in two university research projects around Europe, for instance.

    So current plan is to submit for Asset Store release around Easter.
    But given the scale of the project it could be a while after that before it gets approved for release, but I'll keep everyone updated in this thread.
     
    Stephen_O and DJ_Design like this.
  5. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    72
    @CityGen3D Oh i also forgot to share this link with you:
    https://github.com/maajor/OSMTrafficSim
    (not mine)
    This guy already builds a performant traffic system for unity using OpenStreeMaps. So maybe it's easy to integrate in your creation.
     
    CityGen3D and hopeful like this.
  6. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Yeah I came across this a while back, really useful resource.

    Although any official CityGen3D Traffic add-on module will likely not appear for some time, I’m currently working on some useful functions that you can call for easy access to road lanes that you can use for navigation waypoints.

    This will allow you to start hooking up CityGen3D scenes to your own traffic systems (or third party ones).
     
  7. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Video from a recent Andorra test:



    I was only on keyboard controls this time so driving not the best I’ve ever done... :)
     
    Stephen_O and Lars-Steenhoff like this.
  8. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    So one of the new features that I'm quite excited about coming up in v0.82 is automatic road levelling.
    This feature was used in the recent Andorra test.

    This makes hilly environments with roads much more realistic and turns a default real-world heightmap into something suitable for high detail rendering, especially when dealing with roads on hills.

    Here are two images to demonstrate what it does.
    The first image shows the default heightmap from this location based on real world heightmap data.
    The camber along the road is really extreme and completely unrealistic. That doesn't make the real world heightmap data wrong, but you have to keep in mind that publicly available heightmap data is sampled around 30 metre intervals, which obviously can't consider all the detail required around roads and such like.

    before.png

    So how do we make the heightmap suitable for close-up rendering, such as in a driving game?

    Well a few button clicks away is the second image which has had auto road levelling applied and the terrain retextured based on the new heightmap. Much easier to navigate!

    after.png

    Please take a look at this video for a closer look on how roads can easily be generated around hilly environments in CityGen3D, to create really exciting environments. The earlier video in this thread shows off more of the Andorra environment that was created in the same way.

     
    Last edited: Feb 12, 2020
    StevenPicard likes this.
  9. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    Hey, great asset. I bought it a while back and have been following your progress with interest.

    A couple of thoughts. I have done some prototypes with pulling in UK data from Open Survey, including the DSM/DTM heightmaps which go down to 50cm, and their Open Zoomstack free tier product which I have found is significantly more up to date with building footprints than OSM.

    Here's an example of just dumping the DSM ASC data into a Unity terrain heightmap for my street, for example.

    VisualizeOpenZoomstackData.png

    And here's the footprints from Open Zoomstack, and a fairly crude attempt on my part to use the height variance between DSM and DTM, inside the bounding of the footprints, to create a building shell mesh of my house. A lot of those footprints are missing from the OSM data, incidentally, although oddly enough some of the road naming was better in OSM in a few stray cases I checked.

    2VisualizeOpenZoomstackData - PC, Mac & Linux Standalone - Unity 2019.3..png

    Anyway, do you have any plans to integrate importing those data sources into the asset? (And I would presume there other popular data sets out there for the U.S. and other countries, so perhaps some sort of modular framework where such data could be added as needed might be cool.) It'd certainly go a long way to saving me a lot of time generating the city detail using your asset, as long as I could mix and match the data sources to get the best data.
     
    CityGen3D likes this.
  10. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Hi,

    Thanks for supporting CityGen3D and for your feedback.

    The feature set up to first full release is pretty much locked down now.
    So focus over next few months will mainly be on building generation and map editing functionality.

    After full release, the direction CityGen3D will take will largely be based on demand from users like yourself, so it's always really interesting to hear the different ways people are using it and for what type of projects.
    Naturally the more people mention something, the higher up the priority list it will go!

    Following your message I have downloaded some Ordanance Survey data for experimentation.
    However, I can't promise anything will come of it in the short term, because the OSM to Unity parsing is a huge part of what CityGen3D does.


    Although the higher res heightmap is quite interesting, it does seem like it combines natural terrain with manmade objects, which in most cases would perhaps be undesirable.

    One of the really great things about the NASA heightmap data is that it's detailed enough to have recognizable features, without the artifcats you get from higher resolution.
    So you have something useable straight away, with the option to add your own detail to make it more realistic, either through CityGen3D options (like the new road levelling feature, which has just been released in v0.82) or other tools compatibile with Unity terrains.

    However, I certainly think there's benefit to hi-res heightmaps outside of urban environments, for recreating real world natural features in high detail.
    A few users have contact me about wanting to use their own privately sourced hi-res heightmaps in CityGen3D, so it may be a case of trying to make that a bit easier in future, if possible.

    The tool already supports heightmaps from multiple sources, so this is perhaps a more feasible short-term aim than embedding something like Ordanance Survey data as a primary data source, but I will certainly do some investigation in this area.
     
    Last edited: Feb 17, 2020
  11. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    No worries, I understand. I have been especially looking forward to seeing what you come up with for building gen, so I will hold my breath eagerly for now. :)

    Yes you are correct that the DSM map does contain manmade objects such as cars, buildings, and the like, as well as foliage. However the supplementary DTM map they also provide (which you can see in my second screenshot in the last post) has had all of that subtracted out using some sort of special LiDAR point cloud manipulation magic over at Open Survey, so that all that's left is the ground terrain level (including calculated flattened levels under buildings). I've not been on their site for a while, but as I recall the Open Survey maps can be downloaded as either date-stamped tiles or as composite data spanning a number of LiDAR runs, with the composites being the ones I used in my prototype. Anyway the file formats for both types of map are simple ASC files which are just a header and then a list of doubles pretty much.

    If I can find a format description somewhere online, I might try and write a tool which converts that .asc output into equivalent .hgt files and see if that works - are the 30 metres/1024 values hardcoded when you grab the SRTM data out of the .hgt files, or do you think there's a chance it might work with tossing in a variable sized .hgt?
     
    CityGen3D likes this.
  12. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    Hmm never mind. I read up on the SRTM file format and I see it caps out at fixed sizes of either 1 or 3 arc seconds, so the format wouldn't be directly translatable to ASC files anyway. I've got a few ideas about how the two data sets could be made to co-exist which I might have a tinker at one day, but I'll concede that just sticking with SRTM is probably the right approach for CityGen3D.
     
    CityGen3D likes this.
  13. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Thanks for the explanation. I'll check out the OS DTM data when I get chance, see if I can support it as an import option.

    But yeah, I've found the SRTM data to be really good in general. I may be able to improve this integration further so it downloads the required hgt file for you automatically as well.

    The building generator is really fun to work on and I’m making good progress.

    Over the years I've prototyped several different approaches to this, but I've got a direction I'm happy with now.
    As with all CityGen3D modules, most of the setup will just be via the relevant tab on the Generator window and at it's most basic you'll just need to click the Generate button and it will do all the work for you.

    A "Blueprint" gameobject will define a particular building style with various settings including a material reference.

    You then match up different blueprints to OSM building instances via settings, in much the same way you assign entities with entity rules, or features to feature rules.
    This allows you to match up different blueprints with buildings types, or buildings of different sizes and heights.

    First release will be focused on exteriors, and only support flat roofs. This makes it perfect for generating large office skyscrapers and residential blocks to match up with OSM data, where instantiating a small house prefab using the roadside spawning system isn’t really suitable.
    Eventually I hope to support different roof types so you'll be able to use the same system to generate smaller houses.

    The actual building facades are geometrically very simple extrusions, following the shape from OSM data, and built from a single atlased material for each blueprint. Each material will have walls, windows and doors all in a specific style that you can match up appropriately with certain OSM building types.

    The idea is to provide a way of generating good looking buildings with no complex mesh geometry, with all facades for a particular building type created from one large material that supports several variations on the same theme.
    All the geometric detail will come from the material heightmap which gets tessellated close up using custom shader (on supported hardware).
    But even on low-end hardware the buildings look pretty good because of the PBR material (shiny reflective glass, rough brick walls, etc), and are performant because of the low poly count and single atlased texture.

    It also generates a LOD1 version of the building mesh with reduced polycount and sets up the LOD Group for you. The lower detail mesh looks almost identical to the LOD0 mesh at distance, because it's basically an identical shape, just with a lot less polys as it wont need to be tessellated.

    I'll show off some more specifics on the building generator soon.

    BuildR3 is also in Beta, so I’ll be working on providing a working sample of how to use it with CityGen3D, as an alternative to the built-in procedural building system.
    This will serve as a demonstration for how you can use the powerful CityGen3D API to access map data for hooking up to third party assets.
     
    Last edited: Feb 24, 2020
  14. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    Sure, that would be great if it's possible. Those data sets come in an Eastings/Northings CRS per the UK National Grid so they won't translate directly to lat/long the way SRTM does. I'm not sure which projection library you're using or if you've rolled your own, but all the good ones like DotSpatial and GDAL do conversions between different CRS. I've tested most of them, and the one I ended up settling on was GeoUK, which I think you can find on nuget. So it shouldn't be too hard to write a version of a height eval function that takes in lat/long and converts to easting/northing and then does the eval lookup of the correct height cell that way.


    That would definitely be a handy feature.

    I'm really looking forward to it. All of that you've described sounds amazing.
     
    CityGen3D likes this.
  15. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I tried to use CityGen3D version 0.82 this morning but I found out that USA North East coastline is missing from the list of coastlines. I need the json file.
     
  16. CityGen3D

    CityGen3D

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

    I've only ever packaged UK & Ire coastline with CityGen3D releases (at least deliberately), although I do recall creating a US coastline file at some stage.

    Either way, the latest version actually includes instructions on how to generate coastline files for your project. Please see the updated manual for more info.

    If you have any problems creating it please let me know.

    Edit: I found the old one I created for you, but that will no longer work. The format has changed since then to a more standard GeoJSON format in order to make it easier for users to create them manually. So it should be possible to create a custom coastline file by following the instructions in the manual, but as I say, if you have any problems with that, send me a message and I'll try it for you.
     
    Last edited: Mar 2, 2020
  17. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I was able to create the coastline file for NYC area. When using the generator, after I generate splat maps, I couldn't generate other things until I unselect and then select landscapes. Is this a bug?
     
    CityGen3D likes this.
  18. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Oh good, happy to hear you were able to generate a new coastline file.

    Yes what you describe is a known UI bug. For now you have to deselect and reselect the Landscapes, which is a bit annoying.
    I’ll fix that up before next release
     
  19. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    When will the next version of CityGen3D that will generate buildings from OSM data be released?
     
  20. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    It's pretty much the main focus at the moment.
    I hope to release v0.9 by the end of the month, which will be the first iteration of it.

    Then it will be a case of tidying up some lose ends for a Asset Store submission, and then continuing to develop the procedural building generation and map editing functionality post release.

    Here are some screenshots showing better than expected progress on adding hipped roofs, and on-going development of some residential building materials.

    hipped_roof.png
    window_material.png
    door_material.png
     
    Santa36 likes this.
  21. Santa36

    Santa36

    Joined:
    Dec 1, 2018
    Posts:
    25
    Could you show of this building (51.833706, 12.238140) in Citygen3D thats the area I'm interested in.
     
  22. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Sure, here's a few screenshots from around this location.

    These large buildings are recognizable by shape and size, although as mentioned previously, I'm currently working on adding variation to the building materials to account for different building types, so all buildings look the same until I've finished those.

    (This stone façade works really well for old government buildings and museums, less so for large residential blocks!)

    So by the time v0.9 is ready there'll likely be a more appropriate residential block building style to generate these buildings with.

    screenshot0.png
    screenshot1.png
    screenshot2.png
    screenshot3.png
     
    TerraUnity, chmodseven and Santa36 like this.
  23. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I'm confused about the Landscape Manager. A screenshot on page 22 of the PDF manual shows the "Environment" folder with "Sun" and "Wind" folder under the "Environment" folder. I don't have these folders. How can I use the Landscape Manager? I created 19 groups of 16 terrains for my city - that's about 300 terrains!
     
  24. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Hi,

    If you start your project by loading the New City scene, the environment object with the Landscape Manager is included for you.

    Alternatively you can find the Environment prefab in the Resources folder and add it manually to your main scene.
    Then follow the instructions as detailed in the manual.

    I’ll amend the instructions to make it clear you can add this prefab manually if required.
     
  25. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I found "Environment" and "FreeCam" Prefabs in "New City" scene. I copied them to my scene. When I run the scene, I don't see anything! How can I fix it?
     
  26. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Imagine I had downloaded a location called "London".
    I would have a main scene called "London", and then I'd Generate Terrains with the Save As Scenes checkbox active on Generator-Heightmap panel, which would give me several scenes named London with a tile number eg "London 1", "London 2", etc, for each of my terrains.

    Here's what the landscape Manager component will look like by default:
    landscape_manager.png

    All I'd need to do to setup the scene streaming to work with my London location is:
    • enter "London" as Start Scene
    • tick the Scene Streaming checkbox
    • make sure Axis and Terrain Size settings are the same as what you used when downloading the data.
    • ensure all scenes are added to Unity Build Settings
    • add each associated scene to the Available Scenes list by clicking Register Scenes, which checks for associated scenes from your build settings.

    Then when you click play, Unity will load the scenes around your MainCamera.
    Note that scene streaming performance in Unity is vastly improved in stand-alone builds compared to in Editor.

    If you still have issues with setup, please send me screenshot of your Editor setup (specifically Unity Hierarchy, Build Settings, and Landscape Manager component).
     
    Last edited: Mar 9, 2020
  27. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276


    I am confused about the "Axis" setting. What should I set it to?
     
  28. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    100 is the default and looks like it will be fine in this case.
    It just means how many terrains can fit along one row in a grid. So with an axis of 100, Landscape 0 is [x = 0, y = 0] and Landscape 100 is adjacent to the north at [x = 0, y = 1].

    All your scenes have the prefix “statenisland01", so this is what your Start Scene should be called. But I can see that it's called "statenisland" in the Hierarchy. So I think that's where the issue is.

    Basically all scenes for a location need to share the same name (set as Start Scene). Each landscape scene belonging to that location has the name followed by a number identifying the tile.
    So I think to fix, all you need to do is rename the scene you currently have loaded (the one with your landscape manager and data in it) from "statenisland" to "statenisland01" and set the Start Scene variable to "statenisland01" in the Landscape Manager.

    Edit: I also notice you have a Directional Light in your scene. The environment prefab actually contains one of those (called Sun), so you can probably delete one of them.
     
    Last edited: Mar 10, 2020
  29. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Some more screenshots showing residential buildings procedurally generated from OpenStreetMap data.

    screenshot0.png
    screenshot1.png
     
    StevenPicard likes this.
  30. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I renamed all of the scenes to statenisland01 and almost worked but it was very jerky in play mode. When trying to build and run the project, I got error messages shown in the image below:

     
  31. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    This can be fixed by ensuring CityGen3D.EditorExtension.dll is excluded from the build.
    Locate it in the Plugins folder in your project from within Unity project view.
    Click on it and you’ll see an option to exclude it from standalone builds.

    import_settings.png

    Apply the new settings to exclude it.
    Then if you build again it should be fine.

    (It may be that I can set that automatically by ensuring it's set appropriately before building the Unity package, so I'll check that for next build, but I'll mention this in the docs anyway for future reference).
     
    Last edited: Mar 11, 2020
  32. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    I tried to build the project after changing the settings but I still get error messages.

     
  33. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    I’ve not seen that before but it may be linked to an unsuitable build output location.
    Ensure your build output folder is in an empty directory away from any VS or Unity project.

    Edit: I found this thread which may help to explain further if still stuck
    https://stackoverflow.com/questions/56844138/unity-build-errors
     
    Last edited: Mar 12, 2020
  34. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    How can I set up Edy's Vehicle + Physics in CityGen3D project?
     
  35. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    CityGen3D generates Unity terrains and spawns normal Unity gameobjects, so in the vast majority of instances third party assets will work alongside it without any special setup required.
    (I've had no problems with popular assets like Edy Vehicle Physics, MicroSplat, GPU Instancer and BuildR).

    As a general rule, the only real scope for conflict with other assets is with Unity Layers, because CityGen3D uses them quite extensively during setup to differentiate between different map objects.
    So if anyone does run into an issue someday, that's the first area to check.

    But you should certainly be able to integrate Edy Vehicle Physics into a project using CityGen3D just by following normal setup procedures for that asset. Let me know if you run into any specific issues.
     
  36. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Another façade material which will work well for office blocks and commercial buildings

    office_block.png
    office_block_door.png
     
  37. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276


    As shown in the image above, the hills look more like small mountains. The hills should be more "flatter". How can I fix this? I used NASA SRTM data.
     
  38. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    If you don't believe the heightmap to be an accurate representation of the area, please send me more details about your location and the Peak and Nadir values as shown on Generator-Heightmap panel.

    CityGen3D has various heightmap modification options that can be auto applied via this window, such as the Levelling function which can level out the roads for you:


    If you want to make manual adjustments to the heightmap, then the Unity Terrain tools will work as normal on a CityGen3D generated terrain.
     
  39. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    In Open Street Maps or similar website, go to Grasmere neighborhood in Staten Island, NY near the bridge to Brooklyn. The Peak and Nadir values are 121 and -20.
     
  40. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    I think you might just be misjudging the scale of the hills, they are very small.

    I've generated the same location and you can see when at road level the horizon shows only minor elevation changes. No steep inclines or anything that could be thought of as mountainous.

    The second screenshot below is looking north from Mills Avenue at ground level.

    If I went on to generate the roads, buildings, and trees (etc), you'd barely notice much elevation change moving a character around the location.

    grasmere.png

    grasmere2.png
     
  41. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    What height map data did you use for the areas in the images above this message?
     
  42. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    NASA SRTM (N40W075.hgt)
     
  43. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    That's the same file that I was using. If I click on a landscape so that it shows up in the Inspector and choose the gear icon under the terrain section, I can set terrain height to 1 in the mesh resolution section, flatting the terrain. I found out that the southern half of Staten Island has terrain height of 48 and northern half has terrain height of 141. I tried to use Edy's Vehicle Physics Pro but when I start the game, the truck falls down before the terrain can be generated. If I load a landscape scene before running the game, the truck is on the terrain but I think that scene streaming doesn't work because other scenes (landscapes) don't load during run time. I enabled scene streaming under landscape manager section. I also enabled delayed physics. Is it possible to have the game delay the code for the truck until the terrain can be generated when I run the game? I saw "WaitForSeconds" and "WaitUntil" in the docs I need to write code.
     
  44. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    What I could do is add a height scale slider to act as a multiplier for easily reducing or increasing height range across all your terrains.

    But downloading and applying a heightmap is optional, so if you want a completely flat terrain then you can just not add a heightmap to begin with.


    Is there a terrain loaded at runtime directly above or below the car?

    If you have Scene Streaming and Delayed Physics checkboxes active then gravity shouldn’t come into effect until your local scenes have been loaded at game start. You shouldn’t have to write any additional code for that.

    Remember that scene streaming loads terrains around the tagged MainCamera.

    So ensure you only have one in your scene, it’s possible you have added another one as part of any car controller and you can delete any other camera in your project.

    If terrain directly below car is being loaded but the car is below the surface this means the car is instantiated/ positioned below the surface (move it higher) or it’s falling through the terrain (check physics collisions settings).
     
  45. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    FYI I spent a little time tinkering with overlaying the DSM/DTM 50cm heightmap data I mentioned a while back, on top of the SRTM data used by CityGen3D.

    Here's a raw DSM map from my earlier prototype. This covers a 1km squared block at 50cm accuracy, i.e. the heightmap is 2000x2000 (2049 in the Unity terrain of course).

    rawdsm.png

    In CityGen3D I created a simple medium landscape (512x512) using the defaults for the most part. The lat/long origins and sizes of the two heightmaps obviously differ, but with some geo calcs I was able to convert between them. It's a little hard to visualize but the CityGen3D terrain roughly overlaps the center right segment of the larger map:

    overlap.png

    With that I was able to splice the two together:
    dsmoverlay.png

    Now since the DSM has man-made objects that we don't want, next I simply swapped over to the DTM (terrain only) heightmap instead:

    dtm.png

    And for the final touch, re-ran the road levelling function of CityGen3D on top of the new data:

    levelled.png

    Anyway, no feature requests or anything, I just wanted to share what I was able to do with the additional high detail heightmap data as a proof of concept that it can be made to co-exist with the SRTM data. On this test I didn't mess with the heightmapResolution either, for example in theory it would be possible to double it to 2049 to retain the full heightmap info quite easily. I did try a quick pass at that, but noticed that the generator functions seem to revert back to the original resolution and produces some strange results. Anyway, I hope this has been interesting reading for someone - I love playing with this sort of stuff. :)
     
  46. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Thanks for sharing!
    Always good to see what people are up to with CityGen3D :)
     
  47. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Here are some screenshots from the v0.9 test build.
    Getting close to how I imagined it when I first started on the project... :)

    All the buildings in this scene were generated automatically by CityGen3D from OSM data, so they're not prefabs.
    I'll share some UI screenshots soon too.

    screenshot0.png
    screenshot2.png
    screenshot4.png
    screenshot5.png
     
    Astirian, Freznosis, Neviah and 3 others like this.
  48. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    Looks fantastic, I can't wait to try it out. I take it you're using building:levels and roof:shape to get the buildings looking accurate like that, but are the textures also using some sort of mapping to the :color and :material tags? Also curious about how you're putting the windows and doors in - I seem to recall there's an entrance: tag or something like that but I don't remember seeing anything about placement of windows as such when I was looking.

    Really good work, this is going to be the best city tool ever!
     
    Astirian, CityGen3D and Santa36 like this.
  49. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Yes, "building:levels" is perhaps the most important OSM tag for buildings because this gives you a realistic height of the building.

    But aside from that, the appearance of the buildings in this scene is just inferred from the simple rules I defined in the UI, in much as the same way you can hook up mesh extrusions to OSM data on the Features window.

    I'll take you through the basic workflow, as it will help me write up the docs before release. :)

    On the data panel you define different building types and match them up to OpenStreetMap key/value tags as shown in this screenshot:

    data_buildings.png
    This bit is actually already in CityGen3D v0.82 for buildings (so you can see it in your current build), as it is for other things like Features and Entities.
    When you click Process on the Data-Location panel, CityGen3D reads the OSM and matches everything up using this data and your new 2D map will reflect the changes. You should make sure buildings is ticked on the processing filter to get buildings to appear on your 2D map - it will be off by default in v0.82 (because you can't generate them yet).

    This is where you could go into more detail if you wanted to, matching up building material tags to different blueprints, although I didn't do that here. (For example, explicitly pairing up the glass office block blueprint with the "building:material - glass" XML tag).


    When it comes to the Generator, you match up the building types you defined earlier with different Blueprints. A Blueprint is a prefab that defines exactly how each storey in a building instance is created, by limiting what textures can be used in different circumstances.

    generator_buildings.png

    I'll talk more about this another time, but that's basically how CityGen3D knows to create doors on the ground floor and only one drainpipe.
    So much of the complexity is hidden away by default and at it's most basic level you just match up building types to an appropriate blueprint on this tab.

    For example, in this demo scene, the tall building is using the Glass office Block blueprint because it falls within the height range allowed for that blueprint type. I'm going to make this a bit clearer before release, but the slider value has a minimum height range of 50 meters for the first rule that matches up to that blueprint. So any building not tall enough goes on to the next rule to see if it passes the criteria.

    I'm currently working on getting CityGen3D to identify entrance nodes and use them appropriately, although this may not make v0.9.
    In the absence of this data (it's not set for most buildings anyway), CityGen3D uses the Blueprint settings to know when to place doors.
     
    Bartolomeus755 and chmodseven like this.
  50. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    Thanks for the insight into the inner workings. It has got me thinking about the ways I am intending to use CityGen3D for my project and I have a few questions/suggestions.

    1. Presets or some sort of config saves. For the Data and Generator setup done by the user in the inspector, it'd be handy if there could be a user-friendly way to save and reload settings. At the moment, unless I've missed a serialization button on one of the tabs or something, there's only the option of going into each object one by one and making a Unity preset by hand. Anyway the use case I'm thinking of there is mostly around where the user has carefully curated a bunch of these settings and tags and so on, and wants to be able to use the same config (or a slightly tweaked one, to better match the particular grid of the city) without having to key in all the same tags etc again. It'd also potentially allow for some degree of "community modding" where sets of data tags or generator assets could be shared and swapped in and out for different stylised looks.

    2. Will there be a possibility for the buildings to allow for post-generation tweaking per building? By that I mean could there be something like a Building script sitting on each generated object (similar to your Highway script on those which for now just has the points) which maybe exposes the variables associated with the generator's "decisions" and which the user could then tweak to alter the various appearances such as height, roof shape, door position, materials, etc., and perhaps a button to then regenerate just that house. So sort of like a manual override on a per building basis. The reason I'm hoping it may be possible is since it sounds from your description like you're generating these factors based on defined rules anyway, so adding a tweak-and-regenerate component to such individual objects (maybe optional, with a checkbox when you click the main Generate?) seems like it could be useful. For example, I wrote a tool that opens a little Google Streetview cubemap aligned to the lat/long of the scene, and one of my goals with using CityGen3D would be to look at a given building using that and then, ideally, tweak its generation settings to more closely match the real one in size/textures/door placement/etc. I wouldn't want to spend more than a couple of minutes per building, so anything that can boost productivity and take advantage of the generative power you've built already would be great.

    3. Something I've been wondering about the OSM data - do you only refer to that in the Data tab, to create the 2D map and store the data such as building tags etc, or does the Generator tab also draw from that OSM data afterwards as well? The reason I'm wondering is that one of the directions I'm considering for my project is to create some sort of Frankensteined city made up from carefully selected sections - e.g. a business district, factory area, docks, suburbs, etc., possibly even meshed together from different cities entirely - and handle the seams using photoshop to align the 2D map edges you're processing in Data before pumping those through Generator. And aligning the SRTM terrain seams using Unity terrain tools, of course. Does that sound like it would be feasible with the approach you have implemented? I know you've talked about the ability to generate maps based on user-provided 2D images in the past, so I'm guessing there is the right amount of separation between the two parts of the tool already, but it would be nice to know for sure. EDIT: Another use case here that I've thought of is being able to export an image from a GIS such as QGIS, and then align the style colours from that with the tags-to-colours in CityGen3D. That would actually be perfect as then I can potentially use the superior OpenZoomstack data directly instead of OSM. Again, it all depends on how you've approached the use of the 2D map image coming out of Data, and whether or not that can be swapped out or enhanced prior to its use by Generator.
     
    Last edited: Mar 23, 2020
    Astirian likes this.