I am currently working on an import/export plugin for Blender. The problem I have is with UV mapping of textures. Lets say I have two objects using same material. This material has multiple textures. Also every object uses its own UV mapping for textures, so I need to create different UV mapping for every object sharing one material with multiple textures. I tried two ways, but each has some issues:

  1. Creating UV layer for mesh, it works fine for materials with one texture - every objects is using its own UV mapping even when they are sharing single material. But when the material has multiple textures, then all textures for my mesh are using same UV map - which is definitely something I do not want - each texture has to have its own UV map. I can create multiple layers, but only one layer can be active at the time.

  2. Creating UV mapping for every material texture. It works fine for materials used by single mesh - every texture of material has different UV mapping, which is fine. But when I have more meshes sharing single material, then all meshes are using same UV map - again, its something I do not want.

I also want to keep single material - do not want to duplicate it. Is there any way how to achieve this (like create multiple UV layers for every mesh, assign each layer to one texture and activate them all)?

  • $\begingroup$ I am not quite sure I have understand your goal, but why not creating a new table where you can connect different ID's and combine textures - materials and UV layers per object ? $\endgroup$ – cnisidis Sep 15 '18 at 16:13
  • $\begingroup$ Can you tell me a little bit about the "table"? I am not much experienced Blender user, so I am not sure which table do you mean. When user import file into Blender, I want to preserve as much model settings as possible after export (so if imported file contained only one material, I want to preserve this one material after export, etc). My goal is to assign for each object independent UV map for every texture of used material - mapping for this object and material should be independent from mapping for different object but same material. $\endgroup$ – J. Havran Sep 15 '18 at 17:05
  • $\begingroup$ mainly an "array" in python responsible to hold the different combinations by indices. You said "working on import/export plugin" so I though that you would be already in coding. no ? $\endgroup$ – cnisidis Sep 16 '18 at 22:07
  • $\begingroup$ Sure, but I thought you are talking about some bpy specific structure. I dont have problem about creating it in python, but I do not know how to achieve it in Blender python API. For second described way (my first post) I am creating new uv_texture for mesh (uvtex = bpy_mesh.uv_textures.new()), then new layer (bpy_mesh.uv_layers[uvtex.name]) and finally filling layer data by uv coords. As I said, only one layer can be active at once, so this way I can not map multiple textures with different UV maps... $\endgroup$ – J. Havran Sep 17 '18 at 19:26
  • 1
    $\begingroup$ I think you can do it via cycles, by picking the proper UV map. It hasnt to be the active one. This info counts mainly for export. Each material may hold a different UV layout. $\endgroup$ – cnisidis Sep 19 '18 at 15:05

So I finally figured out how to fix my problem. The solution is pretty simple - just create new uv_layer for texture with same name as uv_layer in mesh.

Here is fix for my plugin for everyone who is interested in: blender-plugin-vietcong


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.