- Home /
multi-layered texturing / multiple vertex color sets
does unity support multi-layered texturing? can i read multiple vertex color sets/layers?
i believe fbx does support this. maya does support this.
thanks,
Answer by insho · Jun 29, 2011 at 09:26 PM
found some documentation and another thread documentation reads...
"For every vertex there can be a normal, two texture coordinates, color and tangent. These are optional though and can be removed at will. All vertex information is stored in separate arrays of the same size, so if your mesh has 10 vertices, you would also have 10-size arrays for normals and other attributes. "
so the answer in short is "no".
but can you override the mesh data arrays.? can you double up the data in the arrays that are read in a custom way though the shader? will this work with fixed function or strumpy?
Answer by numberkruncher · Sep 13, 2016 at 10:45 PM
I needed two sets of vertex colors on my models for my current project; so I decided to use COLOR and TEXCOORD0(xy=rg)+TEXCOORD1(x=b) for my two sets.
To make it possible to see and paint the second set of vertex colors I created a little python script for Blender which allows me to tap Ctrl+Shift+F1
to quickly swap vertex colors with UV coordinates.
Just posting here in case this is of use to anybody; I was unable to find any existing scripts to achieve this.
# LICENSE: MIT
import bpy
bl_info = {
'name': 'Swap Vertex Colors with UVs',
'author': 'numberkruncher',
'version': (0, 1),
'blender': (2, 7, 7),
'description': 'Swaps vertex color data with uv1/uv2 data',
'category': 'Vertex Paint'
}
class SwapVertexColorsWithUVs(bpy.types.Operator):
bl_label = "Swap Vertex Colors with UVs"
bl_idname = "object.swap_vertex_colors_with_uvs"
bl_description = "Swaps vertex color data with uv1/uv2 data"
def execute(self, context):
self.report({'INFO'}, "Swapping vertex color data with uv1/uv2 data")
# start in object mode
obj = context.scene.objects.active
mesh = obj.data
# make sure that the object has vertex colors
if not mesh.vertex_colors:
mesh.vertex_colors.new()
# make sure that the object has uv data
while len(mesh.uv_textures.values()) < 2:
mesh.uv_textures.new()
# grab the active vertex color data layer
color_layer = mesh.vertex_colors.active
# grab the active uv data layer
uv_layers = mesh.uv_layers.values()
i = 0
for poly in mesh.polygons:
for idx in poly.loop_indices:
tempR = color_layer.data[i].color.r
tempG = color_layer.data[i].color.g
tempB = color_layer.data[i].color.b
#tempA = color_layer.data[i].color.a
color_layer.data[i].color.r = uv_layers[0].data[i].uv.x
color_layer.data[i].color.g = uv_layers[0].data[i].uv.y
color_layer.data[i].color.b = uv_layers[1].data[i].uv.x
#color_layer.data[i].color.a = uv_layers[1].data[i].uv.y
uv_layers[0].data[i].uv.x = tempR
uv_layers[0].data[i].uv.y = tempG
uv_layers[1].data[i].uv.x = tempB
#uv_layers[1].data[i].uv.y = tempA
i += 1
# set to vertex paint mode to see the result
bpy.ops.object.mode_set(mode='VERTEX_PAINT')
return {'FINISHED'}
def register():
bpy.utils.register_class(SwapVertexColorsWithUVs)
bpy.context.window_manager.keyconfigs.active.keymaps['Vertex Paint'].keymap_items.new('object.swap_vertex_colors_with_uvs',value='PRESS',type='F1',ctrl=True,alt=False,shift=True,oskey=False)
def unregister():
bpy.utils.unregister_class(SwapVertexColorsWithUVs)
if __name__ == "__main__":
register()
I updated this script for Blender 2.8 if anybody is still in need of this hack (as I do) https://github.com/zardini123/blender-move-vertex-color-to-uv-channels
Hey @zardini123
I'm trying to use the script with blender 2.91.0, I've installed the add-on, but cant see the option in blender search.
Sorry if it seems like such a simple problem, I don't have much scripting experience :D
Hey @zardini123
I'm trying to use the script with blender 2.91.0, I've installed the add-on, but cant see the option in blender search.
Sorry if it seems like such a simple problem, I don't have much scripting experience :D
Hey @zardini123
I'm trying to use the script with blender 2.91.0, I've installed the add-on, but cant see the option in blender search.
Sorry if it seems like such a simple problem, I don't have much scripting experience :D
Hi @t0x1cj4m, I updated from 2.87 to 2.91.0 to check out if I get the same issue. Yes, I cannot see it in search either. I'm imagining there is some API change for 2.9 that I need to consider.
I made an issue on the GitHub page for this. I'm expecting I'll get time to update it by the end of the week. Let me know either on GitHub or here if you have any other issues.
Your answer
Follow this Question
Related Questions
How to export FBX from 3dsMax to Unity3d with texturs applied to materials? 1 Answer
How can I "splat" a leaf texture randomly on my terrain? 0 Answers
I have unchecked "Import Materials" but two texture maps are still being imported. 1 Answer
How to read self when CustomRenderTexture dimension is Tex2DArray 0 Answers