Superimposing 3d shadow onto image of 2d shadow

Hello, I’m trying to follow the tutorial Add Color and Textures to Shadows in Blender! using Eevee rendering but instead of adding wave texture, I want to add image texture for my shadow instead. I tried looking this up but couldn’t find any other topic on whether you can or can’t., it looks like you can’t but I want to know if it’s because a mistake on my part or because Blender doesn’t allow that. I have my material, light setting, and result below, :sweat_smile:, also trying to fix the fact that the light’s casting multiple shadows instead of just one on the wall.

Material applied to object
B/W/G portion of material

Area light settings

Current image result

Thanks to anyone who replies, I appreciate it.

In the material settings of the object casting the shadows, you will find a place that says “shadow mode”. If your texture is partially transparent with gradients, set it to alpha hashed, if it’s all fully opaque / fully transparent, use alpha clip for better performance.

That’s the method Eevee uses to calculate soft shadows: it creates multiple shadows from different parts of the light source. Increase the render samples and eventually, enough shadows will have accumulated that they will form a single beautiful soft shadow. The wider the light sources, the more samples you will need.

First, thank you for replying and sharing information (I will note this down), my image isn’t transparent at all though. I turned the render sample up but it didn’t do anything to accumulate the shadows, rather making the size of the light smaller did.

It looks like I was a step ahead of you then.

In Eevee, you can’t texture light sources directly. If you want to texture a shadow, you have to use a plane with a transparent texture (or actual polygonal holes). Also, you will want a smaller size for the light source, so the shadows are sharp enough to let the texture be visible.

Switched to cycles
Ah I see, just tested what it would look like in Cycles and that does seem closer to what I intended although not really (doesn’t look like the shape of a noose for the shadow). I’m switching back to Eevee now.

Would the plane that’s acting as the background in the previous image work? Can you explain why that requirement is needed in order to texture shadows?

Based on your Eevee images, I think your light source is just too wide (or too close to the object casting the shadow). You will want to try it with a really sharp shadow.

Thanks for the explanation, I’ll try that and get back to you on this. :+1:

With the transparent texture, I’d assume I would have to make a transparent texture outside of Blender, like in GIMP and then import it into Blender and add a material to the plane that uses that texture, is that right, or is there some way to make transparent textures in Blender? Sorry, it’s probably obvious I’m pretty new to Blender. About the polygonal holes, what type of holes would they be?

You can make a transparent texture in an external program, but really any black and white image will do, so you could paint a transparency mask inside Blender if you wanted (or use a noise/gradient/voronoi texture as transparency) and it would work.

I mean going into edit mode and litteraly carving holes into the model manually. One exemple of this would be to subdivide a plane, delete random faces and then placing the plane so it casts a shadow over the scene. This could be used to create a spotted effect as if the scene was in a forest.

1 Like

Ok, that makes sense then, again, thank you for replying so far, the reason why I’ve been doing this method is because I want to superimpose a shadow made by a 3d object on top of an image of a shadow that’s in 2d (and that’s why I was using an image texture taken from the 2d shadow). I do plan on animating both so they’d have to match (I’m pretty sure it’s possible to do this in a 2d program but I’m learning Blender and basic lighting/cinematography so killing three birds with one stone). I was watching Remove Background - But Keep Shadows! (Blender Tutorial) and it seems definitely possible.

I just want to make sure, if I did the above, I could import my 2d image as another plane (or multiple planes for depth), since that texture would make the plane transparent (and I place it between the object and the 2d image), the shadow would be superimposed onto my 2d image?

I should probably change the title of the post.

As long as you have a shape that can cast the same shadow as the one from your 2D image and that the original 2D shadow was plausible, it should be possible to match them. You would ideally want to have an image of the object casting the shadow. Then, you would make a black and white image of the object’s silhouette and use that as transparency on a plane and it could cast and match the same shadow.

2 Likes

Background test image with 2d shadow and noose which is casting the 3d shadow

I see, so would I have to make the black and white image of the silhouette of the 3d object, in this case my noose then following a process similar to here Blender 2.8 Tutorial : Transparent PBR Texture Painting? But that’s for PBR.

Plane that the 3d object's casting the shadow from
The plane’s right in the middle between the 2d image and the 3d object and light. How would I make a black and white image of the noose’s silhouette and use that as transparency on the plane above? Or right on the 2d image. (Are there any specific tutorials on this? I found stuff on shadow catching but I think that’s for working with compositing.) With the light source I changed the height so it won’t be elongated any further.

I tried putting it a bit farther from the object but the light became weaker.

You could, or you could also model the shadow casting object using polygons and avoid using transparent textures.

I am not sure I understand how your scene is constructed or what you expect as a final result. Could you show your setup from a different angle? Where is the shadow supposed to be projected? You seem to have a rather unusual use case here.

Don’t be afraid to use a large number for the intensity if that’s what you need. Also, if you are trying to make an outdoor scene (I am not sure if that’s the case or not), a sun light might be better adapted (doesn’t become weaker with distance, covers the whole scene with light coming from a single direction).

Thanks for being patient with me, that was my bad for not being clearer since the beginning. :+1:

