I am trying to access UV3 (uvmap) of mesh to apply a particular texture, however its not being named anything by my gltf exporter. How do I access these UV maps or change their relative name?
I wanted to change the uv3 name so that i can search for it in a easier way.
Anyways i have a MeshStandardMaterial with diffuse, normal and roughness maps. And i have a mesh with 3 UVs (1,2,3). Is it possible to apply diffuse to the mesh using uv3 and roughness & normal using uv1 to the mesh?
There is a custome shader solution but im sure there must be an easier way.
Yes it’s possible, but may require hacking the built in materials shaders.
Texture selection for those parameters is super complex already… since it has to handle, for instance: roughness float value, roughness map as single texture, roughness map packed into a shared texture with metalness+ao, etc. etc.
Sorry to interfere, I’m just dropping two ideas, which I have never used, so I have no clue whether they will work. Apologies if they don’t.
In respect to giving a custom name to the uv3 attribute, I assume you want to change the .name property of the attribute, not the name of the attribute itself (as a JS variable). If this is so, then I’d first try:
myObject.geometry.attributes.uv3.name = 'uv3';
In respect to using diffuse with uv3, roughness & normal with uv1, I’d try the texture.channel property. If it is not working, only then I’d dive into shader limbo.
The .name property just holds some user-defined name, which is not used internally by Three.js. Just like the .name property of a mesh. So, if the code says:
could you explain the process a little bit on .channel as I cant find much regarding using texture. Channel to apply textures within a material with multiple UVs.
As I said, I have never tried the .channel property. I only know that it exists. In the past, texture maps were bound do fixed UV coordinates. With this property you can define what UV set to be used for each texture map. For example, if the normal map has channel=1, then it uses UVs from buffer attribute uv1. If channel=0, the it uses uv0. Theoretically.