How to get auto-lightmapping to work?

I’m generating a map of blocks that is 23 x 23 x 20 at startup. Each mesh is set to:
receiveShadows = true
castShadows = true
castShadowsLightMap = true
lightMapped = true
isStatic = true
I’ve tried all combinations of true/false with the above flags.

I’m trying to use a directional light. It doesn’t matter what I set the light to with regard to the lightmapping flags (I’ve tried all combinations). After the map has been generated, I’m calling:

this.app.root.findByName('light-white-1').light.updateShadow();
this.app.lightmapper.bake();

The blocks are only lit if “Affect Dynamic” is switched on and Shadow Update Mode is set to “Realtime”, which appears to me to be indicative of the attempted baking not doing anything, nor of the lighting calculation working during the updateShadow() call.

Any help appreciated.

Hi @MikeClarke,

I think updateShadow() is not required if you are using lightmapped models and calling bake() (I may be wrong though). @mvaligursky any idea?

See the example here on how to bake lighting … it sounds like that is what you’re trying to do.
http://playcanvas.github.io/#/graphics/lights-baked

Make sure your meshes have UV1 coordinates generated.
Also look at browser console - this would contain warnings if you’re trying to bake meshes without UV1.

And yes, updateShadow should not be called at all.

1 Like

And here’s a PR, which is almost done, with bit more advanced baking … which should be ready hopefully in the next engine release

See the example there - the API is the same, just have some extra parameters.

1 Like

Also, looking at your other thread about batching - note that batching is not compatible with real-time lightmapping at this stage.

Thanks for the responses.

The shadow update is there in an attempt to just to have the lighting calculated once instead of every frame because baking doesn’t work.

Also, looking at your other thread about batching - note that batching is not compatible with real-time lightmapping at this stage.

After the lightmap has been baked, doesn’t the batching just work as if there’s no difference? I’m just curious as to what would stop it from being compatible.

Make sure your meshes have UV1 coordinates generated. Also look at browser console - this would contain warnings if you’re trying to bake meshes without UV1.

All of the meshes I’m using apart from one are built-in primitive boxes and planes. I don’t get any warnings.

If they all use different lightmap texture, that stops them from being batched.