Add 3D Effects to Your Photos with Camera Projection Mapping in Blender 2.8 and How I put 2D Animated Characters on 3D Sets with BLENDER is similar to what I’ve been trying to do. I’m trying to learn to do something between camera projection mapping and having 2d cutout images of manga mixed with 3d objects in Blender (in the foreground), as well as learning how to extend scenes.

Hopefully this setup should show what I’m trying to do.


In blue shows the image of the 2d shadow I’m talking about, it’s not a shadow that’s casted, it’s literally a drawn shadow. I’m planning on cutting the background out, the shadow, and the figure casting the shadow into separate layers (and eventually rigging it too).

mock-setup
That’s the reason why I wanted to have the 3d objects in my scene cast a shadow that uses an image texture, to match the texture of the 2d shadow. The red is a poor attempt at the shadow, so it should either be able to overlap the 2d shadow or be on top of the background. Maybe I’m using Blender incorrectly? But I know it’s possible to do 2d/3d.

Thank you, I’ll probably be changing the light in that case then considering the context of the scene.

I get it now. Casting the shadow on the image is the easy part, you just have to create a light source, give it a very small radius (or angle if using a sun light) so the shadow is sharp and then move that light around until the shadow hits the correct spot of the image.

It would however be hard to match the 3D and 2D shadows together without having them overlap and darken each other. Especially considering the shadow has a pattern in it. Unless there is some stuff I don’t know with multiple render passes and blending modes, I would not even attempt it.

If I had to modify the shadow in 3D in the image you just posted, I would instead erase the original painted shadow from the image and re-create it entirely in Blender by making the isolated character cast a shadow. That way, every element that needs to cast a shadow can all do it together in 3D and everything will match.

2 Likes

Would that isolated character be casting a shadow on a transparent plane that would be laid on top of the background, from what I notice, emissive materials/textures aren’t affected by light sources, which is good because I don’t actually want my background to be affected by the amount of light that’s shone on it. I managed to make the area light have a radius of 0.0001, which is tiny, but I might just actually switch it to a point light.


Ah, so I’d be cutting out the part of the image I marked in green, have two versions of that, one being the transparency on a plane. I see.

I ended up following the SHADOW CATCHER TUTORIAL - BLENDER 3.0 EEVEE, the odd thing I noticed is that the plane becomes transparent only when the light is sun, and not area, is there a reason why?
sun
area

This probably has something to do with the intensity of the light. Sun lights use completely different numbers than the other light sources and are much brighter than them. The tutorial you linked uses the shader to rgb node to control the transparency, so if the plane is not turned pure white by the light, it won’t become fully transparent.


It looks like this tutorial might do the trick, but I also have an other, alternate way to do it using the compositor instead:

1- Start by cutting the character out of the image, like you did here, except erase the shadow from the background too.

2-In the view layer settings, check shadows. This will allow you to get an image with just the shadows in the compositor, and they will appear even on emissive objects where you would normally not see them, so you can leave all your materials as flat emissives and won’t need the transparent plane trick.

3-Using the compositor, you can then combine the shadows pass with the normal flat shaded render using a “mix rgb” node set to multiply (the fac slider controls the opacity of the shadow):
multiply_shadow
The shadow will appear only in the final render, so you may want to temporarily set the materials to diffuse while testing in the viewport.


Doing all this testing makes me realize something unrelated. There are 2 render settings I would have you change for your specific case:

  • The filter size should be set to 1. This setting adds a bit of blur to the render, which can help a 3D render be more realistic. However, if you are working on an existing image, you are probably better not have that blur.

  • The color space should be set to standard. The default “filmic” is great for 3D scenes with realistic lighting, but it doesn’t preserve the color and brightness of an existing image.

3 Likes


Sorry for being so late to respond, I’ve been busy with life, so I haven’t been able to use Blender much. I did try what you’ve suggested, and the shadows don’t show up still, with the shadow catcher plane, it does. It’s probably due to me doing something wrong on my end.


Maybe it has something to do with how far the sun light is from everything else, but I did test that and there doesn’t seem to be any difference. Still using a sun light. That square shadow is due to the character, I wonder if it’s due to it technically being a plane.

It seems there are 2 problems here. The shadow is too small and it appears as a square.

The shadow appears square because in Eevee you need to tell the material to use transparency for shadows. In the material’s settings, you will find a setting for shadow mode right next to the setting for transparency mode.


For a shape with “all or nothing” transparency, alpha clip is the correct shadow mode.

Now for the shadow being too small.

In the side view, is the tiny plane in front of the camera the character? If yes, then it’s too small and too far away from the background.

If that’s the case, then follow these steps to fix it.

1 - Put the 3D cursor at the location of your camera.
2 - Select the plane with the character.
3 - Set the pivot to 3D cursor mode


4 - Scale the character. Because it’s scaling from the cursor, it will move away from the camera as it gets bigger and it will remain visually the same when viewed from it.
5 - The character will probably need to be rather close to the background. Don’t expect to get exactly the same shape as the original, it’s a drawing and cannot match the 3D shadow, but you can get close.

3 Likes


Thank you, it seems to be getting there.

1 Like