Add a second texture layer to geometry

I’m trying to do a classic lightmapping, i log a geometry attributes and see the 3 buffers: positions, normals, uv:

Object { position: {…}, normal: {…}, uv: {…} }
normal: Object { itemSize: 3, count: 24, normalized: false, … }
position: Object { itemSize: 3, count: 24, normalized: false, … }
uv: Object { itemSize: 2, count: 24, normalized: false, … }

My question is, how to add a second UV coordinates layer to display the lightmap ?

I believe the second set of UV attribute need to be named uv2

uv2: Object { itemSize: 2, count: 24, normalized: false, … }
1 Like

Here’s what i read in the documentation of materials:

I’m looking for an example of this “second set of uv coordinates”.

How do i create this new attribute ?

If the first uv attribute is already set, you can clone it.

const uvAttr = geometry.getAttribute("uv");
geometry.setAttribute("uv2", uvAttr.clone());
2 Likes

Thank you, i’m gonna try that.

1 Like