2
\$\begingroup\$

I made the shadow of Solider in my game using Unity pro shadows feature.

http://docs.unity3d.com/Documentation/Manual/Shadows.html

The performance of my game becomes very slow after adding these shadows. I used light map for buildings shadows but I cant use this thing for solider. I want to ask what technique should I use to make both real and optimize shadow of my solider.

\$\endgroup\$
  • \$\begingroup\$ have you tried to play with different settings (resolution, number of lights )? I think it's there in the documentation. \$\endgroup\$ – concept3d Nov 6 '13 at 9:27
  • \$\begingroup\$ @concept3d yes I tried but there is no better luck. \$\endgroup\$ – Zeeshan Mirza Nov 6 '13 at 9:56
  • \$\begingroup\$ maybe posting a picture, or describing what are you trying to render in more detail can make other people help you. \$\endgroup\$ – concept3d Nov 6 '13 at 10:31
  • \$\begingroup\$ ok . will add soon. \$\endgroup\$ – Zeeshan Mirza Nov 6 '13 at 10:32
3
\$\begingroup\$

There are a few things you should do to optimise the shadows in your game:

Use lightmapping heavily to compute the shadows for static meshes. Unity has a builtin lightmapper. See http://docs.unity3d.com/Documentation/Manual/Lightmapping.html and http://docs.unity3d.com/Documentation/Manual/OptimizeForIntegratedCards.html.

The computation of dynamic lights have 3 main aspects and each one must be tweaked for performance: the light itself, the casters and the receivers.

To make a dynamic light, set Hard Shadows or Soft Shadows in it. However, the number of dynamic lights should be minimal since each one issue additional rendering for shadow projection. Also, Soft Shadows require a blur filter to ensure smoothness, which can impact the performance. Finally, the resolution of the shadow texture also affects performance. See http://docs.unity3d.com/Documentation/Manual/Shadows.html and http://docs.unity3d.com/Documentation/Manual/DirectionalShadowDetails.html.

To make a mesh receive or cast shadows, set Receive Shadows or Cast Shadows in the respective Renderer (BEWARE: by default these settings are on). However, the number of casters and receivers should also be minimal, since each caster or receiver in the "light frustum" must be rendered additional times. See http://docs.unity3d.com/Documentation/Manual/ShadowTroubleshooting.html.

Another related performance tweek is to use the Deferred Rendering Path instead of the Forward Rendering Path.

In summary:

  1. Bake light maps;
  2. Keep the number of dynamic lights to a minimum;
  3. Tweak the resolution of the shadow texture;
  4. Tweak the filter for Soft Shadows;
  5. Use Receive Shadows and Cast Shadows judiciously;
  6. Use the Deferred Rendering Path.
\$\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.