We finally got lightmap baking working in world, and it looks awesome! Steps:
- Wrote an exporter that takes our parcels (you can consider them mini-scenes) and exports an indigo renderer .igs file with embedded meshes
- Bake the meshes (we have a windows PC with RTX 2070 super that can bake reasonably quality lightmaps in about 10 seconds)
- Convert the meshes to .jpg and upload to S3
- Load the meshes in world.
https://www.cryptovoxels.com/play?coords=NW@13E,3N
The only really clever trick we have to do is to deterministically create the uv lightmapping coordinates, we use potpack.js (since we’re only packing quads) and lodash sortBy (for a stable sort function). Because we generate the same lightmap coords on the client as on the baking server, it means we only need to fetch the jpg for the lightmap, we don’t have to store uv coordinates anywhere.
By using lightmapTexture
in babylonJS, we get a nice blending of the lightmap with our textures, which comes out looking pretty nice.