Uv3 not working properly for 2d texture array

Hello everyone I am trying to use the 2d texture array but I am running into a problem.
Here is a playground:

I don’t understand why I can’t pass the uv3. When I give uv2 cords it works fine but I can’t switch the texture layers. If I give it the uv2 cords and append the layer in the shader I can switch the faces that way.
Is there another way I can pass the layer that I want on a per face way?
Or is this maybe a glitch with babylon? I could just be totally wrong.

I am trying to make a voxel engine and the 2d array texture would be really helpful!

Thank you for helping!

I mean so far I was able to get pretty fare just using a texture atlas:

But this just seems like that one extra step I need for performance.

1 Like

UV set 3 is called uv3 in the shader, not uvs3.

But using uv3 won’t work because for Babylon all the uvX sets are vec2, not vec3. You should create a custom attribute instead:

https://playground.babylonjs.com/#NWFSGT#4

2 Likes

Hey thank you so much! That worked like a charm for me.
Saved me form a lot of head ache. I did not know about the custom shader attributes.
I also had another playground where I was using uv3 not uvs3. I was just trying everything I could lol.
But here it is working for me:

2 Likes