Blender Internal - Export .fbx with Proper UV Channel

The objects that I’m exporting to .FBX have more than 1 UV channel or UV layout.

  • One for baking with many other objects
  • Another for the original UV layout I used to paint with or put image textures on.

When exporting to .FBX, Blender 2.79 (Internal) defaults to using the original UV Channel instead of the Baked one.

Thus making everything look “glitched” when used in Unity.


Is there any way to tell blender which UV channel to use when exporting to .FBX?

I know we can set the active UV layout to be rendered by toggling on the Camera icon below but it doesn’t work when exporting.

image

Setting the material’s Texture coordinates to: UV and Map: BackedUVMap didn’t work either.

image

A solution is deleting the original UV channel for every object but doing so would not be Ideal

  • Destructive editing: Inability to go back and edit textures. (Bad for my workflow)
  • Possibly time-consuming when having more than 100 objects for my real projects.

Any other Ideas?

I think you can delete UVs with python in a copy of your .blend file.

Select all objects in the scene and run code:

import bpy  

selection = bpy.context.selected_objects

# UV Map to remove
uv_name = "BakedUVMap"

for obj in selection:
    if obj.data.name in bpy.data.meshes:
        for uv_map in obj.data.uv_layers:
            if uv_name in uv_map.name:
                uv_textures = obj.data.uv_textures
                uv_id = uv_textures.active_index
                uv_textures.remove(uv_textures[uv_id])

The script seems to be working. However, it deleted the active UV Map instead of deleting maps by name.

I’m not familiar with python but I wonder if the code translates to:

"If a UV Map with a specific name exists for the selected object…

…Delete whatever is the Active UV Map"

This is a problem because the active UV Map is the one I wish to keep.


Is there a way to delete all other non-active UV maps?


Code%20Deletes%20only%20Active%20UV%20Map

Try this for deleting specific map:

import bpy  

selection = bpy.context.selected_objects

# UV to remove
uv_name = "UVMap"

for obj in selection:
    if obj.data.name in bpy.data.meshes:
        uv_textures = obj.data.uv_textures
        
        for uv_map in obj.data.uv_layers:
            if uv_name == uv_map.name:
                uv_textures.remove(uv_textures[uv_name])

Attempt to delete everything exсept specific map:

import bpy  

selection = bpy.context.selected_objects

# UV to keep
uv_name = "UVMap"

for obj in selection:
    if obj.data.name in bpy.data.meshes:
        uv_list = []
        
        for uv_map in obj.data.uv_layers:
            if uv_name != uv_map.name:
                uv_list.append(uv_map.name)

        for u in uv_list:
            uv_textures = obj.data.uv_textures
            uv_textures.remove(uv_textures[u])
1 Like

Both scripts worked for me and did what they were meant to :slight_smile:

I hope others will benefit from this automated solution as well, thank you for coming up with it.