1
\$\begingroup\$

I've a big scene, with a lot of realtime light.

I noticed a big drop in FPS after finished to add lights, so I suppose that too many realtime light are a 'bad practice'.

But my question is: are all realtime light calculated every frame despite they are not visible from player camera ?

Is there any option to specify the behaviour of that calculation ?

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

All objects that are affected by any realtime light will take a toll on performance while its being rendered. It doesn't matter if the light itself is visible by the camera.

Basically when a mesh is drawing itself, it's checking all nearby lights, and makes calculations to get the final pixel colours of itself. Lights are too far away and have a small range (so they don't affect any object visible in the camera) could be optimised or not, I'm not sure if Unity handles that, and if you can rely on it on all platforms.

The best advice to give for that is, if you have a big scene, divine it into sections, disabling sections that leave the screen, and enabling others that enter it.

\$\endgroup\$
  • \$\begingroup\$ In forward rendering mode, Unity does handle pruning the number of lights to render per-pixel, compressing less-important lights to per-vertex or spherical harmonics forms (see documentation). In deferred mode, each light renders within its bounding volume, so their cost is roughly proportionate to their on-screen pixel coverage. Shadowcasting can be another source of slowdown, since rendering the shadow maps requires additional passes over lots of geometry. \$\endgroup\$ – DMGregory Jul 3 at 15:51
  • \$\begingroup\$ @DMGregory I might be wrong, but I thought this was platform-specific? As in Unity does that most of the time, but depending what platform you compile for, this could not always be the case. \$\endgroup\$ – TomTsagk Jul 3 at 15:53

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.