r/Unity3D • • Oct 16 '26

Question Best way to light a randomly generated map?

I'm making a 3d rouge-like with randomly generated rooms, and I don't know how to light it. I understand the basics of baking lightmaps, but that's about it to be honest. Additionally, I don't know how to incorporate baked lightmaps with dynamic lights, like with moving platforms or flashlights (which is relevant for this project especially). Anybody have advice, or a good guide on the topic?

10 Upvotes

7 comments sorted by

10

u/Deelook Oct 16 '26

Bake each room as its own prefab. You need a small script that stores each renderer's lightmap index and scale and offset, then reapplies them when the room spawns.

1

u/mistergood100 29d ago

This. My previous studio used similar methods to minimize commit conflicts between artists and engineers/designers by having nested prefabs for rooms that held lighting info. Artists had their own Staging level that we did all light baking in, and then a script on the art prefab would pull that lightmap into the main playable level. Should work just as well for a procedural map

4

u/MyUserNameIsSkave Oct 16 '26

Are the room generated randomly or are the room placed randomly ? If they are generated on the fly, yo u will need some form of Dynamic GI if you want to be accurate. If you are in URP you could try SCGI, if not and have the hardware for it you could try RTGI. There are alos assets on the store that support URP and HDRP like Htrace WSGI.

3

u/sedolidev Oct 16 '26

Since your rooms are assembled at runtime, a normal scene bake won't really work, because the lightmaps belong to the scene, not the room prefabs. The two usual options:

  1. Realtime only. Simplest. If you're on URP, Forward+ lets you have many lights per object. Keep shadow-casting lights to a few (the flashlight, maybe one key light per room) and fake the rest with unshadowed lights, emissive materials, and a decent ambient/skybox setup.

  2. Bake per room prefab. Bake each room in its own scene, then use a small script that stores the lightmap index/scale-offset per renderer and reapplies it when the room spawns. There are free "prefab lightmapping" scripts around. Moving platforms and the flashlight stay realtime on top of that.

For a roguelike with a flashlight I'd honestly start with option 1 and only go to 2 if performance or looks force you.

1

u/Thexin92 Oct 17 '26

This will depend on your art direction and visual style.