Normal texture is ignored when baking in realtime

I’m trying to bake a scene in runtime with materials that have normal maps. When I do it in the editor the normal map is affecting the bake:


But when I do it at runtime, the normal is not affecting the bake:
image
In case that using it wrong, this is the code that I’m using to bake:

this.app.lightmapper.bake(null, 0);

The rest of the bake is working as expected.
Any clue at what could be the problem? I really appreciate any help you can provide.

Are there any errors in the browsers console?
Maybe the texture is basic compressed, but you don’t have basis wasm modules in the project and so those are not used?

There are no errors in the console and the texture is not compressed. :sweat_smile:

Perhaps create a small public project to reproduce the issue, otherwise I’m out of ideas.

I’ve created this small project with two scenes. A scene with a cube that has a material with a normal map and another scene that loads that scene and makes a bake. The normal can’t be seen, but if you bake from the editor, you can see the normal map.
https://playcanvas.com/project/1097899/overview/blank-project

Hi @InfoDeuSens,

Changing the line to this.app.lightmapper.bake(null, 1);, this.app.lightmapper.bake();, or this.app.lightmapper.bake(null, pc.BAKE_COLORDIR); appears to clear up this issue for me.

Since pc.BAKE_COLOR or 0 only takes into account the color map, it makes sense that normals would not appear.

I hope this is helpful.

1 Like

Yes, that worked!
Thank you so much!

1 Like

Ok, now that I’ve change to bake(), in other scene the shadows are doing some crazy things
image
image
When using bake(null, 0) those artifacts don’t appear. The rendering configuration of the scene is the same and it’s not happening in all the scenes, just in one.

Are you using soft bake? (bake area, or ambient bake)? If so, those are not compatible with directional baking.

I’m not sure, how can I know if I’m doing an area or an ambient bake?

basically if Samples on directional light or ambient settings is larger than 1, to bake soft shadows / ambient occlusion

https://developer.playcanvas.com/en/user-manual/graphics/lighting/runtime-lightmaps/

Ok, the problem was that I was using ambient bake, now it’s solved. Thanks