42
$\begingroup$

In most of my models, I usually end up setting a world background using an HDRI image of some kind or another. This has always been really useful for lighting in general or as a background for my final render.

But what if I want my model to look like it is interacting or touching part of the background? For example, in the image below that I found, the modeled objects look like they're part of the scene, and even appear to cast shadows on the ground. How can I do this?

...

$\endgroup$
  • $\begingroup$ Can you accept the cycles answer instead of my BI one so it gets seen first, thanks. $\endgroup$ – iKlsR Jan 6 at 17:21
33
$\begingroup$

One quick way to achieve this using Blender Internal is to select the plane and add a new material, in the material settings under shadow, enable Shadows Only.

enter image description here

Next, you can optionally enable transparency, use Z Transparency and use the alpha slider to control the strength/darkness of the shadow.

enter image description here

To further enhance this and add to the realism, you can enable Ambient Occlusion and use a blend sky (for simple renders). It is also worth noting that the shadow you get is dependent on the type of lamp and world settings you use in some cases, in the image below I am using a sun lamp with ray shadow enabled and I also have Environment lighting turned on, this softens the shadow and its harder to control but gives a nicer subtle effect.

enter image description here

Here I am using a sun lamp and a point lamp with Environment lighting off, with this setup, I can easier adjust the opacity of the shadow with the transparency setting.

enter image description here

Finally, in a case like you describe above, just render the scene without the sky (untick sky under the scene tab), align the camera as best as you can to the angle of the background, render and use an Alpha Over node to join the render and the background together. Here is a quick example I did in a few minutes.

enter image description here

With HDR lighting and some tweaking, this can look really good. It's a bit tricky depending on how you want to use it and at times it will take a good amount of tweaking to get it to look 'right' but this is a sure way to go about it, the ground plane still catches the shadow but it is invisible.

$\endgroup$
  • $\begingroup$ iKlsR is right. Shadow-only textures will do the trick. Adding a floor will do wonders. If you want shadows to have additional play with other things in the scene -- e.g. people and buildings -- then camera mapping will go a long way. Andrew Price explains it flawlessly in his Camera Mapping tutorial and again in Part 2 (an updated one). $\endgroup$ – Wray Bowling May 31 '13 at 8:48
  • $\begingroup$ And shadow only textures simply can't be done (as of 2.77) in cycles. That means cycles is... Better, right..? $\endgroup$ – yPhil Jul 21 '16 at 16:46
  • $\begingroup$ @philipyassin huh? $\endgroup$ – iKlsR Jul 21 '16 at 16:47
  • $\begingroup$ @iKlsR blender.stackexchange.com/questions/58342/… $\endgroup$ – yPhil Jul 21 '16 at 16:54
46
$\begingroup$

CYCLES ENGINE

Shadow Catcher

This feature is a part of official 2.79 version, located in Properties Editor > Object > Cycles Settings. Simply enable it for the object that you want to be the shadow "catcher".

Plane with Shadow Catcher enabled. Background - HDR image

In 2.80, Shadow Catcher can be found under Properties Editor > Object > Visibility.


Shadow / Light Receiver ___ HDRi

As an extension of the answer, I will keep this previous method. Why?

  • This material can also receive lights. Useful in case you use other emitters or lights in a scene, that should affect the ground.

  • This material gives you precise feedback if the HDRi lights correctly. If not, ground plane will be brighter or darker (or will tend to be a different colour tone) depending on image condition.

Material for ground (plane) is Diffuse shader with assigned Environmetal (Equirectangular) HDRi texture. The same texture used for World. The trick here is to use "Reflection" texture coordinates with negative Z value (-1).

Note: Works only for flat surface (like a plane).

enter image description here enter image description here For more examples and more tests check out this Blenderartists thread.


Lighting by HDRi is another topic, so just a quick tip if HDRi doesn't light properly. Use this Greg's Zaals node setup to correct lighting condition in your scene, in most cases just increase/decrease value in "Multiply" node. Later I noticed that the second "Mix" node affects "Exposure" of the HDRi.

enter image description here

Other variations: Reyn's environment nodes, Ben Simond's nodes

If lighting seems to be ok, but shadows are still too blurry you will need to fix the HDRi image manually. Open the image in an image editor that supports 32bit images, select small circle in place of sun and increase exposure. Sorry can't find a tutorial link.

