It only happens when I load my uvs inside the thin instance. My stride of 2 should be correct. I tried with a stride of 6 because custom_mesh is a triangle (2 * 3) but same thing.
The faulty line is clearly custom_mesh.thinInstanceSetBuffer("uv", Float32Array.from(my_packed_uvs), 2, true);
because when I do: vd.uvs = Float32Array.from(my_packed_uvs);
I have my texture visually intelligible for the triangles, but overall incorrect (that’s normal, the same coordinates are applied to all the instances the same)
I separated each triangle to narrow the spectrum of possibilities.
Each triangle has its own normals and uvs arrays.
I only use 1 uv per triangle.
That code works:
let vd = new VertexData();
vd.positions = Float32Array.from(my_packed_vertices);
vd.indices = [0,1,2];
vd.normals = Float32Array.from(my_packed_normals)
vd.uvs = Float32Array.from(my_packed_uvs);
let custom_mesh = new Mesh("my_name", scene);
vd.applyToMesh(custom_mesh);
custom_mesh.thinInstanceSetBuffer("matrix", Float32Array.from(my_packed_matrices), 16, true);
This one doesn’t:
let vd = new VertexData();
vd.positions = Float32Array.from(my_packed_vertices);
vd.indices = [0,1,2];
vd.normals = Float32Array.from(my_packed_normals)
let custom_mesh = new Mesh("my_name", scene);
vd.applyToMesh(custom_mesh);
custom_mesh.thinInstanceSetBuffer("uv", Float32Array.from(my_packed_uvs), 2 , true)
custom_mesh.thinInstanceSetBuffer("matrix", Float32Array.from(my_packed_matrices), 16, true);
My uvs are the same and work perfectly fine (visually correct) in the first code I am not interesting in. I want to use my thin instances.
Once I use the uvs in thin instance, I get the black and white result above…
To test what I am experiencing, please comment or uncomment the whole version 1/2 blocks. (only use one block at a time)
In the PG, the second version which has issue doesn’t have the same BW visual as I do but it doesn’t work either. Maybe something related to the env image…
This is in most cases not viable, UVs are like positions inherent to the main mesh. This is not like a global color you can chose per instance. The only thing you can add would be a uv transform matrix per instance, not a dedicated set per instance.
@sebavan : this was one of the solution I was looking at, but the shapes imply too many UV variations and even “numberofuvs / 6” will imply a huge number of meshes.
I will play smart and carefully choose my textures. Something like noise will do great and I will add some geometry, no way around.