4
\$\begingroup\$

I've implemented a simple script to simulate Sun Rotation (day/night cycle).

In my "Update" i Rotate main Directional Light (the sun). What i've noticed is that my FPS dropped from 60 to 20-25 fps.

I can understand why: recalculate all light each frame can be (euphemism) cpu-consuming.

So i switched approach using an InvokeRepeating with a repeating time of 0.25f seconds (4 "movement" per second).

Also with this approach my frame rate drop from 60 to 50 (unacceptable).

So my question is : is there a way to move/rotate a light (simulating a day/night cycle for instance) without meet a so big fps-dropping but mantaining realism ?

Thanks

\$\endgroup\$
  • 1
    \$\begingroup\$ How are you calculating light e.g. are you using deferred lighting? Are you mapping shadows that are dependent on the position of the sun? What part of your code forces the gpu to recalculate light? \$\endgroup\$ – Kyy13 Jul 20 '18 at 14:14
  • \$\begingroup\$ Does the profiler give any insights as to what operation is taking up so much extra time? \$\endgroup\$ – DMGregory Aug 8 '18 at 13:54
  • \$\begingroup\$ Workaround: can't you rotate the light once minute? It's a day night cycle after all... \$\endgroup\$ – JoulinRouge Aug 12 '18 at 13:08

Your Answer

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

Browse other questions tagged or ask your own question.