If you have used “Shadows Only” material option, you probably have noticed how hard it is to get it rendered properly. That setting makes material to render only shadows, rest of the surface becoming transparent. This can be especially useful when compositing 3D-graphics over images.

Unfortunately, it wasn’t previously working quite well under certain circumstances:

  1. Shadows were very faint unless lamp distance was set near infinity.
  2. Lamp “Energy” value was ignored.
  3. “Add” type Ambient Occlusion was calculated incorrectly when AO “Factor” was other than 1.0. (Lower factor made shadows fade off and higher factor made them stronger.)
  4. Same with Environment Lightning. Changing “Energy” from 1.0 didn’t work as expected.

So I implemented an alternative method, that can be chosen from a drop menu below “Shadows Only” option in materials panel.

New UI panel to select shadow type.

New UI setting to select shadow type.

Currently there are 3 shading types:

  • Shadow and Distance: The old method.
  • Shadow Only: New and improved method.
  • Shadow and Shading: An all new option that even renders dark / lightless areas as shadows.

Here are some comparisons between previous and new method. Renders where “SO” is disabled are also included to see how shadows “should” look like. (Click image to make it larger.)

A single light with small falloff distance.

A single light with small falloff distance.

Ambient Occlusion and Environment Light enabled.

Ambient Occlusion and Environment Light enabled.

Two lights with different energy.

Two lights with different energy.

However, even this new method isn’t perfect. Due to color correction and scalable dynamic range in general, it’s impossible to calculate specific alpha for shadows so that it would match rendered image perfectly. But as far as I can tell, these new methods work very well in most cases!