Rendering – Be sure "Multiple Importance" is enabled in World Properties panel (value like 840), it should be checked by default.


Shadow / Light Receiver ___ Backplate (2D image)

In case you want to merge your CG with the backplate, simply use "Window" texture coordinates for shadow / light receiver. This material doesn't have a geometry limitation. In this example, a plane is used also, but it can be any shape. Scene is lit only by a sun with strength that brings ground image to background colours. Both previously mentioned benefits (shadow/light receiver and in this case general feedback of correct lighting) works here too. Disadvantage of backplate (compared to equirectangular HDRi image) is lighting inaccuracy and missing reflections.

Note: the same node tree is used for the world.

enter image description here


Note: There also exists OSL shader QUIP and QUIPCam for this purpose that gives you the ability to have a bit of movement in the environment too. But OSL isn't supported for GPU calculation and takes quite a lot of time to get a clean render. For correct mirroring of the ground on the reflective object - QUIP works the best.

$\endgroup$
  • $\begingroup$ Thank you for this answer. Your example was very userful for me :) $\endgroup$ – Ant4res Aug 14 '15 at 20:55
  • $\begingroup$ When it comes to envmaps - do you have any method control how hard/soft env light is? $\endgroup$ – user92 May 24 '16 at 13:45
  • $\begingroup$ I'm gonna sound very stupid, I'm afraid. I read the whole BE thread, watched the videos several times, and I can't, for the life of me, figure out where this "HDRI" image texture file comes from. $\endgroup$ – yPhil Jul 21 '16 at 13:28
  • $\begingroup$ OK, so no one is going to tell me where is this HDRi image file, or why do I need it just to hide the shadow receiving plane in my video? Come on, tell me, this unreproducible answer is a joke, right? $\endgroup$ – yPhil Jul 21 '16 at 16:56
  • 1
    $\begingroup$ @yPhil The "HDRi" in question is the same as the world's environment texture. If you don't have an environment texture you will have to use a different method to hide the plane. $\endgroup$ – Fax Jun 30 '18 at 21:26
4
$\begingroup$

I'll probably get myself defrocked for this because what I'm offering is more an alternative to shadowing because it's so easy to achieve and is completely independent of Blender's lighting restrictions, quirks etc.

The method is kindergarten level, crude even, but it works!

enter image description here enter image description here enter image description here

It's entirely flexible and has the added advantage of being able to assume any shape a storyline demands. It can even move independently of it's 'master', take on a life of it's own!

Shadows -

The system uses a 2D alhpa layered plane textured with the shadow movie or a still frame when no animation is involved. This is laid at the actor's or object's 'feet' and parented to the same empty that's propelling it forward. (for stability)

It can just as easily be placed on a wall, or bent half between!

Shadow movies can be blurred in the VSE when a sharply defined version isn't desirable, the plane textured with that instead.

They are also rendered using OpenGL and with no lighting. (Black on transparent)

A shadow is photographed/filmed as with any movie, capturing the actor's movements, but holding it (the actor) stationary. I find it easier to create a new scene and copy paste the actor into that, animation and all, removing or disabling all lighting. You end up with a black figure doing it's thing on an alpha layered background.

This is rendered out using OpenGL as png files, one for each frame and with the "RGBA" button pressed for the alpha layer.

I'd recommend setting up a fixed camera for this. It will give you somewhere stable to come back to, should the need arise.

The cam is usually placed at a position that gives the best results for the job. This isn't necessarily from where the scenario's lighting originates.

More often it can be at it's 'compass' direction only, and at a height and angle to suit. In the Plant example, the shadow sequence was taken from about mid plant height and perpendicular to them.

The walking sequence was taken from directly behind and with the forward motion disabled. i.e. animated but stationary. Whatever 'stretching' is needed for the shadow's projection, is achieved by scaling the plane in that axis. Keyframes can rescale as necessary.

The craft taking off was just a still alpha layered 'photograph' to get it's basic shape from the sun's angle. (It was not intended for this particular background photo)

The shadow plane was parented to the craft.

When the craft takes off and rotates, so too does the plane, so it's Z height has to be held at it's original setting. To add realism the width of the plane was scaled down with a keyframe or two to more accurately reflect the sun's projection angle.

Where more complex distortions might be required, shape keys can be called upon.

$\endgroup$

protected by David Jun 28 '15 at 16:52

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.