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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

DunGen - Procedural Dungeon Generation

Discussion in 'Assets and Asset Store' started by Aegon-Games, Mar 7, 2014.

  1. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    177
    You're welcome! No need to feel stupid. I have come across things where it was so simple and I over looked it. Glad it's working for you.
     
  2. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    Hello,

    For the Local Prop Set, it chooses random prefabs to keep and discards the rest, but is there to way to also make this work for props inside furniture like cabinets?

    I have cabinets that I want to be placed randomly throughout the dungeon, but those cabinets will also have props inside such as tools, bottles, etc. Is there a way to make DunGen randomly select which props to keep inside the cabinet while also keeping the cabinet itself a random spawn?

    The two options I can think of is to either 1.) not have the cabinets be random and just have the props inside them be random, or 2.) create a lot of variations of the same cabinet with props I place in them manually and have the cabinet be a random spawn.

    Is there a way to have the cabinet and the props inside be random at the same time?
     
  3. DevelopGamer

    DevelopGamer

    Joined:
    Nov 22, 2014
    Posts:
    24
    Hi,

    Happy New year, and thanks for a great asset.

    I was wondering why the tile in the castle tiles example is called 'one way tile', since it only has allow rotation and repeat mode set on it? I don't see how that makes it one way!

    Hopefully I'm missing the point, I'd appreciate any explanation.

    I'm also having a more serious issue. Half the time my dungeon is disconnected. My tiles consist of a start room, a corridor and an end room.

    Is there any reason why it's not connecting?



    https://ibb.co/pr14Q1q
     
    Last edited: Jan 10, 2020
  4. swogdog

    swogdog

    Joined:
    Jan 7, 2013
    Posts:
    14
    First, let me say that this asset has been really easy and fun to set up and start playing with right out of the box, excellent job!

    I had a couple things I'm trying to work out, and I searched the thread as best I could before posting, so please forgive me if these are repeated questions.

    First, is there any way to have no "open" or even "blocked" doors? If I understand correctly, it's meant to have blockers for any doors that might open into space, but my situation requires having no doorway pieces being used instead. I hope that makes sense.

    The second problem is I also need to be able to make sure that certain connections are mirrored. So like, the left side of a certain door type needs to match up to the right side of the same door type on the connecting tile, and should never flip from that. Is this possible?

    I feel like that might be too vague! Let me know if I need to try to explain further.

    Thanks!
     
  5. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    16
    I got this error:

    "Tile prefab ... (UnityEngine.GameObject)' has automatic bounds that are zero or negative in size. The bounding volume for this tile will need to be manually defined."

    I searched the documentation and found that I might need to put a Tile component to the prefab. I then opened the prefab and added the Tile component and checked the "Override automatic tile bounds" and pressed Fit to tile.

    tile-component-settings.PNG

    prefab-bounds.PNG

    But I still get the error when I enter play mode. Dungeon is generated though.

    I'm using uModeler to create the tiles. Any help?
     
  6. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    Sorry for the late replies.

    It's one-way because it only has two doorways, and the prefab has a Tile component attached to it which specifies which doorway should be the entrance and which should be the exit.

    I've never seen a dungeon disconnected like that before - I'm not really sure what would cause it to do that. If you haven't already, could you try selecting your dungeon flow asset and hit the "Validate Dungeon" button that appears in the inspector. That should let you know if there are any common configuration issues.

    If that doesn't work, could you please send me a small project that demonstrates the issue to support@aegongames.com


    A doorway's blockers are for when the doorway is not going to be used at all. They can be anything you want - In your case, you could just use a wall segment as the blocker so it looks like there was never the possibility of a door being there. This is what the "Basic" sample does for its unused doorways.

    To guarantee that doorways are correctly mirrored, you can use a connector prefab that has both sides of the door frame in it. Only one prefab is chosen per doorway-pairing, so you don't have to worry about overlapping meshes.

    I hope that helps.


    I've never used uModeler, but ProBuilder has caused similar issues in the past so it makes sense that the automatic bounds might not work properly. But still having problems after switching to manual bounds is a new one.

    The overridden bounds in your screenshot should be fine and I don't know why you're still getting the error. Are there any other errors or warnings? Are you perhaps getting the error for a different tile?

    As you said, the error won't stop the dungeon from being generated so you could just ignore it, but having errors every time a dungeon is generated would get annoying fast.
     
  7. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    I found out that I can mix Local Prop Set with Random Prefab to do this, but there are restrictions. It seems Local Prop Set is executed before Random Prefab. So if I use Local Prop Set on a tile, with a cabinet being one of the objects, I can also use Local Prop Set in the cabinet prefab to randomly select which objects to keep inside the cabinet.

    However, if I use Random Prefab for empty gameobjects in a tile (which can spawn a cabinet), and then use Local Prop Set on the cabinet, the Local Prop Set on the cabinet won't get executed.

    So I currently have this situation: I have empty gameobjects in a tile all using Random Prefab to randomly select a random cabinet to spawn. Each of these cabinets also have empty gameobjects inside them that also have Random Prefab scripts that can spawn props. The problem is that I can't have it choose a random number of props to spawn in the cabinets. If I attach a Local Prop Set script to the cabinets and put in all the empty gameobjects from the cabinet so it can choose a random number to keep, this script doesn't get executed because the cabinet spawned as a Random Prefab.
     
  8. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    Yeah, ideally the prop scripts would be processed recursively so you can nest them as much as you want. I don't think that will be a problem except for the global props which have to all be processed at the same time. I'll look into it and see if it's something I can include in the next version.
     
  9. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    That would be great. Thanks! Been having to go back and forth with some design decisions because I couldn't get the Random Prefab and Local Prop Set to work together properly.
     
  10. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    Version 2.13.0 - Available on the Asset Store
    Be sure to backup your project before updating to a beta version of DunGen.
    Released on the Asset Store as of 05 May 2020

    2.13 contains a major change to the way the generator works internally, so there may be more bugs than usual. This version will remain in beta until I've thoroughly tested everything. You should expect the same results (just faster), though the same seed won't produce the same dungeons between 2.12 and 2.13.

    Enhancements

    • [New in Beta 3] Tiles prefabs are now only instantiated after the entire dungeon layout is generated, resulting in much faster generation times
    • Local Prop Set and Random Prefab props can now be nested properly. Global props should still not have other props nested inside them, but can be nested inside others.
    • Archetypes can now be be marked as unique. DunGen will try to ensure that unique archetypes are only used once throughout the dungeon.
    • When using the 'Full Dungeon Bake' mode with the built-in Unity NavMesh adapter, it's now possible to use your own surfaces for more control over settings by unchecking the 'Auto-Generate Surfaces' checkbox.
    • [New in Beta 2] The Door component now contains a 'DontCullBehind' property to allow doors to be closed without culling rooms behind it. This works for the built-in culling and the SECTR VIS integration
    • [New in Beta 4] Doorway connector & blocker prefabs can now all be assigned weights for more control over how frequently certain objects spawn

    Bug Fixes
    • [New in Beta 2] Local prop sets now correctly work with objects attached to door connectors & blockers
    • [New in Beta 2] The SECTR VIS integration will no longer throw an error if a door already has a SECTR_MEMBER component
     
    Last edited: May 5, 2020
    hopeful, camta005 and Vincent13122 like this.
  11. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    The new beta version above should let you properly nest props now.
     
  12. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    Thanks for the quick update. From my initial testing, everything seems to be working properly.
     
    hopeful likes this.
  13. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    I'm having another issue related to props. When placing them, I'm keeping the space in front of doorways empty in case a door spawns there. But from looking at the dungeon crawler demo, I realized that I can put props as Scene Objects in the Blockers list and it will delete those props if that doorway becomes a door.

    The problem is that if I use Local Prop Set to set how many props I want to keep in the tile, it won't be accurate if I include the props in front of doorways that I set as Blockers. It looks like the doorways are processed after the props are processed. So for example, I have 4 doorways in my tile with 1 prop in front of each doorway set as Scene Object Blockers for each corresponding doorway. Let's say that 2 doorways were chosen as connectors. If I set the Local Prop Set to keep 2 props and it happens to choose the 2 props in front of the doorways that were chosen to be connectors, it would seem like no props were kept at all because the 2 props that were chosen to be kept were deleted by the Doorway script.

    Would it be possible to have the doorway processing be done before the prop scripts processing so that the Local Prop Set will have an accurate number range? Or is there a better solution? Thanks in advance.
     
  14. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    46
    Hi,
    we have been trying this extensively and overall we are happy, but we have some major concerns:
    • Generating process is really slow, you are using full prefabs to do the tries and when the tiles are something different then the usual indie low polygon stuff (your examples) it gets really demanding and slow. We have seen 28GB ram taken when creating a mid size dungeon. Is it possible you do the generating process with bounding boxes instead of the full prefabs? that will speed up drastically the generation speed and memory involved in the process.
    • When the generator finds and error, it simply restart from scratch instead of coming back to a "safe" point and restart from there.
    • Can the main path have an option to make it straight? (as branches do)
     
    christougher likes this.
  15. philwinkel

    philwinkel

    Joined:
    Jun 6, 2013
    Posts:
    313
    Is DunGen deterministic? eg given a specific seed and the same inputs , would DunGen be able to create identical dungeons on multiple clients?

    For example, imagine a networked multiplayer game using DunGen runtime generation - is there a way I could generate identical dungeons on two clients?

    I'm trying to determine if using DunGen for real-time generation in a networked scenario like this would require me to replicate the generated dungeon across the network on my own.

    Thanks!
     
  16. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    According to the documentation, it says this about the seed:

    So with the same settings and the same seed, it looks like it should be able to.
     
    Aegon-Games and philwinkel like this.
  17. philwinkel

    philwinkel

    Joined:
    Jun 6, 2013
    Posts:
    313
    excellent, perfect thank you mate. I skimmed over the docs but missed that part. I will give it a try!
     
  18. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    When using DunGen with SECTR VIS, the rooms that the player isn't currently in is culled unless isOpen is set to true for the door, but is there a way to set the door to be closed and ignore culling if the door is a see-through door such as a jail cell door, or a door with windows?

    I'm also having another issue with SECTR VIS and getting this error when it tries to add my doors:

    Code (CSharp):
    1. ArgumentException: An item with the same key has already been added. Key: Door_02A(Clone) (UnityEngine.Transform)
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <567df3e0919241ba98db88bec4c6696f>:0)
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <567df3e0919241ba98db88bec4c6696f>:0)
    4. SECTR_Member.OnEnable () (at Assets/Procedural Worlds/SECTR/Scripts/Core/SECTR_Member.cs:476)
    5. UnityEngine.GameObject:AddComponent()
    6. DunGen.Adapters.SECTRPortalCullingAdapter:PrepareForCulling(DungeonGenerator, Dungeon) (at Assets/DunGen/Integration/SECTR_VIS/SECTRPortalCullingAdapter.cs:90)
    I tried both SECTR Complete 1.3.6 and the newer version 2019 version and both have the same issue.
     
    Last edited: Jan 31, 2020
  19. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    46
    camta005 likes this.
  20. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    Sorry for the late replies, forum notifications are going to my junk mail again. I'll try to check for new posts regularly from now on.


    The doorway processing is done before the props are processed but because Unity's destroy method doesn't complete until the end of the frame, objects pending deletion were still being used.

    As far as I know, there's no way to check if a Unity object is being deleted, so the new beta version waits one frame after processing the doorways before it continues with the props. This only works if 'Generate Asynchronously' is enabled in the generator settings.

    For the culling issues, the new beta version adds a 'DontCullBehind' property to the door component and I think the error has been fixed (it looks like your door already had a SECTR_Member component and DunGen was trying to add another).


    I already use a proxy object to test possible tile placement positions, but it instantiates the actual prefab once it's found somewhere to put the tile. Generating the entire dungeon before placing a single prefab has been on my to do list for a while but it could require some major reworks so I don't know how long it will take. I'll give it a try today and see if I can get something working.

    The generator does backtrack a bit, but it will give up and start from scratch if it fails too many times. I don't want to allow it to backtrack the whole way because there could be an issue at the start of the dungeon preventing it from finishing and restarting would actually be the faster option.

    The straightening option is on the archetype so it should work for both the main and branch paths. Nodes on the graph might cause the path to turn though - I'll see if there's anything I can do about that.
     
  21. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    46
  22. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    With "Generate Asynchronously" enabled, all the objects in the tiles with gravity seem to fall through the floor, including the player.

    For the culling issues, the error isn't happening anymore, but setting "DontCullBehind" doesn't seem to work. I have a script that sets that variable from a Start() function, but the OnDoorStateChanged event isn't being called.
     
  23. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    To make it work properly when the dungeon is generated synchronously, I'll need to rework some stuff to allow it to still wait a frame after the tiles are placed, but before the props are processed. I could just use DestroyImmediate() instead but I'm hesitant to do that. I'm looking into it now.

    Yeah, the 'DontCullBehind' setting didn't call OnDoorStateChanged so it wouldn't work immediately if you set the value through code - you'd need to have the door open and close again first. I've pushed a new version of the beta with a change that automatically refreshes the door, so hopefully it should all work properly now.


    I just wanted to give a quick update on the change to only place tile prefabs after the entire dungeon has been generated. It's taken a while but I'm making some progress. It looks like I should be able to have it implemented in a reasonable time frame after all, possibly some time this week.

    I'll need to do a lot of testing to make sure everything still works properly because this is a big change to the generation process, but it should provide a big boost to generation speed.
     
    hopeful likes this.
  24. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
  25. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    46
    Great. Will let you know.
     
  26. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    46
    Confirming Beta3 is working much better.
    Only thing is that bounding boxes are not shown up in asynchronous mode which is helping for debugging.
    Thanks for that one @Aegon-Games
     
  27. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    For doorway connectors, if I add two random prefab doors to the list, does each have a 50% of chance of being chosen if that doorway is chosen to have a door? Is there a way to change it? I have several random doors, and a single empty door frame but I want the chances of the door frame being chosen to be the same as the doors combined so that I don't get too many doors spawning.

    For example, if I have 3 doors on the list and 1 empty door frame, there's a 75% chance that a door will be chosen and only a 25% chance for the empty frame, but I'd like it to be 50% for the doors and 50% for the frame. I guess I can just add the empty frame 3 times to make it even.
     
  28. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    Published DunGen 2.13.0 (Beta 4)


    That's definitely something I want to add back in.


    Adding the same object to the list multiple times was the only way to control the likelihood that a specific object would be chosen. I've added a weight to the doorway prefab lists in the new beta version that should make this much easier.

    Also, the new beta version should now allow you to use local prop sets with doorway objects properly even when "Generate Asynchronously" is unchecked.
     
    camta005 likes this.
  29. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    After importing Beta 4, I'm getting this error:

    Assets\DunGen\Integration\SECTR_VIS\SECTRPortalCullingAdapter.cs(84,25): error CS1061: 'Doorway' does not contain a definition for 'HasDoorPrefab' and no accessible extension method 'HasDoorPrefab' accepting a first argument of type 'Doorway' could be found (are you missing a using directive or an assembly reference?)


    I also tried removing the entire DunGen folder and reimporting the whole thing, including the integrations.

    Also for the weights, it wasn't explained very clearly in the documentation on how it works, but I'm assuming if I have three doors and one empty door frame total in the list and the three doors have a weight of 1 and the empty door frame has a weight of 3, the empty door frame will have an equal chance of spawning when compared to a door?
     
  30. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    having a problem with sectr vis implementation and multistory tileset... all i see is doors to the outside then i go through them and it pops in with next tile. any ideas what the problem could be? how do increase the range of sectr vis so that i can see the next tileset at least?


    upload_2020-2-8_8-1-8.png

    i need to see at least one tile ahead to stop it looking janky any ideas?
     
  31. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    i changed a few settings and it seems to work now! :)
    upload_2020-2-8_8-31-58.png
     
  32. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    is there any way to just see a few tiles ahead instead of the entire dungeon?
    answer. change the camera far clipping plane. :)
     
  33. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    okay i have tried to build this into an executable and getting 30 errors any ideas what i need to do?
     
  34. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    The new beta build fixes a lot of the issues you're having, including some additional new features, but it also has its own new errors too. So I'd just wait until Beta 5 comes out.
     
  35. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    Sorry about that. I renamed some things and forgot to check the integration packages. It should work now.


    I'm not getting any build errors on the asset store build (2.12.1) or the beta (2.13.0). What errors are you getting?
     
  36. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    Is there any way to add monsters to the dungeon with minimal coding... some sort of asset integration?
    i am thinking maybe with astar integration + playmaker? are there assets that i can just bolt in to dungen to have wandering monsters? if push comes to shove i will just port the whole dungeon into atavism. Any simple solutions?
     
  37. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    upload_2020-2-8_12-35-7.png
    these are the compile errors after integrating with sectr complete
     
  38. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    46
    i want to generate the dungeon then save it as a prefab and use that as a level for the executable.
     
  39. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    Thanks for the quick update. It's working fine now.

    I was wondering if you have any suggestions on solving some reflection probes issues

    1.) I started doing the lighting for my level and realized that reflection probes can't rotate. So when the tiles are placed in a random rotation, the reflection probe's size doesn't rotate with it, resulting in weird lighting issues. The only way I can think of to solve this issue would be to not allow tile rotation, but then my tiles might look too similar and face the same direction each time. Is there a way to fix this issue and keep tile rotation on?

    2.) Since I'm using occlusion culling, the reflection probe (set to Realtime, with Refresh Mode set to On Awake) doesn't get updated until that room is visible, or until a door for that room is opened. When I first open a door for that room, often times it would appear dark while the reflection probe is updating. The problem seems to go away when I set the Refresh Mode to every frame, but that seems like overkill for performance, especially since this will be a mobile game. What would be the best way to solve this?
     
    Last edited: Feb 8, 2020
  40. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,110
    On the reflection probe ... I'm surprised it is taking a long time. Perhaps you can reduce the range, reduce the resolution - things like that - to make it faster?
     
  41. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    499
    It seems like you would prefer to have your reflection probes set to realtime viaScripting... then call ReflectionProbe.RenderProbe once everything else is placed...

    https://docs.unity3d.com/ScriptReference/ReflectionProbe.RenderProbe.html

     
  42. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    I was thinking of doing that, but then I set them back to On Awake and tried to reproduce the issue again and couldn't get it to happen again. I'm not sure how DunGen generates the levels in terms of when the Awake method for reflection probes are called. If it's called after everything is placed, it's pretty much the same thing as using my own script and calling RenderProbe() after DunGen completes the generation.
     
  43. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    You can use the prop placement scripts to randomly place monster prefabs throughout the dungeon, or place them in the rooms manually if you don't care about randomising them. Outside of those options though, there's nothing built in to DunGen - I felt monster spawning logic was too game-specific for an out of the box solution.


    Looks like SECTR is trying to register a SECTR Member component on an object that already has one. This probably means that you already have a SECTR Member component on your door prefab and DunGen is trying to place another one. You can either remove the existing component or upgrade to the 2.13 beta which fixed the issue a little while ago.


    You could write a custom adapter for DunGen to render the probes during a post-processing step after the dungeon is complete but before the culling is processed. That should render the probes before the culling disables anything. Here's an example.
     
  44. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    Thanks for the code example, but how do I make sure it's ran before the culling adapter? I'm using the original "SECTRPortalCullingAdapter" DunGen comes with and I don't see a way to set the priority since it doesn't use the RegisterPostProcessStep method.
     
  45. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    The SECTRPortalCullingAdapter component should have a priority field that defaults to -1, so anything higher than that should ensure your adapter runs first.

    upload_2020-2-15_12-16-30.png
     
  46. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    Thanks. I was wondering what that variable was for when I first saw it since it has no tooltip.

    I think I got it working now, but after the level loads it takes a while for the reflection probes to update and I can actually see the tiles having some white overlay before the reflection probes update. I'm guessing I should spawn the player after the dungeon generation is complete instead of having the player already in the scene before it starts, but I was wondering if GenerationStatus.Complete takes into account the rendering of the reflection probes. Like if it returns true, does that mean everything is done, including the reflection probes updating? If not, is there a way wait until it's done before spawning the player?
     
  47. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    The complete event happens after the post-processing steps, but reflection probes might update over a frame or two - I'm not sure.
     
  48. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    I've been trying to get DunGen to work on mobile (Android, Unity 2019.3.3, linear color space, and tried both deferred and forward rendering), but have been having some performance issues. The generation seems fine and is quick enough, but the fps during gameplay is really bad. I even tried testing the dungeon crawler demo on mobile and that had really low fps too. I've been trying to figure out what the issues are. I'm guessing it's because of all the real time lights and shadows. In the dungeon crawler demo, the number of batches is usually over 3,000.

    Because the dungeon is generated in real time, I'm guessing the lights and shadows have to be real time too. Is there any solution to make it work well on mobile?

    In the worst case scenario, I was wondering if it's possible to save the dungeons that DunGen generates into a prefab and then create a separate scene for each one, bake the lighting, and just use those pre-generated dungeons in game. If so, how could I use the A* and SECTR VIS adapters on those pre-generated dungeons?
     
    Last edited: Mar 3, 2020
  49. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,110
    Generally you want to keep the viewable area small so it is easier to manage, and you keep lights turned off / no shadows / unimportant unless you specifically need them on / casting / important. Shadow distance would preferably be short. LOD type techniques could be helpful, including LOD levels that disable shadows on small objects and mesh renderers when distant.

    An alternative to occlusion culling is to use mesh combining and atlasing. Also, an object pool can be helpful in many situations.

    If you aren't already doing stuff like that, it could be a good place to begin working on efficiency. These practices are essential even on desktop.
     
  50. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    128
    I tried mesh combining before, but draw calls were still in the thousands. Occlusion culling brings draw calls down to a few hundred at most.

    I did some tests and my level without any lights runs at around 30-35 fps on my Samsung Galaxy Tab A, which I guess is acceptable, but once I turn on lights (even with no shadows), it drops to around 5 fps.

    I know it won't be as accurate without the props, but is there a way I can bake the lights/reflection probes/light probes for each of my prefab rooms? The lightmapping data seems to be saved for the scene, but I was wondering if there's a way to save that data on each room prefab itself.
     
unityunity