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] CScape - advanced building generator

Discussion in 'Tools In Progress' started by olix4242, Mar 11, 2017.

  1. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Exactly where my mind went. (Though again, if it is easy to add these ourselves, that's good too.)
     
    olix4242 likes this.
  2. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Problem with fire escapes is that they can have pretty many polygons - so this is something that I would avoid adding by default, mostly for performance reasons. But they are easy to add with CS Array script, if you have a model. I will try to improove CS array script further, to make it even easier to do.
    Actually, after fixing rooftop elements, I will make some nice balcony models. So, stairs can come later.
     
    Last edited: Nov 29, 2017
  3. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Here it is before importing into unity.
    roof.jpg
     
  4. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    You could try something like this (the ones on the middle-right):

    Since you don't see the steps you could do a single model and rotate it.
    It also adds a lot of variation to the vista.
     
    olix4242 likes this.
  5. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    Any chance of adding a snow variable please. It would help it fit in with uber, cts, and unistorm
     
    olix4242 likes this.
  6. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    These are really cool. I think it should be easy.
     
    hopeful likes this.
  7. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    I wasthinking how to implement this, but I think that this could be pretty tricky. Probblem is that CScape shaders are mure complex than other shaders, and adding snow would requre atleast one more texture (if not more, if you want some special effects, but for this, I could probably reuse some other texture slots). i will do some experimenting on this and see how far can I go.
     
    tredpro likes this.
  8. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515

    would be awesome if you can!
     
  9. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Ok, it's done ;)

    balconies.jpg
     
  10. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Snow.jpg
    Just a small proof of a concept - I think that it visually looks really nice. And probably could be used also for some other effects like a moss in a abbandoned city. But I had to turn off some shader features, so I will have to find another way to optimize this and make it work on most platforms.
     
    tredpro likes this.
  11. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    Welp, that was fast (and cool).

    The snow should be easier (and more notable) to implement on the streets first, since you only have one important normal.

    Have you thought of adding some column generation to break the patterns ? those can be inexpensive and if they are well textured add quite a bit. Maybe even some awnings.

    Another thing that can add a lot and be inexpensive are cables/poles, it would be similar to the lighting poles.
     
  12. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515

    If you think about how snow falls I don't think hitting the street first would be accurate since it would hit a building before it would hit a street but I could be wrong
     
  13. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    Looking nice!
     
  14. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    I know when this first came out I tried it and couldn't but are you able to take a bunch of cscape buildings, lights, etc from a few seperate game objects and add them all under 1 cscape parent? So it would work with those controls?
     
  15. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    You can dp this if after you strip CS scripts. But you loose editing features.
    Also, I can't see any valid reason for doing so. Cscape is organized so that it gives you maximum performance and controll in editor and in build. This type of organization is much more performant as it makes batching work fast, and can be used in future for improoving perfomancr even more. Also, it gives you ability to turn off certain elements on runtime, giving you a flexibility to optimize scenes based on your platforms (turn off some elements that aren't crucial to improve performance).
     
  16. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    My reason is to build a city that is a different shape than a square. Where I may use a cscape parent for 1-3 buildings a few times to and so by the end I could end with maybe 15-20 cscape parent. And for me to use the editing I will need to find its parent instead of using the main parent. Also if I need to make changes city wide I would have to pull up each option
     
  17. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    I've found an issue with MacOS and latest Unity patch.
    This unity version broke some things. You can use Cscape in two ways:
    -by switching editor to Metal (experimental) in player settings.
    -Other way to use it would be to manuallly select all black materials, and under material settings click on Edit shader. Then change a line that states

    #pragma target 4.5
    to
    #pragma target 3.5

    This should work and make those materials visible again.
    I will include this changes into a new Csape version.
     
  18. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Probably not a best way to use a CScape. If you need some buildings to populate your scene in small patches, a best way is to generate a lot of buildings and streets, and than move them to positions that you need (by keeping other buildings outside of your interest of region). Anyway, Cscape will track all 'virtual' parents and move them with buildings. After that, you can easily delete those buildings that arent of your interest. (with Cscapee it's easy, as those buildings doesn't impact editor performancetoo much)
    Next version (not the first one, but one after that) of Cscape introduces few changes to workflow. Now a virtual parrenting should be: CScape City > Block > Buildings. This will give you also a possibility to generate buildings or randomize them from street block object. Or generate separate street blocks one by one.
    I'm still into research on this, so the main idea for now is this.
     
    shredingskin and tredpro like this.
  19. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    Yes, I'm using Cscape the same way as tredpro, that's why I asked about the old prefabs.

    Does having a lot of buildings deactivated from the inspector affect performance much ?
     
  20. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    It shouldn't affect performance probably at all. It can increase file size, but other than that, there shouldn't be any problems.
     
  21. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    A first step into creating a little bit of disorder in street layouts. System below now uses raytracing, an should be capable of doing many new things, and extend city layouting possibilities. disorder.jpg
     
    sharkapps, JBR-games and tredpro like this.
  22. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    excited for the next update!

    also any chance of maybe adding grass(or just an empty square revealing the terrain) along with a slider for the possibility of a patch being grass instead of a building.
     
    olix4242 likes this.
  23. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Yes, this is in works.
     
  24. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    And unless I can't find it, a way to not generate the river
     
  25. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    You don't want a river in your scene? Just set river position value in city size section of randomozer to value larger than number of blocks values.
     
  26. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Step two in developing new street layout system.
    NewLayout .jpg
     
    sharkapps, tapawafo and CptKen like this.
  27. CptKen

    CptKen

    Joined:
    May 30, 2017
    Posts:
    216
    Hi, your asset is quite something else. I really like it.

    However, I have one issue right now which I'm not sure how to solve. I have a need to instantiate a city at runtime from a prefab. So I make a CScape prefab but when I load it into the scene everything is invisible.

    I did a quick workaround with my own script to find the CScapeRandomizer component and call Refresh on it. However, I understand this is only intended for the editor and of course I can't build the game with this because a lot of the CScape Randomizer is editor only.

    Help would be greatly appreciated thanks.
     
  28. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Yes, there are amny scripts that are editor only, and they can't be made to work outside of editor in any way - as it relies on unity editor build in features that aren't available in build. There is no work around, and I'm not sure that there will be any. But I will probably look into trying to make some kind of workaround, atleast for saved prefabs with Refresh function.
    BTW, loading at runtime isn't a best way to do this performance wise. Generating at runtime could be, as it could save some storage memory, but on the other hand, it would have a greater impact on RAM and garbage collector. Also, it could impact probably scene optimization and static batching.

    I might suggest you not to use prefabs, but instead, you can use adittive scene loading that is always a better solution for loading huge worlds. And it works with Cscape.
     
  29. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    I found setting it to -1 did it
     
    olix4242 likes this.
  30. CptKen

    CptKen

    Joined:
    May 30, 2017
    Posts:
    216
    Hi Thanks for the quick response. Unfortunately the way that my game works is rather unique and additive scene loading won't work for me as the level is not static, it is different every time. Its not a huge world perse but an endless track system (see video below). BTW, I am not actually instantiating during gameplay, I am using my own pooling system and instantiating at load time. I don't have any issues with frame rate drops when I activate segments in the scene and I'm getting decent FPS in the below scene. That's in editor with a full stack of heavy image effects and a relatively old graphics card (mostly thanks to the efficiency of CScape). I'm also not calling Refresh during gameplay so the Garbage allocation is minimal.



    I may have to wait for runtime generation functionality if that is the case. Actually tbh that would be ideal as I would get even more diversity. Though unless it allows generation only on specific user defined areas, I'm not sure it would work for me because I had to delete a lot of buildings and move them a bit to fit my track in.

    My game still has a lot of work to do so I'm in no huge rush at the moment. In the mean time I will look into what the Refresh code does and try and implement my own workaround.

    Looking forward to it the real-time stuff though :) thanks.
     
    Last edited: Dec 2, 2017
    sharkapps, olix4242 and blacksun666 like this.
  31. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    No need to do this. I have managed to make a Refresh() code work from a build.
     
    CptKen likes this.
  32. CptKen

    CptKen

    Joined:
    May 30, 2017
    Posts:
    216
    Thank you good sir.
     
    olix4242 likes this.
  33. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Experimenting some new options. Not yet sure if this can be included - but probably can be...

    graffiti.jpg
     
  34. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Im having 2 issues, one is when bloom is used i get this weird looking boxy bloom off some buildings and the other is that the water puddles are not looking correct.(Black-dirt looking) any recommendations ? thanks

    ok i think i figured them out... the bloom issue was too much smoothness (needs to be less than 1) in the building material, and the puddles were way out of adjustment on several settings on road materials. This was in Demo scene, fresh project unity 5.6.3
     
    Last edited: Dec 6, 2017
  35. ChezDoodles

    ChezDoodles

    Joined:
    Sep 13, 2007
    Posts:
    107
    I was wondering about the following for runtime use:
    1. Is there a way to to provide some kind of mask (either polygonal or bitmap) that define the area you can populate with streets and buildings?
    2. Is is possible to make the city grow or shrink at runtime (preferable both in size and in the height of buildings)?
    3. Is there a limit on how many cities you can have in a scene?
    4. Is it possible to have DIFFERENT types of cities in a scene? (Right now you provide just one type of city - but the artist-kit will make it possible to add other types of cities)
     
  36. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Runtime generation isn't supported, and probably won't be soon (but is in exploring). Main problem is that unity don't support some basic functionality like generating LOD's at runtime. You can regenerate city at runtime (without storing mesh data) and make some variations (in materials, heights) but not on layout (street map). I will see if I can make some workaround in future.
    size and height yes. A new version will introduce this possibility.

    No. Not any on side of Cscape. You can have as much cities as you want, if your hardware can handle it. Coun't that editor performance is lower in case of many buildings, and you might get a sluggish editor performace with many buildings - but in build, it should keep performance. Today I've made a city that had 16 000 buildings and all details, with owerall 6 milions of poligons. Navigation was really slow in editor, but after playing scene, it kept stable 90 fps. This is because unity batches meshes together on play.

    Yes, you will be able to do this. I'm also working on some differentiation based on volumes (as in your first question) that will be able to spawn object styles based on those volumes in same city.
     
    shredingskin and CptKen like this.
  37. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    There's an error on building in 2017.2.1:
     
  38. jlocke

    jlocke

    Joined:
    Dec 16, 2017
    Posts:
    62
    Congratulation for the asset. Innovative concept and really amazing implementation. We will buy next week to explore new option for a game still in idea stage
     
    olix4242 likes this.
  39. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Hi, thanks for pointing this out. What is the platform and Api settings that you are building for?
    Rooftop shader is a quite simple shader, and there is no any apparent reason for this error. I never got this error. But I can only guess that this can be caused by some project settings, or some unknown Unity bug.
     
  40. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Ok, I've found this one and this probably could be your problem.
    https://issuetracker.unity3d.com/is...lerunity-lightmap-error-with-specific-shaders
    This topic has a probable solution for this bug. But it also mentions a shader "Custom/ColorPicker" that, I think, comes from one of the packs on assetstore, that in some cases breaks correct shader compilation ( it had some issues with another of my assets).
     
    Last edited: Dec 19, 2017
    shredingskin likes this.
  41. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    city.jpg As many of you wanted a support for non parralel streets, I have made some progress on this field. A basic alghorithm is done. I have to make some further finetuning - but for now it does basic things making cities more random and less box shaped. It requires a lot of adittional work (for spawning objects like lightpoles, and making some scripts for easy positioning calculation). I don't think that this will go immediately into a new release - but it should become available in final version of Cscape.
     
    JBR-games and shredingskin like this.
  42. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    The lightmap modes are already set to automatic.
    It's weird since I haven't imported any new assets in the project, and I'm pretty sure the project compiled under 2017.2
     
  43. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Could you try doing some export by removing that shader temporary from a project?
    What is your export platform?
     
  44. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    Desktop,
    You mean deleting the shader and trying the same export ? (I don't see where to exclude shader from compiling)/
     
  45. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Yes.. move it outside of your project.. this way we can know if it's shaders fault or some other thing. (unity sometimes bugs on reporting errors)
     
  46. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    Or you can even test with a new version of shader (by replacing the old one).
     

    Attached Files:

  47. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    It did build when I took the rooftop shader off.

    I'll see replacing with this new one.

    EDIT: that isn't the shader that was causing problems, it was RooftopsShader.shader
     
  48. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    oh.. ok, then you can freely keep it out of your project. That one was included but it shouldn't be. It was an old shader that isn't in use anymore.
     
    hopeful likes this.
  49. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,962
    But I still don't get why it should give any problems..:eek:
     
  50. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    A lot more comfortable now.
     
    olix4242 likes this.