4
$\begingroup$

I have a simple scene with only two objects. I want to bake shadow of one of them, but for some reason it ignores self shadow and bakes only shadow cast by other object. Have i missed something in baking or material settings?

baked shadow

scene

bake settings

$\endgroup$
6
  • $\begingroup$ Hello, it should work, could you please share your file? $\endgroup$
    – moonboots
    Oct 14, 2023 at 13:49
  • $\begingroup$ it's as simple as it gets. fresh blender install (3.6.4) file.io/2fjQIKaJqwaR $\endgroup$
    – kabukiman
    Oct 15, 2023 at 0:37
  • $\begingroup$ oh ok I thought you were baking the diffuse, i don't know why Shadow doesn't bake the own shadows of the object, isit supposed to? $\endgroup$
    – moonboots
    Oct 15, 2023 at 6:42
  • $\begingroup$ i'm not sure if it's supposed to or not, but that's what i need $\endgroup$
    – kabukiman
    Oct 15, 2023 at 8:51
  • $\begingroup$ you should mention the bake type and show the bake settings. This is not clear when you read the question and the file got deleted meanwhile. $\endgroup$
    – Blunder
    Oct 15, 2023 at 13:36

1 Answer 1

2
+50
$\begingroup$

The issue here is the Shadow Bake Type doesn't seem to include the shadows cast by the object on itself. I experimented a bit, and I found a way to make it work, but it is a bit convoluted.

The steps are:

  1. Bake diffuse with all lights set to cast shadows.
  2. Bake diffuse with all lights set to not cast shadows.
  3. Divide the first by the second as shown in the screenshot.
  4. If the nodes are connected as shown in the screenshot, bake emission to another image to get the shadows.

Please note that the color of the surface and the light properties will affect the output. You will obviously need to avoid black surfaces. If you prefer, you can add a Color Ramp to customize the output.

Shadows


Update: It seems that OP wants to bake lightmaps in Blender. To do that, the Diffuse Bake Type should be selected making sure to exclude Color contribution under Influence as shown in the screenshot below. This will bake direct and indirect light which can then be multiplied by the Base Color in the game engine to get a fully lit scene without needing active lights.

enter image description here

For this simple scene, light baking shouldn't be too hard, but for normal or complex scenes, more steps need to be taken. I suggest to refer to this YouTube tutorial for more information.

$\endgroup$
6
  • $\begingroup$ This will still be missing some of the shadow since there are areas that Diffuse and shadow would both leave unlit. A proper shadow pass would have the side of the cubes that isn't facing the light. Individual mesh elements still aren't properly self shadowing. It is possible to make an OSL script that does this properly. $\endgroup$
    – Ascalon
    Nov 15, 2023 at 17:38
  • $\begingroup$ @Ascalon I think what you're referring to is called shading. If we want both shading and shadows, I think a diffuse bake with shadow-casting lights would suffice assuming white surfaces are used. What do you think? $\endgroup$
    – Mr A
    Nov 16, 2023 at 10:58
  • $\begingroup$ Not quite. Shading is based on the surface angle(normal) as compared to the light angle and strength. Shadows are based on occlusion of the light. So areas of an object opposite the light are often both shaded and self-shadowed. $\endgroup$
    – Ascalon
    Nov 16, 2023 at 18:27
  • $\begingroup$ side faces are not in shadow. all i want is to create lightmap to use in game engine. all lights and all shadows must be baked to the texture of one single object $\endgroup$
    – kabukiman
    Nov 18, 2023 at 6:21
  • $\begingroup$ @kabukiman Is there a reason why you don't want to bake the light in the game engine? You can bake a grayscale image that represents the lighting (direct and indirect) in Blender which you can then multiply by the base color using a custom shader in engine to get a shaded look. However, there is an issue that you may have multiple instances of the same asset (rock, for example) which face the light differently, and therefore, require different bakes. Game engine are equipped to handle this. Anyway, for your simple scene, I will update my answer. $\endgroup$
    – Mr A
    Nov 18, 2023 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .