Search Unity

Assets [RELEASED] CScape - advanced building generator

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

  1. anton88pro

    anton88pro

    Joined:
    Jul 20, 2017
    Posts:
    36
    I just wanted the dev to know, I've solved my issue. It was my fault, sorry. In instructions of JamesWjRose, somehow I've skipped the first step and created new black scene, instead of using "CScapeToolkit"scene.
    However, now I want to know if it's possible to have two or more sets of facades. I thought, if I change folder name in the "Texture Folder" box of the "CS Material Tools" script of Cscape City, it will read textures from that new folder, but it didn't work (pressing "compile" buttons does nothing).
     
  2. anton88pro

    anton88pro

    Joined:
    Jul 20, 2017
    Posts:
    36
    Seems like the dev still has not addressed my previous questions :( . But I have more questions!
    1.How do I remove grey stains. I tried to adjust "faced lights", but it only places stains somewhere else. An example is shown in the screenshot below.
    2. I can't make floor colors and main colors to match. I adjusted "building floor colors" but it never completely matches the colors. Why? An example is shown in the screenshot below.
    3. Seems like, it's impossible to remove "height subdivision". Am I correct? It looks like it is possible to remove"width subdivision", so why not the height one???
    Снимок экрана (823).png
     
  3. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Check that all textures have read/write flags set to true. Otherwise, a script can't read those textures.
    In building material you have a value for Dirt Amount. This controlls overall dirt amount on all city buildings. You can controll this value only globally.
    You can't - floor color always influences building color, so those colors aren't separable. This is due to how shader works - due to optimization I had to drop support for separating those two colors. (as we have finite number of instructions that can work together).
    You can't remove both of them (height or width). Eventually, you can remove only on buildings that have less floors or width of a division frequency. Also, this is done for shader optimization purposes. having the ability to remove them would require too much instructions and would result in slower performance.
     
    anton88pro likes this.
  4. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    51
    Yay :) Oliver seems to be back from business trip

    Oliver, is it possible to add assembly definition files? CScape is used in a bigger project together with a lot of other assets. And assembly definition files can heavily reduce the compile time in a bigger project.
     
    olix4242 likes this.
  5. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    This is a neat idea and I will see to introduce it in a next version. Main problem is that it works only in Unity 2018.3 or later, so I will implement it when I drop support for Unity 2017. But probably dropping support this has to be done as Unity 2019.1 cycle is started and LWRP render pipeline is finished. So, you can expect new versions of CScape to work only with Unity 2019.1 with added LWRP support and assembly definition. I also hope that HDPR will enter it's final stage soon, so that i can finally give a stablke HDRP solution.
     
  6. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,871
    Let's be sure to get a version that works with 2018 LTS in there somewhere. ;)
     
  7. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Yes, there will be a CScape LTS version ;) With some bug fixes and improovements.
     
    hopeful likes this.
  8. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    51
    Maybe a folder with additional imports such as "AsmDefs.unitypackage" could solve this. So users interested in this can add this feature by importing the package. I'm not sure, but would think it works also for versions < 2018.3, because it is in a separate package. So it could simplify your struggle with different versions, at least a little.
     
  9. bahadir147

    bahadir147

    Joined:
    Mar 5, 2015
    Posts:
    1
    Does this work with LWRP?
     
  10. badradionz

    badradionz

    Joined:
    Feb 2, 2018
    Posts:
    19
    Oliver said (without directly answering my question on page 26) that he is working on LWRP 2019.1 version, so hopefully soon.
     
    Rzeznik likes this.
  11. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    hi @olix4242, I'm trying to use CScape on mobile and I get really terrible performance on android devices. From the profiler, it looks like it spends 600ms in GPU in "RenderForwardOpaque.Render -> Clear" for 99.5% of the time. So I assume your shader is pushing GPU out of its limits. I've tried it on P9 Lite - I know its rubbish but it is not that better on P20 Pro - which I would say is mid-high end phone. Haven't tried iPhone yet.

    Are there any tricks I can use to boost up the performance on mobile (android in this case)?

    EDIT
    I forgot to mention that I've already tried all optimization options included in cscape, no luck.
     
    Last edited: May 9, 2019
  12. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    All optimization options? There are so many, that it's pretty hard to guess what might be wrong. Unity on it's own has many optimizations that can be made. Have you done Occlusion Culling baking, are you using deferred rendering, realtime shadows, any post processing effects and so on.. Also, how big is the city?
    I didn't try p9 lite, so can't say anything abouit it's graphics performance and if it has some bottlenecks.
     
  13. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    Sorry, by all optimization option I mean all available as a button inside City Randomizer Script:
    - optimize performance
    - optimize for mobile
    - strip cs scripts

    I'm using forward rendering which should be lighter than deferred.
    Post-processing and shadows are switched off.
    As for occlusion culling and city size - well it doesn't matter if I generate a full city of size 10 by 10 or only one cell ... as soon as I put one single building on a scene then the frame rate goes down from 30 to 2-4 FPS.

    Is there anything else I can check?
     
  14. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    292
    Oliver,

    I made a collection of Building Templates and created a new Building Template Group. I added all of my templates (55 total) and when I add that template to the "Building Templates" section of the "City Randomizer" script and then press "Generate City" I get the following error:

    IndexOutOfRangeException: Index was outside the bounds of the array.
    CScape.CityRandomizer.Generate () (at Assets/CScape/Scripts/CityRandomizer.cs:379)
    CScape.CityRandomizerEditor.OnInspectorGUI () (at Assets/CScape/Editor/CityRandomizerEditor.cs:504)
    UnityEditor.InspectorWindow.DoOnInspectorGUI (System.Boolean rebuildOptimizedGUIBlock, UnityEditor.Editor editor, System.Boolean wasVisible, UnityEngine.Rect& contentRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1622)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    This happens if my template group has more than 29 items (I noticed that "MegaCityDistrictStyle" has 29 items) I created a copy of my template and reduced the number of items to 29 and did NOT get the error.

    Is this a hard limit? If so, is there a limit on the number of building template groups? I'm happy to have fewer templates per group, I just want to be sure.

    Thanks.
     
  15. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,871
    If you have Anisotropic Textures on "Forced On," try changing that to "Per Texture." I know that gave me much better performance with an earlier build.
     
    Rzeznik and olix4242 like this.
  16. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    No, there shouldn't be any limit. I will have to check - I assume that some arrays doesn't update themselfs as they should.
    Or, maybee it's one another thing: first building has to be small - one CS unit (3 unity units) - otherwise you might expect problems.
     
  17. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    292
    I made about 50 templates, added all of them, got error. Removed the last 20 from that list, did not get the error. The first template never changed, so I don't think that's the issue.
     
  18. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    It is already set to "Per Texture", but thank you for trying to help.

    I've made some more investigation on this mobile performance topic and there are 2 things that allow me to achive 30 FPS on this old mobile:
    1. scale down the resolution to 30DPI which looks like 480x320
    2. replace MegaCity1 shader to Mobile/Bumped Diff - this way I was able to get stable 28FPS even on the city of size 10 by10 however, I've lost all the goodies included in CSBuildingShader

    The next thing I will try is to lower the texture size for buildings and use it with CSBuildingShader.

    @olix4242 I've noticed that there is no LOD system for buildings, while streets and rooftop details have their own, is it intentional?
     
  19. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,871
    I would tend to think that reducing the texture sizes is likely to help. Please let us know if it does, and how much. It's just good to know. :)
     
    JBR-games likes this.
  20. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    Nope, no improvement. I've halved the texture and I've even quartered it, and finally I've removed all the textures - and still, there is no improvement.

    Either I'm doing something wrong or CSBuildingShader is just too heavy for android.
     
  21. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    559
    https://www.assetstore.unity3d.com/en/?stay#!/content/69651

    I use this imposter system with Seascape with noticeable improvements in performance at least in the unity editor at some point I will test it with Android device
     
    Rzeznik and JamesWjRose like this.
  22. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    @JBR-games nice trick!

    I've just checked exact same scene (default MegaCity complex with generated 1) Street Layout and 2) buildings) on iPhone SE - and for my surprise, it was able to render the scene with solid 30 FPS.

    For comparison, P9 Lite was on a "stable" 2 FPS and P20 PRO barely hit 12 FPS.

    Definitely, androids don't like CSBuildingShader, especially considering that P20 Pro is faster than iPhone SE for about 25%.
     
    JBR-games likes this.
  23. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    I don't think that it has anything to do with Android. I was able to to render VR (stereo) with Samsung S6 and Gear VR.. and it's a 4 years old phone. Also, those phones rendered perfectly any scene. On samsung 8 or later, I was been able to run extreme big cities.
    What I know is that some low end phones use crippled graphics - that doesn't natively support texture arrays - so it might all come to this. Didn't had any chance to test any of those phones. But I would suggest you to try one more thing: turn off mutithreading in build settings. It can sometimes interfere with graphics performance.
    If you want, you can send me an APK of your game, and I can test if it works on Galaxy S8 (or S6). If it doesn't work, than we can try to see if there is another problem related to compiling.
     
    Last edited: May 12, 2019
    Rzeznik and JBR-games like this.
  24. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    @olix4242 you are probably right, I've faced a similar issue with LG L7 II which had problems with GPU drivers.

    Will SystemInfo.supports2DArrayTextures show if this phone supports texture arrays? If yes then it supports.
    Also, I've turned off multithreading - no improvement.

    Will appreciate if you could check this scene on your Galaxy S6:
    https://1drv.ms/u/s!AksbvUebYlzFgacChlqXT0i5xxhvgg
     
  25. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Well, no. It will show that they are supported - but it won't show if there is a proper acceleration for them.
     
  26. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Ok, I just did a check on S8. Performance is in 15 fps range. Not too good. But I think that I know what could be a problem: you have activated parallax occlusion mapping on building shader - and it kills performance. Most mobile phones require to decativate it.
     
    JBR-games likes this.
  27. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    I've just tried it with disabled POM, nothing is changed. At least you get the same performance on S8 as I get on P20 Pro.

    I must be doing something terribly wrong, whatever option I change (opengles3, Vulkan, multithreaded rendering, merge meshes) there is literally no impact on frame rate :(
     
  28. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Can you send a screenshot of close up of any building? I wan't to check if POM is really disabled (just to be sure that script that manages it works as expected).
     
  29. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    You are absolutely right! I can clearly see the difference in the editor when I'm changing POM so this means it is working inside the editor, however on a phone no matter what I select the POM is always enabled.
     
  30. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Have you decativated or removed CScape City Randomizer component?
     
  31. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    Nope, to be sure I've just created a city from scratch with disabled POM, and it is still there.
     
  32. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    It looks like there is some problem with swithing shaders. Could be also a Unity bug.
    Here is a simple script that you should attach to any object in your scene. It should fix this issue.
    If it doesn't work for some reason, try to modify this script by changing lines
    Shader.EnableKeyword("_CSCAPE_DESKTOP_ON");
    to
    Shader.DisableKeyword("_CSCAPE_DESKTOP_ON");
    (just to check if we are dealing with Unity bug)
     

    Attached Files:

  33. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    None of those is working.
     
  34. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Strange. It should absolutely work. If it doesn't then we are definitely dealing with a Bug in Unity. What Unity version are you using?
     
  35. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    2018.3.0f2 ... because of other assets I cant switch to 2019.1
     
  36. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Ok, I've probably found where is your problem. New versions of Unity can strip out shader variants that they suppose that they dont need.
    https://blogs.unity3d.com/2018/05/14/stripping-scriptable-shader-variants/
    What happens is that non POM version of shader doesn't get included into your build.
    Article that I've posted explains how to include it (or exclude).
     
    hopeful, Rzeznik and JBR-games like this.
  37. Rzeznik

    Rzeznik

    Joined:
    Apr 10, 2016
    Posts:
    23
    Thanks again! I've forced the unity to disable the POM on a phone, but it is not much better. I mean the framerate is in range 12-16 but occasionally it jumps to stable 30 for a few seconds and it drops again to 15 for a few minutes. Maybe it's throttling ... I don't know yet.
     
  38. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    559
    I tested your apk on my LG v20 and it was noticably slower compared to a version i built with cscape. Although mine was using unity 5.6 at the time.
     
    olix4242 and Rzeznik like this.
  39. JoxyAlexandru

    JoxyAlexandru

    Joined:
    Feb 23, 2019
    Posts:
    1
    Hello
    I tried to import the game on my phone for testing and the city is seeing very ugly black without the light rendering.
    I get a lot of bugs on the rooftop!!!....
     
  40. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Can you post me a screenshot? Images sometimes speak more than words.
     
  41. Evil-Otaku

    Evil-Otaku

    Joined:
    Oct 17, 2012
    Posts:
    25
    Is there a way create a Central Park like area? My ultimate goal is to be able to mask out a Manhattan Island type area then generate the grip map on top of it.
     
  42. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    152
    You can just delete the buildings you don't need and create a park there.
     
  43. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    292
    Oliver,
    I'm attempting to change the textures however I am getting an odd situation. To start I changed only one texture: \Assets\CScapeCDK\Editor\Resources\CScapeToolset\Surfaces\basecolor_surface_01.png and it's normal file: normal_surface_01.png

    I replaced it with an image I purchased from GameTextures.com (great site, I highly recommend) and it's normal image. The new image is 512x512, as it's normal, just like the original image. When I press the "Compile all textures" I get this issue: https://imgur.com/a/u4PoGq5

    I re-imported the CScapeToolsetSources package and the original image basecolor_surface_01.png was again the bricks you include. However, even after pressing the "Compile all textures" button the city still looks wrong. No errors are showing up in the console. I have opened and closed the project, rebooted my machine and still the issue persists. I also tried recreating the city by pressing the "Generate City" button, but still the issue persists. I also deleted the city from the project Hierarchy and then added it again, and again pressed the Generate City but still the issue persists.
    I then deleted the CScape folder in the project, but NOT the CSCapeSDK folder, and then again added a city to the scene and pressed "Generate City". This time when the city is generated the original brick texture is used and the city looks correct.

    So there seems to be a couple of issues... but I don't know how to proceed.

    Thoughts?

    Thanks
    James

    -----------------------------

    EDIT 1: I created a new project on a different system, added CScape and the CScape Toolkit, changed the one image (basecolor_surface_01) and pressed "Compile all textures" without any issue. The new image is used on the buildings. I'm not sure how this helps, but I wanted to let you know.

    -----------------------------

    EDIT 2: DratsDratsDrats. Turns out I am getting warning messages (had only Info and Error buttons pressed on the Console... my bad!) Even without changing the original image, when I press the "Compile all textures" on my development machine (as opposed to my laptop in "Edit 1") I get 163 instances, at a count of 10 warnings per instance, on the following message:
    Graphics.CopyTexture with a region will not copy readable texture data for compressed formats (source texture format 12)
    UnityEngine.Graphics:CopyTexture(Texture, Int32, Int32, Texture, Int32, Int32)
    CSMaterialTools:CreateStyleShapes() (at Assets/CScape/Scripts/CSMaterialTools.cs:117)
    CScape.CSMaterialToolsEditor:OnInspectorGUI() (at Assets/CScape/Scripts/Editor/CSMaterialToolsEditor.cs:57)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    You and I have gone over this before, a few months back. Sadly, neither of us found a solution. I will do more research. Let me know if you find anything.
     
    Last edited: May 31, 2019
  44. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    402

    in the US the interstate highways standard width is 3.7 meters. which is what my world scale is based upon. my vehicles barely fit in their lane so it makes it difficult for my users. i tried the tiling you suggested but it doesnt appear correct. gets rid of some of the road lines and stuff.

    was hoping we can maybe get 2 separate scales or something because this has been a problem for me since it was released.
     
  45. HBK_

    HBK_

    Joined:
    Dec 1, 2017
    Posts:
    86
    Hi Oliver,First of all great job for making this awesome asset and making it affordable for small devs like me.
    I purchased it this week and didn't got time to play with it but now i played with it little bit i have some problems.
    I Made a new scene and made a default cscape mega city (simple) with all default settings and it was telling me to "Turn Off Lightmap Baking" i did that and i am making it for mobile so i generated the scene without the lightmap baking and after few minutes the light was generated and nothing happened.When i played the scene in editor window the streets were still black Here's the screenshot https://imgur.com/a/yHUNxB4 and ran it on android device and voila the streets were colored but the performance was the lowest i could imagine.I have S9+ and the device barely loaded the scene and the fps was 10-15 i thought that's because the lighting is not baked or something so i turned on the lightmap baking and used the same progressive lighmapper and in 10 seconds my display driver crashed....it happened everytime i used progressive lightmapper with baked lighting on.

    I want to use baked lighting because it really boosts the performance of game in mobile and now i don't have any idea how can i bake the light while using cscape.It only shows the light in device but i need to see streets and the look and feel of my game in editor too.

    and also there is almost no documentation rather than some videos which explains the basics of the older version but this one is different from them.

    Other than that the asset is great so far.I am able to make an awesome city in just few clicks.Peace.
     
  46. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    Main problem with baking large city is that it requires much of a video memory. City has a large surface 3D area (you have to count for tall buildings and a space that lightmaps occupy in memory). Baked light for this kind of scenarion on mobile is almost impossible to do right.
    You are probably getting crashes because of too much Vram required. You didn't mention your build sizes.
    Also, be cautious with progressive lightmapper - it is still in experimental version, and it i'ts better to be used in developement phase.. and not for builds.
    There is a bug in latest unity with simple Cscape city (it happens on some systems) where it doesn't work correctly. Create Complex city, and deselect Use Quadtree and slanted streets and you will get a same city as "simple".
     
  47. HBK_

    HBK_

    Joined:
    Dec 1, 2017
    Posts:
    86
    Its 156MB and i used progressive lightmapper on games with 500mb+.
    yeah it was on earlier versions of unity but the one which i am using,its released.BTW i am using Unity 2018.2.18f1.

    apart from those i changed the lighmapper from progressive to enlighten and made a new scene and changed the lightmapper there too and did this
    and sadly the result was same the streets are black and buildings are colored https://imgur.com/a/fQqlpwj and i did not checked on android for this same behaviour
    but i assume it would be same.

    In conclusion,The streets are black in editor and i cannot see anything colored except the buildings and the performance sucks dude,I Have i7 processor with 16 gb ram and 1080ti graphics card and my unity literally crashes whenever i try to select the Cscape City Object in hierarchy or try to move through the city.I mean if it doesn't work on the pc then how am i suppose to expect good performance in mobile And how am i suppose to make a game,missions,etc if i cannot move through the city.To be honest i was very hyped about CScape and saw many videos and it looked very smooth there but now i have tried it myself i am little bit disappointed.
    Using the asset causes Lag like i am running it on 2005 computer,I worked on much more larger projects than this and never experienced this.I don't know how can i make a game with this much lag and unity not responding.Some Real Help Needed.

    Few questions, How does lighting in CScape works and is it compatible with mobile,I mean is it an optimised way of lighting for mobile?

    Do i need to bake light or just make the city and drop my player in it and play?
    and if i do need to bake light then HOW? because it just does not allow lightmap baking and relatime lighting is Not So Much Mobile Friendly as far as i know.
     
    Last edited: Jun 21, 2019
  48. HBK_

    HBK_

    Joined:
    Dec 1, 2017
    Posts:
    86
    https://imgur.com/a/7rHXSvU Take a look at this.Its the street shader and its just black no grate texture no ashphalt texture no noise,nothing like the shader is broken or something so i tried reimporting again and nothing happened.Any Help?
     
  49. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,452
    With that configuration you should have around 800 - 1000 fps in editor. Can you please check in unity profiler what steals your time? Can you please also check this by opening CScape Demo scene so that we can see if it has a same problem.
    As for bnlack streets, did you check that you aren't using Graphics Emulation? (go to Edit/Graphics Emulation and set it to "No Emulation". Also, be sure to check that your build settings Graphics Api is set to GLES 3.0?
    If you make a new and fresh project, import only CScape, does this behaviour still happens?
     
  50. HBK_

    HBK_

    Joined:
    Dec 1, 2017
    Posts:
    86
    It is set to OpenGLES 3.0...One Question,Does It Not Work With Vulkan?

    After doing this the black street issue is gone but now i have Magenta Street Issue which doesn't look good either https://imgur.com/a/dcZ1qrV Here's The Screenshot....sorry for such a small view of street but the unity's scene view stuck there and unity stopped responding AGAIN!.
    We'll talk about that issue later...first i need a city which looks like city so please first help me with the Street Issue...I'll find that unity stuck issue's solution later and again that same question,Does it work with Vulkan?
     
    Last edited: Jun 22, 2019