Download

Shadows on procedurally generated map

Hello.

I have game with procedurally generated map, that means, that i can’t build lighting and shadows. And if i want shadows in game - they need to be dynamic even if it’s just a wall that not moves.

http://images.akamai.steamusercontent.com/ugc/103977589468758557/DB62FE63AE494352FEE0ABE4F578DCDFFC26843E/

So is it possible to somehow optimize that? Or maybe it’s possible to build lighting inside BP? Or just disable updating of some shadows?

Alpha version can be downloaded here: rooMaze by Chair killing

The light buliding process is not available at runtime, but even then it would take minutes or hours to execute which is most certainly you dont want to do. The player would interpret the situation as a frozen game.

You should be able to generate your maps before, and just build the light on the statics, save them as individual maps and you are done.

@Konflict: You can’t spawn actors in construction script, you’re limited to only static meshes (geometry). If his map creation relies on actors, it can’t be moved into construction script.

You may have to use dynamic lights.

According to this post there is workaround to this limitation, but the warning from [MENTION=2437]Nick Whiting[/MENTION] just below the post should be considered before doing so. Also, in [MENTION=28980]Ali Akbar[/MENTION] 's Dungeon Architect there is a way to assemble full maps at design time without limitations as such.

This technique however is only applies if the maps are not randomized (and not re-aligned) on each run, in which case the dynamic light is the only remaining approach. Also, other shadowing techniques are available for implementation that would bring new possibilities for dynamic scenes to be applied, tho i’m not familiar with the details regarding this library.

I don’t want to use pre-generated maps, because it will kill all random. If there no way to optimize it - I’d rather leave it the way it is :frowning:

Actually you have great many ways to improve the overall scene performance, this includes the rendering techniques and composition you apply. For example, you can change the static meshes to be instanced meshes (where applies) which possibly will give you some level of performance boost. You should use the editor’s debuging facilities to monitor and filter out the perfroamnce heavy operations, then just apply some limitations to your generated scenes based on certain thresholds to make sure you never go over budget with your content. You also can provide ingame settings menu for the user to set up eg. the shadow quality to choose between the performance vs quality presets, or simply exposing some shadow configuration options in the menu ui.

Also: level streaming! There is even a youtube tutorial which creates randomized levels using level streaming…

I approve Zireael07 idea, sounds like the most efficient way of doing it.

each room is a level and is baked. At runtime, via level streaming, you load random rooms. I dont’t know if it’s going to be easy to have a baking that looks uniform between all those rooms though.

If the contents of the room don’t change, maybe bake lightmaps on a per-room basis and have “unlit” materials on each, with the baked results plugged into the emissive channel. That would only work though on individual rooms that don’t change in the slightest, which if you’re going for randomness I doubt is the case.

Or maybe a little bit of both? While the lightmap baking will produce high quality shadows, the rooms will most likely loose most of their customizations. But, as thinking in terms of level streaming, only the content required for the current room the player resides have to be rendered, and the rest can be queued to be executed later as the player progress forward in the maze. You can also remove some rooms from the scene the player left behind, so you will end up only with a few rooms in the scene to be exists, and that will most likely be a nice optimization since you can cut down the physics and actor processing costs significantly.

Btw i have checked the game, looks very cool! There also is a nice graphics settings ui that helps to cut down the costs, althought with HIGH settings on everything, on my gtx 1070 i got ~70% GPU usage with 60fps (vsync), so this is running smoothly here already.

This should apply your use case pretty well. No baking. Automatic feature. No GI. But fast and nice shadows.

“NEW: SHADOW MAP CACHING FOR MOVABLE LIGHTS”

Thanks for answers. You helped a lot :slight_smile:

Could you please point me to the video?
Thanks

I managed to find it in the heap of UE4 related stuff I bookmarked: https://www.youtube.com/watch?v=VmRggTwhiew

Here’s another variant:
https://www.youtube.com/watch?v=bSWu7oTwkZs

thanks guys! i really appreciate your help!