Lightmap and custom uvs

Hi,
I created a raytracer which enables to bake light with the effects I want.

Now, I plan to use the baking in BJS. There is an issue though: let’s take a cube as an example. If that cube has a tiled texture and my light texture is not tiled, I wonder how I can tell BJS to use a different set of uvs for the lightmap.

Vertex buffers have up to 6 uvs but it ideally, I would redirect uv2 to the lightmap.

Otherwise my light map will be tiled as well…

How can I sort that out ?

Thanks!

Set the uvs for your lightmap in uv2 (mesh.setVerticesData("uv2", ...)) and indicate that your lightmap texture should use uv2 by doing:

lightmapTexture.coordinatesIndex = 1; // 0-based index

My savior :blush:

Thanks!