1
\$\begingroup\$

I am working on a game project where most of the action takes place in a large scene that is built to look like a space station. Because it is all technological and enclosed, I can't use a directional light to light the whole scene, and I need to be able to change the color of the lights for an alarm system. I can't bake the lights, because then I can't change their color, and I can't leave them all as dynamic lights, because I have about fifty spot-lights, and they take up a huge amount of memory, so much so that the lights can't even render on mobile devices.

Is there any way to do this without baking?

I am getting about 3000 batches in the Unity Editor Stats on average, in some places it is higher. Even viewing the game in full screen in the editor makes the game run super slow because of the amount of rendering it has to do, and I have a pretty new computer.

Here's a picture of my scene (As you can see, it is fairly large as you are able to see the UI box clearly from the scene editor): My Unity Scene

And here's the Stats box:

Stats Box

Here is an example of my scene in play mode:

Rendered Scene

UPDATE: I removed the shadow casting, which isn't necessary for my project, and it improved the framerate slightly, and the batches number is smaller, averaging out at about 1500 now, but the performance still is not optimal.

\$\endgroup\$
  • 1
    \$\begingroup\$ Does every light need to be shadowcasting? Or can you prioritize a small number to cast shadows (eg. those brightest / covering the most area / closest to the player) and allow the rest to be shadowless? Also, are you using any occlusion culling to limit rendering of rooms that can't be seen from the current camera position? For more specific advice, it would help to see what your typical rendered scene looks like - we might be able to suggest cheaper ways to achieve similar visuals. \$\endgroup\$ – DMGregory Nov 30 '16 at 3:01
  • \$\begingroup\$ @DMGregory Added a picture of my rendered scene, and removed all shadow casters, as I don't need them at all. I have no idea what occlusion culling is, so that probably is a factor. \$\endgroup\$ – Sub 6 Resources Nov 30 '16 at 3:15
  • 1
    \$\begingroup\$ If you want a lot of lights in a corridor-like environment, occlusion culling is a must. Read through the manual: docs.unity3d.com/Manual/OcclusionCulling.html and try to get it working (I haven't done so before, but I haven't had to use that many lights yet). Also, if you do get it working, post it as an answer and pick it as the answer (would be great if you could do it as a short tutorial, I'd like to see that answer here). \$\endgroup\$ – John Hamilton Dec 2 '16 at 17:53
  • 1
    \$\begingroup\$ Another way could be to add a red filter (image effect) to the camera, that would make white lights appear red so you can bake them, the you can play with the values of the image effect to simulate blinking or anything else if you need. \$\endgroup\$ – Vadim Tatarnikov Dec 4 '16 at 7:51
  • 1
    \$\begingroup\$ Posted the tutorial answer @JohnHamilton \$\endgroup\$ – Sub 6 Resources Dec 15 '16 at 19:27
3
\$\begingroup\$

I ended up using occlusion culling like a few people suggested in the comments. It worked wonders for my situation.

Setting it up is very simple as well.

First, you have to mark everything you want to occlude other objects as occluder static, and everything that can be occluded as occludee static:

Press down arrow next to static checkbox to access these individual options

In my situation, my whole station doesn't move, so everything but the lights was marked as static already.

Second, you open the Occlusion Culling window (Window->Occlusion Culling)

If needed, you can alter the values, but the default values worked perfectly for me, then click bake!

The occlusion culling window. Just press bake!

Wait a few seconds, and that's it. You're done! You can view the occlusion culling real-time from the visualization tab while you play the game, and it's as simple as that. (Though there are options to occlude moving objects if that is necessary. You'll have to look at the full manual for that though. I didn't need to do any of that.)

Performance is great now. I have reduced it in most areas from 3000 batches to anywhere from 5 to 500, based on where you are facing in the game. Thanks for the helpful comments!

\$\endgroup\$
0
\$\begingroup\$

I know you don't want to use baked light, but you may be interested in LightProbes technique from unity. Here you can find more information about it https://docs.unity3d.com/ScriptReference/LightProbes.html

Here more examples of lights in unity http://www.edy.es/dev/docs/unity-5-lighting-cookbook/

I think you can achieve nice looking effect with combination of different types of light.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.