Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Vertex Painter

Discussion in 'Assets and Asset Store' started by reissgrant, Sep 6, 2010.

  1. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    My shaders do not contain parallax mapping, maybe in the future if there is enough interest.
    There are examples throughout this thread of the various shaders included, if you check the past posts in this thread you will see them ;).
     
  2. Muronranta

    Muronranta

    Joined:
    Dec 22, 2009
    Posts:
    26
    I can't paint on object I have sculpted in Mudbox. It shows the vertex colors, but when I select "See blend shader" all I see are simple colors. The colors represent overall color of texture in material slots though, like it would endlessly stretch the texture or something. I have exported it in .fbx. and in .obj. I tried to export if to Max first and then to Unity, but it made no difference. I can paint on objects created in Max.

    Pic of problem: http://imageshack.us/photo/my-images/830/problemdhe.jpg/
     
  3. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    A few things you can try:

    Try applying the blend shader material to it manually, just drag the material onto the object in the scene
    Ensure every texture slot has a texture in it
    Ensure the model has uvs

    Let me know how that works
     
  4. Muronranta

    Muronranta

    Joined:
    Dec 22, 2009
    Posts:
    26
    How do I check if model actually has UV's? I don't know much yet...
     
  5. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    If your model does not have UVs, textures will appear stretched and generally distorted.

    Try applying a simple material to it with one texture, if it looks distorted or stretched, it probably needs UVs.
     
  6. Muronranta

    Muronranta

    Joined:
    Dec 22, 2009
    Posts:
    26
    Awesome it works now! Thank you for super fast support, this was a great purchase!
     
  7. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    How do I make use of the vertexBlend+map_DiffuseNormalSpec_SM4 shader. The one, I assume, for blending 4 textures using the height values in an alpha channel along with the vertex colours.

    I figured out the one that does two textures, but this one stumps me. Not sure how it works if there's only one "Blend Map" slot.

    I filled up all 9 slots and can't get it to do anything but show the last texture, regardless of which vertex colours I paint.
     
  8. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    I don't have the shader code in front of me because I'm on my playbook, but it will either be the blendmap rgba or the individual alpha channel from the diffuse or normal. Let me know if that doesn't matchup and I'll have a closer look.
     
  9. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    I got it to work by adding an alpha channel to the last Basemap texture. The other three Basemaps use the alpha for Gloss, and it blends whether they have an alpha channel or not.

    The shader seems to be incomplete. The texture slots are labelled Base1, Base2, Base2, Base2. And removing the Blend Map at the bottom had no effect... It still works!

    It seems to be working though I'm not sure where it's getting it's heightmap info, I blanked the alpha channel in the last Basemap and it still works, like it just wants there to be an alpha channel even if it's black.

    Could you provide a quick tutorial on how it's used? The label of each texture slot should be enough of an explanation usually but they don't all appear to be correct.
     
  10. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey there...just had a peek at your vertex painter...and I am currently using SSE to create my own shaders... will this work with my custom shaders to blend damage on fighters faces like let's say for a fighting game?
     
  11. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Hello Reissgrant, that tool is looking great, and one thing is holding me from purchasing :
    I'm expecting a negative answer as it would require extensive FBX knowledge, but does your "save meshes changes" apply to the Resources FBX mesh directly ?
    I have a lot of custom built prefabs which rely on FBX directly, and all my mesh modification workflow now rely entirely on Editor scripts.
    So it would take me a truckload of time to update vertex colors each time I want to reimport my modified FBX.

    I guess the answer is no ? :rolleyes:

    edit : nevermind I'll deal with it. Purchased ;)
     
    Last edited: Oct 10, 2011
  12. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @n0mad, Unfortunately, my plugin does not affect the .FBX file. It saves a copy of the file and leaves the .FBX intact.

    *EDIT too late, thanks for the purchase!



    @Neptune_Imaging, Sorry, I somehow missed your question. If you need to paint vertex colors in the editor to use with your custom shader, then yes, it will do that.
     
    Last edited: Oct 11, 2011
  13. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hiya, my artist is interested in this. He uses a wacom on the mac and we're wondering if it's supported in any way?
     
  14. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @hippocoder, I don't have a wacom to test on, but If the wacom can interact with the scene in the editor then it should work. Pressing CTRL / CMD will paint the vertex colors while the tablet pen is directing the location of where to paint.
     
  15. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    (yep, you can remap the pen button to CTRL)
     
  16. Rook3D

    Rook3D

    Joined:
    Sep 27, 2011
    Posts:
    19
    Hello, can you please tell me if your blend shaders work fully with lighting ( point / spot / directional ) shadows ? Thanks.
     
  17. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Yes, shadows will work with the blend shaders, with all light types. I think I show some shadows on the blend shader in the demo video in the first post

    *EDIT: yes, go to the 5:13 mark to see shadows working with the blend shader ;)
     
  18. Rook3D

    Rook3D

    Joined:
    Sep 27, 2011
    Posts:
    19
    Thanks, looks great.

    Another question - can I buy an Indie license and then 'upgrade' if things work out that way ( maybe pay for another Indie license ) ?

    Edit: Nevermind - I just found the Asset store version.
     
    Last edited: Oct 17, 2011
  19. Cyril

    Cyril

    Joined:
    Mar 19, 2010
    Posts:
    24
    hey reissgrant,

    is it possible to read the vertex color positions through scripting and pass it to a mesh which i want to create a SkinnedCloth at runtime?

    thanks for answer!.
     
  20. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @Cyril:

    As long as the mesh has the same vertex count, read: identical, then sure.
     
  21. Cyril

    Cyril

    Joined:
    Mar 19, 2010
    Posts:
    24
    ahh nice just bought it xD
     
  22. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Cyril, thanks! Post if you have any more questions! :D
     
  23. Cyril

    Cyril

    Joined:
    Mar 19, 2010
    Posts:
    24
    hmm its not working some how all vertex colors are blue
    im doing folowing things

    i have mesh body parts head / body / feet /.... and adding my armor to the body via script they sharing same/single animation of base character and the bones get compared and transformed to the corosponding bones through script after that i add the skinnedCloth
    NewObj.AddComponent<SkinnedCloth>();

    the GameObject uses the xxxx_vertexPainted but if i pause the game and check inscene all vertieces are blue

    what could be the prob?

    EDIT :: hmm just copyed the same GameObject removed the skinnedCloth and add new one without doing any changes on vertex color on the new GO assigned the same mesh xxxx_vertexPainted to it and all vertexes are blue :(
     
    Last edited: Oct 18, 2011
  24. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    I'll look at this later when I have some time.
     
  25. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    You have two objects, and are trying to transfer vertex colors from one to the other?

    Are you setting the vertex colors one by one, or all at once?

    One by one will not work you have to assign them all at once.

    So, make a temporary array, store the vertex colors in that array with a for loop, then assign that color array to the mesh color array.

    Something like this:
    Code (csharp):
    1.  
    2.  
    3. Color[] colors = new Color[oldMesh.vertices.Length];
    4.                                                    
    5. for (int i = 0; i < vertices.Length;i++){
    6.                                
    7.      colors[i] = oldMesh.colors
    8.                                    
    9. }
    10.                                                
    11. clonedMesh.colors = colors;
    12.  
    13.  
     
    Last edited: Oct 18, 2011
  26. Cyril

    Cyril

    Joined:
    Mar 19, 2010
    Posts:
    24
    hey reissgran,

    im reading the vertex colors with this code
    TEST = GameObject which has the painted Vertex color mesh in Editor and has tag test for testing purpose
    NewRenderer = SkinnedMeshRenderer of the TEST GO

    im geting only red colored vertices

    Vertex Color : RGBA(0.933, 0.067, 0.000, 1.000)
    Vertex Color : RGBA(0.937, 0.063, 0.000, 1.000)
    ...
    Vertex Color : RGBA(0.961, 0.039, 0.000, 1.000)
    ....
    Vertex Color : RGBA(1.000, 0.000, 0.000, 1.000)

    Code (csharp):
    1.  
    2. ....   
    3.         private SkinnedCloth NewCloth;
    4.     private GameObject TEST;
    5.     private SkinnedMeshRenderer NewRenderer;
    6.     private Color[] colors;
    7.    
    8.     // Use this for initialization
    9.     void Start () {
    10.        
    11.         TEST = GameObject.FindWithTag("test");
    12.         //NewCloth =    (SkinnedCloth)TEST.AddComponent("SkinnedCloth");
    13.        
    14.         NewRenderer = TEST.GetComponent<SkinnedMeshRenderer>();
    15.            
    16.         Mesh mesh = NewRenderer.sharedMesh;
    17.         Vector3[] vertices = mesh.vertices;
    18.        
    19.         colors = new Color[vertices.Length];
    20.            
    21.          for (int i = 0; i <vertices.Length;i++){
    22.                                
    23.              colors[i] = mesh.colors[i];
    24.         Debug.Log( "Vertex Color : "+ colors[i] );                     
    25.            
    26.     }
    27. ....
    28.  
    anyway to contact u? dont want to spam here :/
    or post at this threat xD
    http://forum.unity3d.com/threads/108361-ClothSkinningCoefficient-save-read-vertex
     
  27. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Cyril, just post in this thread, that way if someone else has a similar problem, they can find the solution ;)

    That code looks fine from a glance, but how are you assigning the code to the new mesh?

    You should be doing:

    Code (csharp):
    1.  
    2.  
    3. newMesh.colors = colors;
    4.  
    5.  
    If you want to get and set the skinning coefficient values, you may have to do each subtype individually:

    Code (csharp):
    1.  
    2.  
    3. ClothSkinningCoefficient coeff = selectedMeshSkinnedCloth.coefficients[i];
    4. coeff.maxDistance = oldMesh.coefficients.maxDistance;
    5. selectedMeshSkinnedCloth.coefficients[i] = coeff;
    6.  
    7.  
     
  28. Cosmas

    Cosmas

    Joined:
    Jan 9, 2010
    Posts:
    133
    Does Vertex Painter support reading values directly from a grayscale map? If so that would be perfect for a variety of uses.
     
  29. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    It does not currently, but the functionality would not be hard to add.

    Can you explain further? Do you mean assigning a uv mapped texture with the values, then the vertex painter reads those values and applies the colors? That would be pretty easy.
     
  30. Cosmas

    Cosmas

    Joined:
    Jan 9, 2010
    Posts:
    133
    Precisely. For example, I have a cubesphere mesh that's UVed and ready, and I've generated a greyscale heightmap to use later for displacement. But eventually I'll want to use the greyscale also for assigning vertex colors which will then apply 3-4 layered terrain textures automatically.
     
  31. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    I see, that would be easy to add. I'll push that into my next build. ;)
     
  32. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Vertex Painter works like a charm for me ;)
    It's perfect for adding tints, partial transparency to HUD objects and visual effects that are already split as prefabs.
     
  33. Cyril

    Cyril

    Joined:
    Mar 19, 2010
    Posts:
    24
    cant get it working dunno maybe a bug?

    im geting Blue Verts
    Coeff Max Distance : 0.1999994
    for Green Verts
    Coeff Max Distance : 0

    http://imageshack.us/photo/my-images/148/clothz.jpg/

    looks right for me

    maybe this line is wrong?
    NewRenderer.sharedMesh.colors = colors;

    if i remove this line
    Newcoeff.maxDistance = OldCloth.coefficients.maxDistance;

    i get Coeff Max Distance : 0.05 for all verts




    Code (csharp):
    1. private void ProcessBonedObject(SkinnedMeshRenderer ThisRenderer, GameObject RootObj )
    2. {
    3.        
    4.    /*      Create the SubObject      */
    5.    GameObject NewObj = new GameObject( ThisRenderer.gameObject.name );
    6.    NewObj.transform.parent = RootObj.transform;
    7.        
    8.    /*      Add the renderer      */
    9.    NewObj.AddComponent<SkinnedMeshRenderer>();
    10.    
    11.    SkinnedMeshRenderer NewRenderer = NewObj.GetComponent<SkinnedMeshRenderer>();
    12.  
    13.  
    14.        
    15.        
    16.    /*      Assemble Bone Structure      */
    17.   var MyBones = new Transform[ ThisRenderer.bones.Length ];
    18.        
    19.    for ( int i=0; i<ThisRenderer.bones.Length; i++ )
    20.       MyBones[ i ] = FindChildByName( ThisRenderer.bones[ i ].name, RootObj.transform );
    21.    /*      Assemble Renderer      */
    22.  
    23.        
    24.         NewRenderer.bones = MyBones;
    25.         NewRenderer.sharedMesh = ThisRenderer.sharedMesh;
    26.         NewRenderer.materials = ThisRenderer.materials;
    27.         NewRenderer.renderer.receiveShadows = false;
    28.         NewObj.tag = "Armor";
    29.        
    30.         //Base GameObject with Colored Vertices
    31.         TEST = GameObject.FindWithTag("test");
    32.         OldCloth = TEST.GetComponent<SkinnedCloth>();
    33.         //Adding to new GameObject a SkinnedCloth Component
    34.         NewObj.AddComponent<SkinnedCloth>();
    35.         NewCloth = NewObj.GetComponent<SkinnedCloth>();
    36.        
    37.         Mesh mesh = NewRenderer.sharedMesh;
    38.         Vector3[] vertices = mesh.vertices;
    39.  
    40.        
    41.         colors = new Color[vertices.Length];
    42.            
    43.          for (int i = 0; i <vertices.Length;i++){
    44.                                
    45.              colors[i] = mesh.colors[i];
    46.            
    47.             ClothSkinningCoefficient Newcoeff = NewCloth.coefficients[i];
    48.             Newcoeff.maxDistance = OldCloth.coefficients[i].maxDistance;
    49.            
    50.             //ClothSkinningCoefficient Oldcoeff = OldCloth.coefficients[i];
    51.             //coeff.maxDistance = OldCloth.coefficients[i].maxDistance;        
    52.             //NewCloth.coefficients[i] = Newcoeff;
    53.            
    54.    
    55.            
    56.         Debug.Log( "Vertex Color : "+ Newcoeff.maxDistance );  
    57.         }
    58.         NewRenderer.sharedMesh.colors = colors;
    59.  
    60.  
    61. }
     
    Last edited: Oct 20, 2011
  34. Rook3D

    Rook3D

    Joined:
    Sep 27, 2011
    Posts:
    19
    I was wondering if there was any performance impact when using the shaders with 3 or 4 textures as opposed to 2 ( or 1 ) ? Thanks.
     
  35. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    If you are on desktop, there is a performance hit, but not very big. SSAO, blur and the other post process filters are much more expensive.
     
  36. ikke

    ikke

    Joined:
    Jan 23, 2008
    Posts:
    15
    I am very happy with the Vertex painter, but I run into 2 problems with these shaders:

    mobile_VertexBlend_2tex_lightmap mobile_VertexBlend_3tex_lightmap

    1) The lightmap doesn't use the secondary UV map but also the primary (so even switching them makes no sense)
    2) The lightmap option on the mobile_VertexBlend_2tex_lightmap is'nt present, so it can't be added.
     
  37. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    iKKE, I will look into this.
     
  38. ikke

    ikke

    Joined:
    Jan 23, 2008
    Posts:
    15
    Please also check:

    mobile_VertexBlend_2tex mobile_VertexBlend_3tex

    I dropped the second UV map in the model, and generate them with unity. When using the unity lightmapper, textures using these shaders also switch to the secondary UV map, ignoring the primary UV map.

    If you want I can send yoy some models to test.

    Cheers

    Hans
     
  39. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @iKKe: I sent you a private message with the link to download the fixed mobile lightmap shaders. Let me know how they work for you.

    Regards,
    Andrew
     
  40. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @iKKe: I got the mobile blend shaders working with the Unity lightmaps and sent you a PM with the link to test.

    @Everyone: I will push out a new package shortly including these blend + unity lightmap shaders for mobile.

     
    Last edited: Nov 9, 2011
  41. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,080
    Do the texture blend painting only work on terrains?

    How is the performance on mobile.

    Also, can the results be converted to a texture2d for saving?
     
  42. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @ina:

    Texture Blend painting works on custom imported meshes as well as primitives.

    The performance on mobile depends on what device you are using. I believe there are some performance numbers from someone who tested them. Not sure if they are somewhere in this thread, or in the other thread (there are two threads).

    The results can't be converted into a texture2d at this time.
     
  43. ehsangamer

    ehsangamer

    Joined:
    Apr 15, 2011
    Posts:
    34
    I Have a problem :

    When you paint Red Color and then Blue Color on the Red ones They should turn into Purple Same as green and blur they should turn into Yellow .

    This the way that UDK Vetrx painter works . but In this tool It's kinda weird that there are no color combination and the color just replace with each other .

    That hurts alot .
     
  44. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Try checking the box that says "Blend Colors", that will blend the colors rather than overwrite them.
     
  45. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,080
    Do you have suggestions how how to save the resulting image, since it can't use the savetopng() method from texture2d?

     
  46. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    I'm not sure what you mean.

    A texture of the resulting blend between the different textures? Is that what you're after?
     
  47. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,080

    Yes, how do you save the resulting texture from the blends and other manipulations?
     
  48. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Off hand, I don't know of a way. I'll have to get back to you on that!
     
  49. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Does anybody know how to make the mobile shader to support lightmaps?
     
  50. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @elias_t:

    I sent out an email yesterday to all customers with a link to a new package with updates. PM me your email if you did not receive it. In the package is a mobile lightmap shader.