Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Assets [RELEASED] CScape - advanced building generator

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

  1. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Thrawn75, jlocke, Aaron2348 and 2 others like this.
  2. omarvanegas2

    omarvanegas2

    Joined:
    Jan 27, 2016
    Posts:
    4
    Hi Olix,
    I’m looking for a solution that helps me populate a city taking into account I already have my predefine roads and need to move from there.

    Any advice to do so?

    If there’s no way to automate what I need, can I place your buildings individually taking advantage of the level of optimization you already have?

    Ps: city is the size of Miami ‍♂️

    Thanks for your time
     
  3. Aaron2348

    Aaron2348

    Joined:
    Dec 12, 2016
    Posts:
    157
    Hey I'm wondering if customization over CScape buildings a thing yet? And does this support Amplify shader or will it?
     
  4. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    It can be done, but it isn't documented yet - to do it so, you would have to make some reverse engeenering by looking at models and prefabs that come with Cscape. There are only a few guidelines that has to be respected when making models. One of them is that you would probably want to use Vertex colors in your modelling app. If a vertex color is black, those faces of a building will use windows, if it is white, they won't 8this way you can define what surfaces won't be filled with window - usefull when you have features like columns or some surfaces that don't meet requirements of scaling at 3m.). other than that, you would need correct pivot point orientation (you can see how it's done by opening any template model provided in FBX format). Also,you should be sure that your object is mapped with a box mapping, and that your UV coordinates start from a bottom left. This way a Cscape will know what is a lowest floor of your building. I don't suggest going into modifying building templates until a next release, that adds some new features in respect to the one available on assetstore. There is some refactoring going on, and a new possibilities will be more flexible (mostly supporting some new features as Graffiti on walls, snow or moss on buildings, and angles buildings (I have added a angled skew option for each building sot that they can fit any angleed streets - this means that you can do any angled streets). If you want to do any customization on a latest version, you can send me your request with your invoice number, and I will be glad to send you a new version.

    For a simplicity of use and developement, CScape is based on Amlifiy shader. This means that you can modify it without problems. i also think, that something that uses as complex shaders as CScape, couldn't be developed without using solutions like Amplify (there are just too many things going on - and Amplify just simplifies them and makes them readable). At this stage, amplify shaders are a little bit messy, and are still made for being read by myself, but, I will try to make some order to them in a near futur. I also must say that I'm working closely with Amplify Creations, and they were very helpfull in implementing some things that I've needed for CScape. Here you can see one of the graphs:
    Amplify.jpg
     
    matteumayo likes this.
  5. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    No, you can't use your roads to place buildings automatically as there is no any way that CScape could understand what are your streets. But, you can place and move buildings from CScape, anywhere in your scene a you would do with any other 3d models.A best way to do this is to generate many Cscape buildings, keep them in your scene, and move, customise and scale them to meet your needs. only thing that you have to assure is that you have to keep a folder (hierarchy) structure of CScape.
     
  6. Aaron2348

    Aaron2348

    Joined:
    Dec 12, 2016
    Posts:
    157
    Thanks for the information that's actually a really good explanation of how to go about customizing your own buildings. I have not purchased CScape yet, I don't know how but i just seen this on the Asset store today , I'll be getting a copy after Christmas. Okay I'll take your advice and wait for updates . I'll still try to reverse engineer my way through just to see how it goes, I really want to buy this to contribute content to the Asset.

    "In a future, I also plan to release Building Styles Packs, like Sci-Fi city, ’20’s New York, Italian city, Cartoon City, Apocalyptic City, Soviet City."
    (This is what Really got me interested In CScape)



    Yeah I was just going to ask you if this was built with Amplify based off the parallax interiors, This is really solid Work Great Job!!
     
  7. Anticleric

    Anticleric

    Joined:
    Dec 15, 2013
    Posts:
    2
    Hi Oli,

    I'm seeing big differences between what the editor shows and what a build shows. Not sure whats happening.
    Some of the buildings have this weird moire pattern:
    https://imgur.com/a/XZ135 (BUILD)

    Here's the same building in the editor:
    https://imgur.com/a/GJxyV (EDITOR)

    Then there are the building lights.
    https://imgur.com/a/NzXIb (BUILD)
    And in the editor:
    https://imgur.com/a/iCceC (EDITOR)

    Ideally, everything should look the same as in the editor. Not sure what's happening.
    Also, is there a way to turn the building lights all black for an entire city chunk? I've been selecting them one at a time and setting RGB all to 0 for each.

    Cheers
     
    Last edited: Dec 26, 2017
  8. Neviah

    Neviah

    Joined:
    Dec 1, 2016
    Posts:
    171
    Suggestion -
    I would love to see Points of Interest randomly generated through the city. For example: Stadiums, Parks, Gas stores, etc. Not a huge deal, just icing on the cake to make it look super nice.

    Cheers!
     
    sharkapps and olix4242 like this.
  9. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Check that you don't use any vertex compression in player settings as CScape needs high precission UV coordinates. Using vertex compression can produce errors with some graphics drivers.

    Right now there isn't. But this is planned for future release.
    If you are able to script, you could make a simple script that iterates buildings, and sets light parameter on buildings that are in range. I can make it for you, but right now I'm on hollydays, and I don't have any access to unity.
     
    Anticleric likes this.
  10. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Ok, here is a simplescript that can do thi for you - I haven't tested it, but it should work (if there arent any bracket errors or if I missed some namings).
    It will turn off all lights in a certain radius. Create a new object and apply a script to it. Then move it to a position where you want to turn off lights and set radius of its influence. Then click on Applly Influences checkbox Here it turns off all lights, but you can modify it also so that it sets any other value to any of building parameters (for references on parameter names, look into a BuildingModifierEditor.cs script).

    Code (CSharp):
    1. using UnityEngine;
    2. using CScape;
    3.  
    4. [ExecuteInEditMode]
    5. public class BuildingLightsInfluencer : MonoBehaviour
    6. {
    7.     public float radius = 100;
    8.     public Transform buildingsHolderObject;
    9.     BuildingModifier bm;
    10.     public bool applyInfluences = false;
    11.  
    12.     void Update()
    13.     {
    14.         if (applyInfluences) {
    15.             foreach (Transform go in buildingsHolderObject)
    16.             {
    17.                 if (Vector3.Distance(go.position, gameObject.transform.position) < radius)
    18.                 {
    19.                     bm = go.GetComponent<BuildingModifier>();
    20.                     if (bm)
    21.                     {
    22.                         bm.colorVariation.y = 0;
    23.                         bm.colorVariation.z = 0;
    24.                         bm.colorVariation.w = 0;
    25.                         bm.AwakeCity();
    26.                         bm.UpdateCity();
    27.                     }
    28.                 }
    29.             }
    30.             applyInfluences = false;
    31.         }
    32.     }
    33. }
    34.  
     
  11. omarvanegas2

    omarvanegas2

    Joined:
    Jan 27, 2016
    Posts:
    4
    Hey Olix,

    very nice work on CScape!!!!
    I did as you said and so far im happy with the results on a 10km x 10km city im working on. I did encounter texture flickering by the time I had a build.... something that wasn't visible on the editor. tried setting anti aliasing but didn't help much, might be something on the shader i believe.

    Please check the following link to a video that shows what happens. I appreciate your help on this issue!!!

    https://drive.google.com/open?id=1ieTqRmZZ7FQ6VoOWqeKStSvVmDBwLMqM
     
  12. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Did you try a trick with vertex compressin that I've suggested?
     
  13. Anticleric

    Anticleric

    Joined:
    Dec 15, 2013
    Posts:
    2
    You're the best OliVR! Turning off all the vertex compression fixed everything. I haven't tried the light script yet, but it looks like a lot of them don't show up anyway when it renders properly. I'll give it a go next time it becomes an issue.

    Thanks again!
    I'll give you a good review on the asset store when I get a chance!
     
    hopeful likes this.
  14. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    62
    Hi,
    Is there any guide on how to modify the Texture arrays (as taken from the CSDK), how to turn them into .asset files, then how to use them in the shader?
    Thanks
     
  15. jlocke

    jlocke

    Joined:
    Dec 16, 2017
    Posts:
    62
    Hello ...I would ask if it possible generate a city that not cover only a flat area .. thanks a lot
     
  16. jlocke

    jlocke

    Joined:
    Dec 16, 2017
    Posts:
    62
    It is really nice you include the full shader giving the opportunity to change according to specific needs.
     
    olix4242 likes this.
  17. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    You can find a script that does this in a CScape City object (CSMaterialTools).
    It will look into a CDK folder, compile textures, and assign them to a given material. But right now there is no documentation on how to make those textures. This is because I'm still amking some changes in a way to include more options and compress more usefull data into less textures. I will also provide a Substance material that will help in modifying those textures.
     
  18. omarvanegas2

    omarvanegas2

    Joined:
    Jan 27, 2016
    Posts:
    4
    Yes.... it was worst before that
     
  19. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    No, this isn't planned (yet) and I don't know if it can be done anytime soon. For now,only wat to do thingss like that is to manually place your buildings on some other city layout. Making it work automatically is too challenging, recource intensive, unoptimized and prone to errors. It would recqure probably years of work, and still wouldn't be optimized as you would have to use complex mesh parametrization (and tesselation) that would bring cities complexity to milions of polygons instead of thousands. Making a good terrain system is a complex thing (and we are still stuck with unity terrain for years), and making a city layout would be exponentialy more difficult than making a terrain system.
    Other than that, it would require completely different logic on building generation and modelling - because nobody want's buildings that have entrances somewhere where they don't belong (like entrance or window that is inside terrain). Also, you would have to loose many features and performance.
     
    jlocke likes this.
  20. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    62
    Perhaps just raising the height of a row of buildings? That way theres no complex terrain, but would be alot easier to do. Just need to join the roads up at an angle. So a building is always flat, but the roads inbetween go up/down hill. You can probobly do this already by exporting to fbx, and shifting the vertcies up/down at the road edge. Prob need a limit or it will all look like San Francisco but you get the idea!
     
  21. haywirephoenix

    haywirephoenix

    Joined:
    May 17, 2017
    Posts:
    17
    Are you able to separate the interior shader from the window frames so I can adjust Zwrite offset allowing for geometry inside. Can we also have scalable rooms like in Fake Interiors Free please? It also uses Amplify.
     
    Last edited: Jan 5, 2018
  22. omarvanegas2

    omarvanegas2

    Joined:
    Jan 27, 2016
    Posts:
    4
    What do you think Olix?
     
  23. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    388
    @olix4242 just playing around with the demo scene.. Switched from standalone build to android (editor only) and streets and buildings became black.. Using Linear , using. Tried availaliable types of graphics setting vulkan gles 3 etc...
    Any tips to fix this.. Unity 5.6.5f1. Also did it in 5.6.3.

    Windows10.. Amd 480 gpu

    Thanks
     
  24. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    No, this isn't planned as it would be extremely inefficient as all meshes would have to be rendered two times.

    This one is planned and will probably be implemented soon.
     
  25. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Select "Edit/Graphics emulation/No Emulation". This should correct your issue. Unity emulation is somewhat broken, so it emulates this in a wrong way.
     
  26. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    I must say that I don't have any idea on why this happens - as I can't reproduce this artifact. It probably has to do something with floating point precision in your scene or settings. But it's quite difficult to track if it doesn't appear in Editor.
    Until a 1.00 of your video, you have a classic moire effect that is mostly normal for high detail patterns (it happens also with standard meshes, and it happens even in real life). In a first scene, you have a shimmering from a building border. From minute 1.00 there is some problem with float precision, but I don't know why this happens. If you can find a building that has this problem, you could probably change few sliders and materials, and get rid of this problem. But I can immagine that it's hard to find what building has this problem. Also, it would be good to know if it happens always on a same building prefab.
    One question, from a look of your buildings, it seems like you are using Gamma instead of Linear color workflow. If this is true, then your precision problems might come from this.

    A new version should help in avoiding this problems as I have rewritten some shader and script code, to compensate for eventual imprecissions and allow more data to be written into a mesh.
     
    JBR-games and hopeful like this.
  27. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    Hi, does the Random seed that you use in Cscape override the entire Random system in all other scripts? ie: when I use Randon.Range, I get the exact same values everytime I run the game. I haven't encountered this on other projects so I'm wondering whether having Cscape code in the project is setting the random seed for the entire project to a set value thereby making all of the random numbers the same sequence for things that happen on Start or Awake.
     
  28. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    388
    Will do thanks..
     
  29. warren-miller-maltd

    warren-miller-maltd

    Joined:
    Jul 26, 2012
    Posts:
    31
    Having a bit of trouble with Android: The demo scene displays fine on my Pixel 2 but on my Nexus 7 (2013) which supports OpenGL ES 3.0 all the buildings are black.
    I've set up the Color Space and Graphics APIs, building for 4.3 (also doesn't work for 6.0)
     
  30. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    277
    i bet the response you are given will look familiar. like a few posts ago familar
     
  31. warren-miller-maltd

    warren-miller-maltd

    Joined:
    Jul 26, 2012
    Posts:
    31
    which one is that please?
    to be more clear, I've tested another Texture2DArray shader in the same project setup and it works ok.
     
  32. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    You can probably try this one. Find shaders that are black (probably CSBuilding, CSStreets and SCRooftops) open them, and change line where you see:
    #pragma target 4.5 (or 4.6)
    to
    #pragma target 3.5
    This should probably correct your issue.
     
  33. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    It could affect radom seed after generation as unity uses global seed. You should probably add a script that resets custom random seed by line like this.
    Random.seed = System.Environment.TickCount;
    p. s. I will include this into my scripts in a next version.
     
    hopeful likes this.
  34. warren-miller-maltd

    warren-miller-maltd

    Joined:
    Jul 26, 2012
    Posts:
    31
    hi, thanks for the suggestion but the buildings are still all black
    device-2018-01-10-172239.png
     
  35. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    Can you give us a bit of detail about how the template for things like street details work? for example, is it possible to have multiple types of street detail on the same block, so streetlights, with some trash cans, etc on the same block? I tried to create a new template for trash cans but seems like each block has either trash cans or streetlights.

    Also, is there a way to add street detail to the actual street, not the sidewalk section? for example obstacles that are in the middle of the street?
     
  36. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Hmm.. looks like a case where we could have some hardware/system related problems. It is quite difficult to support devices that are quite old, discontinued and that I don't own - and a problem could be enywhere - from graphics drivers (I can see that there was a patch for graphics drivers that adresses some 2d Arrays problems - https://forum.xda-developers.com/showthread.php?t=2665832
    but with functionality that probably no one used at a time, this leads me to think that there might be some issues/bugs.
    this could mean something, but also nothing - maybee there is some limit on number of tex arrays per shader or resolution limit. One of the things to try is to rebuild texture arrays in smaller resolution (with CSMaterial tools script).
     
  37. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Right now it works for a single type :( But you can change some scripts if you are familiar with scripting. Open a CityRandomizerEditor.cs script, and you will find a section that has this lines:

    if (GUILayout.Button("Add Street Details"))
    {
    ce.DeleteStreeetDetails();
    ce.GenerateDetails();
    }

    and below add lines

    if (GUILayout.Button("Add Street Details without Deleting"))
    {
    ce.GenerateDetails();
    }

    This will give you a new button that should enable adding multiple objects. Generate lamp poles, then change a prefab, and use new button to add new type of prefab.
    Alsomyou could use scripts like this one:
    https://forum.unity.com/threads/rel...building-generator.460380/page-4#post-3244962

    Anyway, this functionality of spawning objects is being re-written, to give some advanced things (mostly with support for non parralel streets.
     
    Neviah likes this.
  38. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    62
    Hi,
    When is the next patch likely to be released?
    Thanks
     
    Neviah likes this.
  39. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    Thanks for the reply.

    I've got another question, I'm working on a different computer (razer laptop with 1060 card) and all of the buildings are just grey, no color or texture. The same project works fine on my desktop. This is using Unity 2017.3p1 (on both machines). i tried to generate the city again, but that doesn't help. Project settings are the same on both, using DirectX 11 and no emulation.

    Cscape-greybuildings.PNG
     
  40. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    This clearly looks like some kind of Unity or driver bug. Are you running Unity with a Nvidia graphics card and integrated Intel? Anyway, thos shouldn't happen and I'm almost pretty sure it's not directly related to CScape. Is this a dame project or another one? Does this happen if you create new project?
     
  41. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    Not sure.. I wanted to release it one month ago, but had so much ideas and changed (and added) too many things - then I was ill for two weeks and this slowed down things. I plan to start finishing it next week - so i think that it will be online in two weeks time.
     
    JBR-games likes this.
  42. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    Yes, this is the same project and I don't think it was happening a few days ago on this same computer with the same unity version. I did do a nvidia driver update recently though.

    I tried to delete the library folder but same issues. Yes, I believe the computer has both the 1060 and an integrated card, but it hasn't caused any issues with any of my projects including cscape in the past.

    However a build made with the other computer runs just fine on the laptop, the textures are all there.
     
  43. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    There are a number of warnings:

    Could not create a custom UI for the shader 'CScape/CSBuildingShader'. The shader has the following: 'CustomEditor = ASEMaterialInspector'. Does the custom editor specified include its namespace? And does the class either derive from ShaderGUI or MaterialEditor?

    Shader warning in 'CScape/CSBuildingShader': floating point division by zero at line 229 (on d3d11)

    Requested realtime/indirect resolution on mesh 'CSBuilding5(Clone)' is too high, clamping to maximum system size (512x512). Lower the resolution setting.
     
  44. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    Looks like creating a brand new project with Cscape on this laptop works just fine, it's just my existing project :( so maybe something is missing from it or a bad setting that is causing that... but it's odd because the same commit from the same repo works fine on another computer.
     
  45. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    62
    ok cool, look forward to it. Please include instructions on how to modify the texture arrays! Thanks
     
    olix4242 likes this.
  46. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    If you look into a MegaCity1 material, do you have all texturess assigned? If no, try this:
    -Unpack Unity pack in CDK folder with all resource textures.
    -On CScape object find CSMaterialTools script, and click on Generate checkfield. It will repack textures and assign them to your material.
    It could be that unity lost reference to those textures
     
  47. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    364
    Thanks, I first tried to just re-import cscape into the project and overwrite the old files. This seemed to fix the missing textures. Yeah, I think somehow the references got lost or something like that.
     
    olix4242 and hopeful like this.
  48. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    946
    I finished my submission for Neon Challenge by using CScape. You can look at it, and put a like here if you want.

     
    magique, rrahim, matteumayo and 3 others like this.
  49. rrahim

    rrahim

    Joined:
    Nov 30, 2015
    Posts:
    149

    Awesome work. I also used Cscape in my submission as well.

     
    olix4242 likes this.
  50. KSF

    KSF

    Joined:
    Mar 15, 2015
    Posts:
    3
    Great asset, but we've got an issue. We set up the city in the Building modifier. After we need to move the city to the unity package. We were trying to move just the city, not whole cscape. When we unpack package all of setting in BuildingModifier are default. What should we do? Thanks
     
    Last edited: Jan 18, 2018