[MEL] Vertex Color to UV (Textureless Workflow)

asah53
vertex
Offline / Send Message
Pinned
asah53 vertex
Hello Guys,

I am currently working on my Bachelor Thesis for which I am developing a textureless workflow with Unity and MayaLT. I wanted to push as much Vertex information into the modell as possible. As Unity supports only one Vertex Color Channel, I am running into problems. This single Vertex Color Channel is color and baked occlusion information. Now I wanted to create metall and smoothness Information as vertex colors which are only greyscale. What I am now trying is to write a MEL Script which puts the vertex colors into the uv's. I found a script in python for blender which is capable of doing this : http://answers.unity3d.com/questions/137453/multi-layered-texturing-multiple-vertex-color-sets.html
This is my first try with MEL and I am now a little stuck. This is what I got:

//creating a new uv set
polyUVSet -cr -uvs "Metallic";

//set metallic as active uv set   
polyUVSet -currentUVSet -uvs "Metallic";

//convert the object selection into vertex selection 
ConvertSelectionToVertices;

//select metallic vertex color set as active   
polyColorSet -currentColorSet -colorSet "Metallic";

Not much, I know. I am now asking,  is it even possible to write such a script in MEL?

Thanks for you answers
Andreas


 



Replies

  • radiancef0rge
    Offline / Send Message
    radiancef0rge Polycount Sponsor
    What are you trying to do in the above script? Right now I can't really tell what you are trying to do with it. 

    puts the vertex colors into the uv's
    I don't follow this - vtx color is a float4 and uvs are a 2 axis coordinate. In this circumstance what I believe you'd want to do is convert your selection from vertex to uvs then set one of the coordinates of the uv to 1 and the rest to 0. 
  • asah53
    Offline / Send Message
    asah53 vertex
    What I did was just some selection. To be honest, I dont really know how the guy at the unity forum did save the vertex colors into the uv layers. I hoped that someone could explain it to me and may give me a solution for a MEL script. If it's not possible, it isn't a problem for me. It was just a thought in my mind, that it could be possible to store some more information into the vertices. But thanks for your replie, maybe someone has solution or maybe unity starts to support multiple vertex color channels.  
  • radiancef0rge
    Offline / Send Message
    radiancef0rge Polycount Sponsor
    you'd want to do is convert your selection from vertex to uvs then set one of the coordinates of the uv to 1 and the rest to 0. 

    This should work. Some untested code:

    cmds.select(cmds.polyListComponentConversion(tuv = True))
    uv = cmds.polyEditUV(q = True)

    Then transform 'uv' to U=1,V=0, then transform the inverse selection to U=0,V=0. 


    It was just a thought in my mind,

    I've stored various things into vertex colors and UVs. On my previous project I stored transforms for morph targets on a static mesh. So there ways to use extra vtx clrs or uvs that don't have the overhead of a texture sample. I don't think metalness is one of them to be honest. The distance between vertices is going to cause gradients along polygons, this may make the material appear strange. But I suppose for your project the trade off for visual quality is improved memory. UV sets aren't necessarily 'free' though. 

Sign In or Register to comment.