0
\$\begingroup\$

I am using Unity 5. As a test, I set the realtime shadow resolution to max and the distance to cover my entire scene with no cascades. As expected, it lagged severely, but I could still move the camera and the shadows updated in real time.

As a second test, I lightmapped the scene using the absolute lowest settings. This took about a minute to complete.

Basically, I can use lightmapping, and it takes much longer to work than real time shadows even though it looks worse. Why does lightmapping take so long to bake in comparison to real time shadows?

\$\endgroup\$
  • \$\begingroup\$ How big is your shadow map? If it is top big, it can eaf up all the memkry, like Chrome does. \$\endgroup\$ – Bálint Apr 17 '16 at 16:00
5
\$\begingroup\$

Realtime shadow maps allocate texels for everything the light can see.

Lightmaps allocate texels for everything.

This makes a big difference in several cases:

  • faces occluded from the light don't contribute any information to a shadow map - they occupy the same texels as the object occluding them. A lightmap will allocate separate texels to shadowed faces.

  • faces nearly parallel to the light rays occupy only a narrow sliver of a shadow map, leading to stretchy/zig-zag artifacts when partially shadowed because there's not enough resolution to capture the shadow shape in the near-parallel axis. A lightmap will allocate a more even (or possibly adaptive) distribution of light samples across these faces.

This also demands substantially different methods for computing them. Shadow maps are designed to be re-rendered every frame, tolerating some errors like aliasing, light bleeding, and peter panning, while lightmaps are designed to be baked in advance, taking the time needed to minimize these errors as much as possible at the available resolution.

Lightmaps can also encode indirect lighting information (bounce light), which is a whole extra layer of computation.

\$\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.