Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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:
    1,685
    Mostly yes (but there are some new features that will come soon). But it isn't documented. You can explore it by opening FBX template files and starting by modifying those. Modification is different in different modelling software, so let me know if you need some help.
     
    syscrusher likes this.
  2. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    BTW, as I'm approaching a final release, I'm planing to make some video tutorials on how to modify them and on how to create textures.
     
    syscrusher and matteumayo like this.
  3. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Here is a small solution to your problem.

    Code (CSharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using UnityEditor;
    5. using System.Collections;
    6. using CScape;
    7. using UnityEngine.SceneManagement;
    8. using UnityEditor.SceneManagement;
    9. using System.Collections.Generic;
    10.  
    11. public class CSSmartSaver : MonoBehaviour
    12. {
    13.  
    14.     [MenuItem("File/Save CScape Scene", false, 10)]
    15.     static void SaveSceneCScape(MenuCommand menuCommand)
    16.     {
    17.         List<GameObject> rootObjects = new List<GameObject>();
    18.         Scene scene = SceneManager.GetActiveScene();
    19.         scene.GetRootGameObjects(rootObjects);
    20.         //iterate root objects and find all City Randomizers (if there are more than one)
    21.         for (int i = 0; i < rootObjects.Count; ++i)
    22.         {
    23.             GameObject gObject = rootObjects[i];
    24.             if (gObject.GetComponent<CityRandomizer>() != null)
    25.             {
    26.                 Component[] renderer = gObject.GetComponentsInChildren<MeshFilter>();
    27.                 foreach (MeshFilter x in renderer)
    28.                 {
    29.                     if (x.transform.name != "NordLake")
    30.                         DestroyImmediate(x.sharedMesh, false);
    31.                 }
    32.  
    33.             }
    34.         }
    35.         EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
    36.         for (int i = 0; i < rootObjects.Count; ++i)
    37.         {
    38.             GameObject gObject = rootObjects[i];
    39.             if (gObject.GetComponent<CityRandomizer>() != null)
    40.             {
    41.                 gObject.GetComponent<CityRandomizer>().Refresh();
    42.  
    43.             }
    44.         }
    45.  
    46.     }
    47. }
    48.  
    49.  
    This script should enable a new menu item under FILE, called Save CScape Scene.
    It will save a Cscape parametrization and your scene, without saving procedural meshes (that use most of a disk space).
    For now, after loading, you will have to call manually Refresh City button after loading. But it should recreate city really fast as it was before saving.
     
    ranaUK and syscrusher like this.
  4. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,181
    I don't know what cleared up in the new update, but I can now run CScape at framerates in the 30s in the editor on fullscreen with sky and horizon plugins and soft shadows @300m ... which is like more than double the performance on the previous version.

    The lighting is also great! Just starting to fiddle with it. The buildings also look very nice. :)

    (UPDATE: Is the NordLake river missing? Seems to be absent in my example scene.)
     
    Last edited: Nov 4, 2017
  5. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Strange. I think that you probably had some importing problems in a version before. Might be a Unity bug. Almost nothing that could drastically impact performance wasn't introduced in a new version. On contrary.. Re-lighting feature by itself is somewhat more complex for rendering, so in theory it could be somewhat slower with that feature enabled (but probably insignificantly slower - probably can't be even measured).
    No, It is still there. Just tested if there were exporting problems, but, imported in fresh project, it works perfectly. I would suggest you to use clean install (remove CScape folder shutdown unity, reopen it, and install CScape package ), sometimes unity can break prefab associations if you are updating.
     
  6. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    I guess I just don't know how to use it. Sorry
     
  7. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,181
    Things seem to be ... fixed now. Not sure why.

    First off, the CScape I cited before (with no river) was already a fresh import into a new project, where I added sky and horizon as part of testing after I saw the frame rate seemed so much better.

    To further investigate the river issue, I created yet another new project, imported CScape, and this time I had the river. So I went back to my other one, which had the sky and horizon plugins.

    After rebuilding the city (which I had done at least twice before), now I have the river. I've rebuilt twice more and I still have it. (*shrug*)

    Anyway, it seems I did recover the river. I don't know where it went, since it was in the hierarchy even when invisible and it always looked fine in terms of compiled shader, material, and all. And I had reimported it too. So ... IDK, but I have it now. ;)
     
    olix4242 likes this.
  8. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    I think that Unity importer sometimes has some glitches when it has to import/update assets that are already existing. It looks like it looses some references (probably a serialization issue). Thats why, a clean import is a best way to go. Also, I have another user that had some performance issues when not making a clean impoort. And even, I can't see any obvious reason how this should impact performance, it can happen. I suppose that simply, unity project gets corrupted in some way, and that performance glitches comes from Unity internal problems.
     
  9. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Contact me, and I can try to explain how it can be done.
     
    syscrusher likes this.
  10. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
  11. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    Is there a pdf or step by step instructions somewhere?
     
  12. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Hi, there is no PDF, and it won't be available until a final release of CScape. This is because I'm one man team, and CSCape continues to improove and change with every release, so at this point, making a serious help file would steal too much time from developement. And also, it would become obsolete really fast. For now, you can watch a tutorial that I've made, it should explain pretty everything important to get you going.
     
    rrahim, syscrusher and JBR-games like this.
  13. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,062
    Thanks for posting this. One small note (minor issue, not serious) is that your video capture tool didn't capture popup menus, so things like right mouse button context menus that you mention do not appear.

    I wouldn't worry about it for this video, but when you get ready to do one for your final release it might be worth checking your capture settings. :)

    By the way, I was awake until the wee hours last night myself, working on a tutorial video for my own soon-to-release asset, and I was doing battle with video codecs. So I feel your pain as to how aggravating that part of the process can be! Making docs and tutorials can take longer than the code.
     
  14. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Good news for you. WEBGL 2.0 support is on it's way and will be included probably in a next release.
     
  15. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    after watching the video i realized i already knew what i was looking for just not how it was used. love the asset still. only way it could get better is if you add support to fill the floors too! like how you do the roof tops
     
    olix4242 likes this.
  16. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Do you mean city streets? Or faccade? Faccade is half implemented (you can check buildings that have balconies). Street level detailing scripts will be made soon (it is planned, and lately I'm making many changes in how city generation works, to be able to easily extend everything). But they require good assets, and probably, this would have to be a separate package.
    I plan to implement different city generation workflow: now it works by generation streets and buildings in one step with a single logic. i want to change this so that user has to generate city in more steps:
    -Generate city street layout automaticcaly (only streets and nothing else)
    -modify city layout by hand by moving streets around and resizing them
    -Once a map is done, fill automatically everything with buildings and details.
     
    rrahim and JBR-games like this.
  17. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Next release will be soon submitted to Assetstore. It has some nice new features:
    -WEBGL2.0 support
    -Improoved Re-Lighten. Now it's possible to have nice daytime lit city with a single directional light, without any GI baking.
    -Improoved textures
    -Improoved material shader. I have spent many hours on trying to calibrate materials and improove overall look.
    -Better glass rendering - now reflections get's distortedlike it would in real world
    -Better nightime building illumination
    -Better management of blinds
    -Improoved Street shader and materials
     
  18. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
  19. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    I was talking about building interior but I was messing with the plugin today and was wondering if it could be added to slant the streets and maybe add a little more than just squares?
     
  20. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    Also when I mess with the bridge piece I'm trying to remove the 2 pieces that run next to the river but I can't do so completely. Any idea how?
     
  21. N00MKRAD

    N00MKRAD

    Joined:
    Dec 31, 2013
    Posts:
    210
    The interiors are all just a 512px texture with Parallax mapping.

    Actual 3D interiors would kill the Performance and would take many hours to create.
     
    olix4242 likes this.
  22. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    I know about the parallax. I'm talking about doing interior like the rooftop is done but only within a certain of that area with lod. So you may have 1 or 2 rooms loaded at a time
     
  23. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Some new assets (and features) are coming to CScape.

     
  24. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Hmm... I think that this would be a pretty heavy feature. There is no any way to do this and keep it optimized (moving complex meshes around a scene isn't free). Also, as @N00MKRAD mentioned, creating that type of assets would be really large work to do (probably a lifetime for one person team as me). Also, I even can't immagine how could I make transitions between textures and real interiours. Probably it could be done by using transparent shaders, but this would open a can of worms and kill any performance left.
     
  25. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    Don't worry. I'm not expecting it to be added. I'm planning to try an add on to your asset. But just wanted to comment that so if someone else gets it done before I do
     
    olix4242 and JBR-games like this.
  26. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    A test:
     
    JBR-games, Steve-Tack and hopeful like this.
  27. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,181
    I get an error trying to play that. But the first frame looks great. :)
     
  28. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Oh my god. But here I'm unable to help without putting my hands on youtube code ;)
     
  29. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,181
    Don't worry ... for some reason it's working now. Looks great! :)
     
  30. BrianDouglas

    BrianDouglas

    Joined:
    Nov 17, 2017
    Posts:
    1
    Hi! Does this work on ground that is not flat, and does it work on spheres?
     
  31. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Unfortunately no in both cases.
     
  32. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    with each update will it be possible to add to the current city instead of having to build a new city each time?

    i have a city built that i really like where i had to move a few things around but the bus stop and other future items i would like to be added
     
  33. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Yes, it can be done ;) As I'm approaching a final release, I'm trying tk make all those updates less invasive.
     
    tredpro likes this.
  34. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,830
    I just purchased this and when I view the demo scene it just has black texturing for all the buildings. When I look at the shaders being used, there is a floating point division by zero error. I'm not sure if that's the entire reason for the black texturing, but maybe you can help.

    upload_2017-11-18_12-35-40.png

    [EDIT]
    I was able to eliminate the division by zero errors by adding UNITY_WIIU wherever it was looking for UNITY_COMPILER_HLSL2GLSL, but that didn't help the black issue.
     
    Last edited: Nov 18, 2017
  35. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Division by zero is harmless error and shouldnt be considered.
    You are running this on dx 10 gpu. Be sure to ise dx11.
     
  36. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,830
    No, it's actually Wii U, which is neither DX11 or DX10. It uses Shader Model 4.
     
  37. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,830
    I'm trying with just PC build for now, but having issues with lighting. When I add street lights, the lights are not where they should be. I would think they would be positioned under the street lamps, but I see lights completely off the city area completely. See on right side in particular.

    upload_2017-11-18_14-7-6.png
     
  38. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    630
    Looks great, Im very interested in this asset and will likely pick it up in the next week or so.
    Im curious can we make multiple instances of these city areas in one scene. Or make an area save as a prefab and then delete it from scene and then generate a new area and then place these prefabs together ?
     
  39. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    Ah ok.. then contact me in private, I can probably use you as a tester for support for WII. As you probably know (and tjlhis is stated on assrtstore) WII isn't supported. But it probably could be with skme testing.
     
    tredpro likes this.
  40. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    440
    @olix4242 i have this same question about the lighting
     
  41. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    You can generate as many areas as you want (with different settings) and combine them together. If you look at a second video that I have posted, you can watch tutorial that explains how does it work.
     
    JBR-games likes this.
  42. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    I have checked, and it appears that there are some wrong calculations. I have updated some generation scripts, but I didn't update light generation scripts to reflect those changes. Sorry for that. This will be corrected in a new CScape update. Ina meantime, you can edit CityRandomizer.cs script and replace GenerateLights() function with this one:

    Code (CSharp):
    1. public void GenerateLights()
    2.         {
    3.             foreach (Transform go in streets.transform.Cast<Transform>().Reverse())
    4.             {
    5.                 StreetModifier streetMod = go.GetComponent(typeof(StreetModifier)) as StreetModifier;
    6.                 if (streetMod != null)
    7.                 {
    8.                     if (streetMod.streetType != StreetModifier.CScapeStreetType.River)
    9.                     {
    10.                         GameObject cloneH = Instantiate(streetLightsPrefabs[Random.Range(0, streetLightsPrefabs.Length)], go.transform.position, go.transform.rotation) as GameObject;
    11.                         cloneH.transform.parent = streetLights.transform;
    12.                         cloneH.transform.Translate(new Vector3 (0f, 12f, 0f));
    13.                         cloneH.transform.name = "Light" + go.transform.name;
    14.                         CSInstantiatorLights streetLightsModifier = cloneH.GetComponent(typeof(CSInstantiatorLights)) as CSInstantiatorLights;
    15.                         streetLightsModifier.depth = streetMod.blockDepth;
    16.                         streetLightsModifier.width = streetMod.blockWidth;
    17.                         streetLightsModifier.Awake();
    18.                         streetLightsModifier.UpdateElements();
    19.                     }
    20.                 }
    21.             }
    22.         }
    Note that this script doesn't place those lights correctly on every pole, as this would have a great impact on a performance (having thousands of lights isn't a right way to do it). That's why I have introduced Re-Lighting feature. and I'm moving towards rewriting street lights management: main idea is to use certain realtime number of lights in a close range, and fade them to match Re-lighten feature at a distance. This way we will be able to use realtime lighting that will have less impact on a perfromance (and editor workflow).
     
    tredpro and hopeful like this.
  43. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,244
    I had to buy this, it's just too cool!

    I'm not sure how far you plan to extend the systems that make up this asset; personally, I'd love to see the road network system expanded to support more interesting patterns and possibly allowing the ground level to not be flat (perhaps to conform in an intelligent way to a shape below the generated city). I think these have been requested before but I want to add mine to the list too.
     
    tredpro and JBR-games like this.
  44. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    I'm moving into that direction, lately I've been making some changes that would help in a future, but before implementing all of this, I have to come into a official first release. And this means that I wan't to solve some standardization questions, and add some models (like I'm doing right now) and extended features that will allow to generate all kinds of buildings, without many limits. One of the first steps is to allow physics to do some calculations on layouts as raytracing collisions in generation step is better solution for this task. anyway, I'm completely dedicated to this asseet, so you can expect it to grow with time.

    This is a task that isn't easy and usually generates non optimized solutions that have many problems. Solutions that work and that I saw generate mostly non performant models. Other solutions (and there are many lately) generate cities that are good for aerial viewing, but all have great problems at a street level and really can't be used for serious game production. And my main goal is to be able to produce a convincing cities that work and doesn't have any glitches. this means that I don't want to make anything that dosn't have a best performance, stability and looks. Idea is to have a powerfull city/building generator that can output a final level that is on a par with AAA levels made by artists.
     
    hopeful, JBR-games and Stephen_O like this.
  45. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,244
    In my city, I'd like to have dark colored asphalt streets and lighter colored concrete sidewalks and was wondering if it's possible to separate the street and sidewalk albedo color in the StreetShader? Thinking about it more, it would also be nice if the color tint did not effect the grates and puddles, so I guess that might need its own color too, maybe as an alternate shader if it's more expensive.
     
    olix4242 likes this.
  46. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,685
    this isn't a problem, but it will influence all street sidewalks. I can implement this easily with few lines of code, and it isn't intrusive.
    But you have another option, that is somehow better as you get a controll on street basis. You just have to edit source textures that are included in CDK, recompile them with CS Material Tool script , so you can have colours on per-surface base.
     
    Stephen_O likes this.
  47. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    334
    where can I find the documentation for the material tool and the workflow for adding custom props' textures (or buildings, streets...) and using them with cscape?
     
  48. nayagam

    nayagam

    Joined:
    Nov 18, 2015
    Posts:
    10
    is there a workflow to define the road network manually (not grided) so it can be more organic as is typical of an old city in Europe?
     
  49. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    334
    right now its only grids. although you can have different cscape city objects in the scene so you can create multiple blocks and place these as you wish. you would then have to fill in the spaces inbetween, (if the space would not be rectangular, you would have to add a park/ parking lot/ whatever, as you couldnt fit another cscape object).
     
  50. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    334
    would you be able to add global settings for night lights tiling and height? perhaps add it to the random settings or the night lights settings. also would you be able to allow for billboards all over the building? not just around the bottom

    and hopefully the last thing, but probably not, how do I prevent buildings spawning where I would like an open space? would you be able to check for collision on created buildings and remove them so that we could place colliders where we dont want stuff to spawn? or alternatively would you be able to add something like include/exclude volumes? so that when placed certain buildings would be placed, or could be excluded




    and I would also like to report a bug? when I hit generate city with the same seed, the width of some of the streets is different.

    also on a mac I got this:
    Shader error in 'InteriorSCape': Duplicate system value semantic definition: input semantic 'SV_POSITION' and input semantic 'VPOS' at line 122 (on metal)

    Compiling Fragment program with SHADOWS_DEPTH UNITY_PASS_SHADOWCASTER
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME

    and the heights curve is really unresponsive, since it regenerates the city right away after its slightly changed its extremely painful to drag the keys where I want them to




    also got this error when I set the section division min/max to 3 & 5 respectively (or any other number combination except the default 2 & 4 or 1 & 1)

    IndexOutOfRangeException: Array index is out of range.
    CScape.CityRandomizer.Generate () (at Assets/CScape/Scripts/CityRandomizer.cs:330)
    CScape.CityRandomizerEditor.OnInspectorGUI () (at Assets/CScape/Editor/CityRandomizerEditor.cs:442)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1240)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    EDIT: also got that ^ error for some numbers in min/max block distance (eg 20 & 22)


    and how do I set the city maximum height/ floor amount? I thought the floors would be between the values set in the random settings, but when I set the values to 0 and 1, I still get taller buildings than that.
     
    Last edited: Nov 22, 2017
unityunity