Download

Lighting up a randomly generated level

I’m having problems getting the lighting I want without the massive performance hit. Pre-built lighting is out of the question because it’s all randomly generated.

I want to achieve pitch black areas of the map which are just rooms with no lights in. Hovever I’m struggling to achieve this without dynamic shadows enabled. And even on the ‘medium’ shadow setting the FPS tanks!
Why does dynamic shadows destroy the performance so much?

Shadows are disabled on the lights here, in game FPS is great:

p1.jpg

p2.jpg

Here is what I need but with fast performance (lights are set to cast dynamic shadows):

46a719ef27d867405cc673f39b61e23cb8444877.jpeg

Dynamic shadows are expensive, especially if you have over lapping lights. Try to avoid overlap, see if you could bake lighting, or maybe try distance field shadows.

Without Dynamic Shadows enabled there is no way to block the light.

If you’re getting performance issues, have you tried using any profiling to see where you’re getting the slow downs?

Couple of questions:

  • How are you meshes setup? Is this one single mesh for the walls, or are you using modular pieces that are placed?
  • Have you setup any LODs for your supplemental geometry like the lights, pipes, etc?

I’ll check out the profiling which hopefully should give me more info.

It’s set up like this: Corridor pieces are the squares which are their own blueprint and then theres bigger rooms, again their own seperate blueprint for each shape.

http://www.lazygames.org/uploads/2/4/8/8/24881910/40241.png?424

I havn’t done any LODs. It’s a top down shooter so when somethings on the screen it will always be that same distance away.

You could fake the lighting/shadows. Your level aligns nicely to a grid, so you could generate a mask and use that to define the lighting.

Something like this:

  • Remove all “ambient” lighting such as skylights so that your shadowed areas start black.
  • Only leave small radius lights to create interesting local lighting and make sure they don’t reach beyond the walls.
  • Use the mask you generated based on the grid to create fake fill lighting in the materials emissive channel that is limited to the areas you want lit.

Should be super cheap. You could even extend it to generate some large scale ambient occlusion by giving the mask a blurry transition.

I think I know what you mean. Like have a plane roof above the room tiles that has a transparent material above them for lit rooms and opaque for dark rooms? That might work if I can allow my characters flashlight to be seen through the material.

p5.jpg

For now I’m happy with the way it is now. I’ve changed the attenuation radius for each light. It isn’t perfect but most of the time the far rooms are pitch black and can only be explored when the player has a torch.