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
    Ok new shader about to be rolled out, it blends four texures / normals / specular based on specular map in alpha channel of diffuse maps and vertex color:

    All current customers, a link will be emailed to you.

     
  2. Disaster

    Disaster

    Joined:
    Oct 31, 2009
    Posts:
    43
    Sorry if this has already been asked in this thread, I had a good scan through but couldn't see any mention of performance. I was wondering what kind of impact using vertex painting would have on a game? I assume since it's just shader voodoo that it has very little impact.
     
  3. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Very little performance hit, though I suppose lower end computers will feel it more (and get less benefit from it as they'd have fewer textures to play with per material).
     
  4. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Each vertex on your mesh has a slot for color values (RGBA) whether you use it or not, it is encoded into your meshes vertices by default.
    It will be there anyway, so you might as well use it!
    You can paint color onto the vertices at no extra cost.
    But, If you add a shader to access those vertex colors (which my shaders do), you might see a slight performance hit, but it really depends on the shader.

    For instance, the basic blend shaders will not impact performance any more than the Unity terrain shaders; but the more complex shader I just posted would be a little more expensive.

    It really depends on the hardware, so that's why I've included different versions of shaders for fallback.
     
  5. Disaster

    Disaster

    Joined:
    Oct 31, 2009
    Posts:
    43
    Thanks for the response. It's probably just easier if I give it a go and see the impact on performance myself :)

    Out of interest, if the user didn't have the minimum requirement in order to run the more complicated example above, would you be able to gracefully degrade the shader so they'd still get some of the vertex painting, just not at the same level?
     
  6. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Yes, all of the blend shaders use "shader lods" which allows the shader to "fallback" to a lower quality shader if you specifiy this in a performance script in your scene.
    Shader LODs are explained here: - Click Here -
    The more complicated blend shaders use Shader Model 3, so if your card can't support those, they will automatically fallback to the shader model 2 verisons.
    Eventually it will degrade to a plain diffuse if you can't support it, but you have to be running some kind of dinosaur card.
     
  7. Disaster

    Disaster

    Joined:
    Oct 31, 2009
    Posts:
    43
    Awesome, thanks again. Hope I didn't de-rail your thread too much!
     
  8. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Oh no problem, glad I could help :)
     
  9. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    iv'e been using vertex paint for a while and let me tell you it is so good that it should be with every single unity user .
    also the support is very good too .

    recommended to all .
     
  10. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Now included with the package is a demo scene that shows how you would use this tool and shaders in an environment, as well as painting skinned cloth weights on a skinned model.

    Customers who already purchased will receive a download link in email.

    Demo scene includes textures, models and skinned model show in video:


     
    Last edited: Mar 30, 2011
  11. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    This looks extremely cool, but before I'd buy it I'd like to know if it will work on android\iphone and if so, how expensive performance-wise it would be? Would this be a good solution to do mesh terrain on mobile devices? What about drawing battle damage on vehicles?
     
  12. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    The shaders I would not recommend for iPhone, but I would be willing to look at writing a shader for iPhone. For this I would need your help to test them. I could make some meshes and have you test them with a test shader to see if they work for you. How does that sound?
     
  13. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    I would be happy to test anything for you also. I have Unity iPhone pro.
     
  14. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    vertexPainted mesh prefab
    vertexBlendShader + Material
    Should look like this:

     
    Last edited: Apr 23, 2011
  15. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    I only have unity android at the moment, but I'd be glad to test any shaders on it.
     
  16. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    If you would be so kind, please try the download link I just posted and see if it will work on Android, and what the performance is like.
     
  17. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Downloading now... :)
     
  18. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Looks fine in the editor with all the possible iPhone graphic emulation options.

    Here is a screen shot from an iPhone 4 with OpenGL ES1.1

    I'll try running on an iPhone 3 and an iPad next.
     

    Attached Files:

  19. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    Works (and looks fantastic) on android. I'm trying it on an original droid running 2.3.

    Getting 45-55 fps.

    For comparisons sake I stuck the sand texture using mobile vertex lit on the same mesh and I'm getting 55-60 fps. ~10 fps hit from blended shader.
     
    Last edited: Apr 1, 2011
  20. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Sweet! Thanks guys ;)
     
  21. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Works on the iPad 1 and iPhone 3. Of course, this is only 2 textures. I think the iPhone can support 4 since the 3GS.
     
  22. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    Just bought it. Thanks for making such a great tool.
     
  23. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Thank you for the business kind sir ;)
     
  24. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    This is fantastic. Very easy to use. Any chance of a 3 channel version of the iphone shader you made for me to try out?
     
  25. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    I'll take a look ;)
     
  26. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    Created a test terrain. Actually runs faster than the test mesh you gave me :p

    $snap20110331_183725.png
     
  27. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    That mesh looks more dense than mine too. Nice!
     
  28. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    Where exactly is the painting data stored? If I updated this mesh in sketchup and reimported it would it lose all the vertex colors?
     
  29. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Unfortunately the colors would not transfer to the new mesh. The old vertex painted mesh is stored in "_vertexPainter\_vertexPaintedMeshes", but it holds the old vertex positions.
     
  30. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    OK Patyrn, try this one; I wrote it as a two pass shader, but it's the only way I could find to blend three textures.

    @kenlem, this should work on the iphone too, if you want to check it.

    Code (csharp):
    1.  
    2.   Shader "iPhoneVertexBlend" {
    3.  
    4.     Properties {
    5.  
    6.         _MainTex ("Texture 1  (white vertex A)", 2D) = ""
    7.         _Texture2 ("Texture 2  (black vertex A)", 2D) = ""
    8.         _Texture3 ("Texture 3  (black vertex A)", 2D) = ""
    9.  
    10.     }
    11.  
    12.     SubShader {
    13.  
    14.         BindChannels {
    15.             Bind "vertex", vertex
    16.             Bind "color", color
    17.             Bind "texcoord", texcoord
    18.  
    19.         }
    20.  
    21.         Pass {
    22.  
    23.             SetTexture [_MainTex]  {    Combine texture - primary}
    24.             SetTexture [_Texture2] {    Combine previous Lerp(primary) texture}
    25.  
    26.         }
    27.  
    28.         Pass {
    29.  
    30.             Blend One OneMinusSrcColor  
    31.             SetTexture [_Texture3] {    Combine texture * primary}
    32.  
    33.         }
    34.     }
    35.  
     
    Last edited: Apr 1, 2011
  31. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    But how do I paint the third texture if it's also set to black?
     
  32. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Paint 0 alpha for texture 1
    Paint 1 alpha for texture 2
    Paint White for texture 3

    For painting this, just apply the iphone shader and don't use the "see vertex colors" button.
    You can't see the alpha colors painted on the mesh so apply the shader to see what you're painting.
     
  33. Patyrn

    Patyrn

    Joined:
    Feb 17, 2011
    Posts:
    57
    Really confusing sometimes which color\alpha combinations to use, but I figured it out. :)

    Unfortunately the third texture really takes a bite out of performance on the droid 1. Pretty steady at 35 fps.

    The result looks really good though. I think you definitely need bare-minimum 3 textures for terrain.

    $snap20110331_202042.png
     
    Last edited: Apr 1, 2011
  34. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Yeah looks great. Performance, not so much though. Surely will be better on the newer phones.
     
  35. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Haha :D.
    Reissgrant i am also wondering what is performance hit of this vertex tool. For example i would have arround 10 big rocks and few smaller models with vertex color applied (2 blended NormalSpecular shaders) per frame, how much bigger is performance hit comparing to just 1 shader per model without vertex colors?
     
  36. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    It really depends on the card, but I would say, generally, that you can use the normal specular shaders without much of a performance hit ( 5 - 10 fps? ), probably wouldn't even notice it on a upper end card.

    If you want to give me a test file, I can test it with and without shaders.

    The vertex color that is painted on the model, there is no performance hit for that (because the data is there anyway all the time, even if you don't use it, even on the primitive cubes you can create in the editor).
     
  37. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Ok so basically performance hit is then only from using 2 shaders per model instead of standart use of 1 shader. Ok i think that shouldnt be a problem.
     
  38. Deleted User

    Deleted User

    Guest

    I did a little test using a simple blending shader lerp-ing the texture and normal maps by the vertex colour (which I'm sure are similar to reissgrant's - in fact his might be faster. It's only for reference as it was rewritten in HLSL to work with the profile tool) and AMD's GPU Shader Analyser. The results are as follows:

    (pixel shader percentages slower)
    HD2xxx - 3.4%
    HD3xxx - 3.4%
    HD45xx - 3.4%
    HD46xx - 3.3%
    HD47xx - 3.3%
    HD48xx - 16.7%
    HD5xxx - 11.9%
    HD68xx - 11.8%
    HD69xx - 9.8%

    Given the longest shader took only 30 cycles (and the average was 9.2 cycles), I very much doubt the difference would be that noticable. Even the GPU with the highest percentage (the HD4870) could process 200 million pixels per GPU core (out of 16 pixel cores) with the blending shader ( 3.5 cycles @ 700MHz ) theoretically.
     
  39. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Interesting gaustwick. Anyways i am going to make purchase of tool next month becouse i have that stupid paypal sending limit.
     
  40. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @gaustwick, thanks for taking the time to do that!
     
  41. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Update 1.1.3:

    Vertex Painter package updated with two mobile blend shaders for iPhone and Android.

    1.) Shader 1: Blends two textures based on vertex alpha.

    2.) Shader 2: Blends three textures based on vertex alpha and white vertex color.

    Also, it is now available on the asset store!
     
  42. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I have one question non related to vertex painter...does anyone knows what is performance loss (or fps drop) if you are using more than 4 terrain textures?
     
  43. Deleted User

    Deleted User

    Guest

    No problem, and bought!
     
  44. benjaminbojko

    benjaminbojko

    Joined:
    Mar 16, 2011
    Posts:
    2
    I've been following this thread a bit and was wondering if it's possible to use this shader to change in realtime by modifying vertices alpha values?
     
  45. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    If you modify the vertex alpha in real-time, yes the shader will reflect that and change the textures. Is that what you mean?
     
  46. benjaminbojko

    benjaminbojko

    Joined:
    Mar 16, 2011
    Posts:
    2
    Yes, thanks! I'll look into using this for our project!
     
  47. John_Doe

    John_Doe

    Joined:
    Mar 23, 2011
    Posts:
    8
    This tool loox so damn sweeet!
    Really good work that surely is worth more than you charge .. I could put it into good use, hope I can afford it later on..
    (sorry but I's in need saying that)
    keep it up
     
  48. ehsangamer

    ehsangamer

    Joined:
    Apr 15, 2011
    Posts:
    34
    Hi

    You have done a great job . I have two questions :

    1. In your site there is an Indie version that cots 25$ and a commercial that costs 50 $ . what is the difference ?

    2. I saw that Ninja Camp is making a similar tool . When that tool is going to be released and what are the difference between your tool and theirs ?
     
  49. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    The only difference between the two versions is that the indie license is cheaper because I want to make it affordable to independent developers.

    Judging by the ninja camp video, compared to my tool it does not look like they include:
    Skinned cloth weight painting.
    Random color generation on all vertices.
    No option to change the brush size / hardness while painting (you have to go back over to the window and drag a slider to change this where mine has hot-keys).
    Doubt they include desktop and mobile blend shaders with their package.

    Take that with a grain of salt, because they are just assumptions based on the short demo video I saw.
     
  50. ehsangamer

    ehsangamer

    Joined:
    Apr 15, 2011
    Posts:
    34
    Thanks for answer .

    Does your shaders contain parallax mapping ?

    Can you Give a short view of them that how are they .

    Thanks again. Sorry to bother .