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?
-
$\begingroup$ Hello, it should work, could you please share your file? $\endgroup$– moonbootsOct 14 at 13:49
-
$\begingroup$ it's as simple as it gets. fresh blender install (3.6.4) file.io/2fjQIKaJqwaR $\endgroup$– kabukimanOct 15 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$– moonbootsOct 15 at 6:42
-
$\begingroup$ i'm not sure if it's supposed to or not, but that's what i need $\endgroup$– kabukimanOct 15 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$– BlunderOct 15 at 13:36
1 Answer
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:
- Bake diffuse with all lights set to cast shadows.
- Bake diffuse with all lights set to not cast shadows.
- Divide the first by the second as shown in the screenshot.
- 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.
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.
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.
-
$\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$– AscalonNov 15 at 17:38
-
-
$\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$– AscalonNov 16 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$ Nov 18 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 ANov 18 at 11:49