Download

Advanced level streaming techniques?

Hello,

I am currently working on an RPG game with a procedural generated dungeon, pretty much like described in this article: http://gamedevelopment.tutsplus.com/tutorials/bake-your-own-3d-dungeons-with-procedural-recipes--gamedev-14360

I have implemented this the following way:

  • Every room and/or corridor is a blueprint representing the room geometry with a few child actors for torches, chests, crates and so on. Every room has several custom components that function as doorways/exits.
  • Upon loading a level, the level blueprint runs the generation code, selecting a room blueprint from a list, selecting an unconnected exit from the existing level geometry and transforming the newly spawned room, so that the selected exit and one of the exits of the new room align correctly, taking existing geometry into account and restarting the process when the new room would collide with an existing one. This processed is repeat a certain number of times until a somewhat acceptable dungeon has been built. I use a custom “spawn into level” blueprint node to add the spawned rooms to the correct streaming level instance so they disappear when the level is unloaded.
  • Every level (as in streaming level) represents a single floor of the dungeon and the final exit is a special ‘floor transition blueprint’ which upon activation by the player creates a new instance of the dungeon streaming level, transforms it roughly 2000 units on the negative z-axis and moves the player to the entrance of the new instance, where the whole random generation starts again.

This basically gives me a random dungeon that I can keep going down as long as I want or until I get killed. It works okay, but using blueprints for building a room is a bit cumbersome and has some disadvantages:

  • I can only use dynamic lighting. However, some of the rooms would certainly look better if some lighting could be precomputed.
  • The blueprint editor is not really suited for working with actors that have rather large number of components. It also does not preview the blueprint with correct dynamic lighting

I was wondering if the whole process can and should be reworked by using a streaming level for each room, creating an instance of the room and transforming it accordingly instead of room blueprints. Would this allow using precomputed lighting? Is transforming and therefore moving/rotating an instanced streaming level possible after it has been loaded, as the placement algorithm I currently use requires it? Is there an option to find all actors that only belong to a specific streaming level instance so I can easily find all exits/doorways of a room? Are there maybe any planned or upcoming changes to the level streaming system that would make this a lot easier to achieve?

I know these are a lot of questions but I was hoping to get some input about how other people might implement this (or already did implement something like this). Of course, changing an already working system is quite some work so the benefits should really be noticeable. I am not afraid of using more C++ code to improve this, however, I would like to avoid making changes to parts of the engine itself.

Any input is appreciated. Thanks in advance!

even if you managed to spawn levels that have the lighting pre-computed, you will always have seams where they connect.
light that leaks from one room into a corridor will not work because, well, the corridor isn’t there when you compute the light. therefore you’d need to make sure your lights never go as far as the entrances of the room, which would probably greatly limit the visuals and isolate them into really obvious ‘dark’ and ‘bright’ areas
or you’d need to always put doors at the entrances, but as soon as you open the door you’d immediately notice a different lighting in the other room (and you’d never be able to have light dynamically leaking as you open/close the door)

my UDK game does pretty much what you describe (change the word blueprint for prefab, and use a different random dungeon algorithm and you’re there), and dynamic lighting was always the obvious choice for me

@Mark: Would you not rather use Dynamic Lighting and then instead of using PBR materials rather use Pre-Baked Materials with Specular and AO Maps?

To me it sounds like your original approach to make each room a BP is the correct one. I would then ensure my textures have the lighting built in to the Difuse and then apply a Specular and AO map to the objects. This won’t give you as nice lighting as you want but it should still look pretty good.

I am actually doing something similar for a portion of a project that I am working on, the only difference is my Dungeons are procedural generated the first time a player enters them and then are stored from then on.