Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by insho · Jun 29, 2011 at 08:08 PM · textureshadersfbxvertexcolor

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,

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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()
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zardini123 · May 17, 2020 at 10:36 PM 1
Share

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

avatar image t0x1cj4m zardini123 · Dec 30, 2020 at 11:35 AM 0
Share

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

avatar image t0x1cj4m zardini123 · Dec 30, 2020 at 11:35 AM 0
Share

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

avatar image t0x1cj4m zardini123 · Dec 30, 2020 at 11:35 AM 0
Share

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

avatar image zardini123 t0x1cj4m · Dec 30, 2020 at 06:16 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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

Vertex Color: texture blending and shadowing 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges