8 Tips for Improving Shadows on Sketchfab

Back to overview

You can use up to three real-time, shadow-casting lights in your Sketchfab scenes. Most of the time, your lights will look great without further consideration, but sometimes you need a bit of tweaking to make the most of them. This tutorial gives you insight into how real-time shadows work and how you can tune them for your own Sketchfab scene.

Real-time shadows are calculated with a trick: it would be way too ‘expensive’ to calculate rays from each pixel in your scene to the lights and determine if an object blocks the light path – like ray tracing does. Instead, we calculate a ‘depth map’ from the viewpoint of each lamp. Each pixel on those maps indicates the maximum depth the light can reach before hitting an object.

Here’s an example from Wikipedia:

When rendering your image, we use this light map to quickly look up which parts of your model receive light from the lamp:

As mentioned before, we support three real-time lights here on Sketchfab so we calculate three shadow maps. In static scenes we only need to do this once, but for animated models these calculations need to be done for each frame. As you can imagine this can become quite resource-intensive for complex scenes.

Now here’s the thing: light-maps are just bitmaps and they have a fixed resolution (of 1024×1024 pixels). If you use their full resolution to light a small part of your scene, you’ll be fine and you’ll get nice, crisp shadows. Basically the light space resolution of the light-map matches the screen space resolution of your scene and we have enough information to determine the shadows for each pixel on your screen.

If, however, your scene is huge and you try to light everything with just one lamp, each pixel in the shadow-map will cover more than one pixel in screen space and shadows will look blocky. There are also other situations where the combination of the relative positions of the lights and camera will result in a lower resolution of the shadow map in screen space.

Now, a shadow map has a ‘depth’ resolution too (it uses discrete values, after all). This can lead to polygons casting shadows on themselves etc. – an effect known as shadow acne (hello, puberty!). To fix this we use a configurable bias value which offsets the shadows in lightspace which offsets the shadow caster depth. Each scene requires its own bias values – more about that later.

One more thing: you may have noticed that shadows ‘smooth out’ if you don’t navigate your scene. This is an anti-aliasing trick we’ve added: once your scene is no longer updating, we render the shadows 16 times while jittering (adding some random movement) to your camera (we do the same for our Depth of Field filter).


Got that? Great! Then let’s move on to how you can work with this knowledge to improve your scene.

Tip 1: When using directional lights, keep the size of your scene as small as possible

Directional lights try to light everything in your scene, so your scene’s bounding box will determine their resolution. The bigger your scene, the lower the resolution of your shadow map will become! If you have to use directional lights with shadows, remove unneeded parts, huge backdrops, etc.

Tip 2: Use spotlights whenever possible instead and tune their angle to match your scene.

Unlike Directional lights, Spotlights have a limited, configurable  ‘beam’ size. The ‘angle’ value determines how wide the light beam from the spotlight is and can therefore be used to focus the shadow map pixels only where you need them. This results in less “wasted” shadow resolution and therefore better quality shadows.


Pro tip: look ‘through’ your lamp to get a better sense of what it ‘sees’. This will make it very easy to determine the best angle value.

Tip 3: Tune the spotlight ‘falloff’ value carefully

This value determines how far the light from a spotlight will reach. Anything beyond this point will not be included, and as such the bounding box of the geometry in your shadow map will be reduced, resulting in a better quality shadow map.

Directional lights don’t have a falloff value as their light rays are parallel, and therefore don’t attenuate with distance.


Please note that the ‘end’ of the spotlight widget in the 3D editor does not reflect the falloff reach, so just pay attention to your shadows while changing this value.

Tip 4: Play with the bias value

Don’t accept the default value of the shadow as the correct one. Tuning it isn’t always obvious – values that are either too high or too low will create their own problems, so be sure to explore the effect of a wide range of values. Change it so that all shadow artifacts are gone.

Be aware of Peter-Panning (yep, that’s really what it’s called!) – high bias values may make shadows seem ‘disconnected’ from objects, having them ‘fly around’ your scene.

Pro tip: changing the bias value may solve shadow problems in one area and give rise to others in unexpected places. To review your entire scene after making changes!

Here’s an example: Her left face side has shadow acne, so you tweak the bias:

Now the face is lit correctly… but now look at the foot, it’s peter-panning!


Tip 5: Don’t make your shadows too strong

Crisp dark shadows are always a dead give-away for CG lighting. Shadows in the real world are always softer even if they appear crisp. By combining your shadow-casting lights with other lights or an HDR environment, you can achieve more natural-looking, less dark shadows. By reducing their contrast you will automatically reduce the visibility of any blockiness in them.

Tip 6: Review your shadow settings after adding post-processing filters

As I mentioned in tip 5, things like contrast and color balance can affect how you perceive the blockiness in your shadows. Therefore it’s always a good habit to review your overall scene after adding or changing any post-processing.

Tip 7: Do you really need real-time shadows?

You might achieve much better quality by baking the light (AND shadows!) into your scene. This will also allow for effects that real-time lighting cannot do, such as area lights, indirect lighting and even caustics! With baked lighting you also have full control over the resolution of your light/shadow map and as a bonus your real-time performance will be much better.

Pro tip: Our free 3DS Max exporter plugin has built-in support for generating light maps.


Tip 8: Is your target audience mainly on mobile?

Remember that we currently don’t support real-time shadows on iOS devices, so you’ll definitely need to bake them (see my previous tip).

That’s it! It may seem like a lot to take in, but it will quickly become second nature to you to review your light settings for a new scene. Let me know if you have further questions – we have a lot of knowledge about these things in our team and our 3D developers are happy to help you out!

We have more information about setting up your lights in our Help Center.

As a final note, here is a solid example of effective shadow-casting:

About the author

Bart Veldhuizen

Head of Community at Sketchfab. 3D Scanning enthusiast and Blenderhead. Running BlenderNation in my spare time.


Leave a Reply

Your email address will not be published. Required fields are marked *

Related articles