Improved “Shadows Only” Material

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!

The Future of Overrides
This Summer’s Sculpt Mode Refactor
Geometry Nodes Workshop: October 2024
New Brush Thumbnails

17 comments
  1. Wow,solved my problem,thanks.

  2. Yup, that’ll do it. You have my appercaiotin.

  3. Thanks for your work!

    But shadows are too dark in “Shadows Only” mode:

    http://itmages.ru/image/view/171495/31a17a9f

    Is it possible to make absolutly same shadows?

    I tried to change lamp energy, to turn on “falloff”, but shadows look differ :(

  4. Fabulous – hope this makes 2.57!!

  5. Oh MiikaH!!!! thanks for this, your code additions are very very usefull,. not so long ago I had a great headache when trying to work with shadow only when putting a model into a photo, ended up with painting shadows in photoshop… so this won’t happen anymore :)

  6. Yeaaa!!!
    I’m Waiting exactly for that :D:D:D

    Ever a step forward :P

  7. I’m so glad you tackled this, MiikaH!

  8. awesome!
    is this build available somewhere?

    also, the Shadow pass background should be white, and the projected shadow in the shadow “only” material does not appear in the pass.

    example:
    http://s2.imagefrog.net/show.php/147082_compositeshadow.jpg

    I hope you can fix it! =D
    bye

  9. This is fantastic. I’ve had many issues with the old Shadow Only option. Good on you for fixing it.
    But I wonder, why keep the old one? To me, it sounds more like a bug. Main issue now is that we have this huge dropdown menu taking up valuable space. I think it’s unnecessary – we have to be careful about adding buttons all over the place in the UI. Blender is bloated enough as it is! :)

  10. Amazing! 4 (or 3?) years ago, I’ve been very frustrated by this feature of Blender, being that it doesn’t do much of what it says, and I did solve the problem the hard way, creating several passes via compositing–which can really be cumbersome at times to setup. But from your implementation, I can see that this is the perfect solution to my several years old problem.

    Simply perfect!

    Thanks so much, MiikaH! As always, you always surprise the Blender community with your innovations! ^_^

    -Reyn

  11. This is faboulus, great work! Will this make it into the 2.57 version? :D

  12. reflections would be very nice <—

  13. Finally! this has been one of the most missed features which have made me use other apps for cgi in live action integration.

    thanks!

  14. Amazing!… I love your developments MiikaH, always sooo functional and oriented to quality and “correctness” of the simulations… You remember me of Matt Ebbs developments, you both seem to use a lot Blender for production work but every time looking for realism and plausibility of results. Your developments have helped me big time in my projects!

    Keep the awesome work!

  15. And here I thought it was just me being an idiot. Glad to see another part of Blender working properly. :)

  16. a feature that I’ve been hoping would be better implemented for years now, coming from other 3d packages that handle shadow-only in just this manner(or similarly).

    THANK YOU Miika!!!!

  17. awesome!! glad these old nuyances are being tackled!

    keep it up!
    cheers

In order to prevent spam, comments are closed 7 days after the post is published.
Feel free to continue the conversation on the forums.