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

[Released] [FREE] Vertex Painter 2.0, paint on mesh instances, splat map shaders, Flow maps, AO, etc

Discussion in 'Assets and Asset Store' started by jbooth, Feb 8, 2016.

  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    A while back I wrote a nice little vertex painting system that used Unity 5.0's additionalVertexStream feature to allow you to paint on mesh instances. I've added a ton of new features to the system, a fully PBR splat map shader with flow mapping and support for 5 splat channels, and released it on my GitHub account today.








    Get it here:
    https://github.com/slipster216/VertexPaint

    Features:
    - Requires Unity 5.3+
    - Paint on mesh instances using the new additionalVertexStream features of Unity 5
    - Supports Color, Position, and UV0-3 as targets for data
    - Paint mesh deformations, with correct normal and tangent adjustments
    - Paint Flow direction, for flow mapping and other effects
    - Bake Ambient Occlusion and simple lighting to any mesh channels
    - Bake Pivot of the mesh into mesh verts- useful for shatter effects, particle trees, etc
    - Bake out data to mesh assets

    Splat Blend Shader features:
    - PBR shader based on Metallic or Specular workflow
    - Blend up to 5 layers of splat texture based on height value in diffuse alpha channel
    - Designate one layer as a Flow map layer
    - Support for alpha and refraction on Flow map layer (for water effects)
    - Multiple UV scales for large terrains
    - Only pay for what you use, the rest compiles out

    And a bunch more I'm likely forgetting. Enjoy.
     
    Last edited: Apr 2, 2016
    Rahd, TeagansDad, JamesArndt and 18 others like this.
  2. b4c5p4c3

    b4c5p4c3

    Joined:
    Jan 4, 2013
    Posts:
    537
    wow very cool
     
  3. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    Awesome!
    Thanks
     
  4. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    335
    thank ++
     
  5. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Thank you for your generous contribution :)
     
  6. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Brilliant work, and thanks!
     
  7. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    This is wonderful, I'm looking forward to integrating this into my workflow!

    I have a small issue, which really has nothing to do with your tool. And more to do with the shaders.
    So far my project has been using either toon shaders, or legacy / specular setup shaders, as I'm going for a flat comic style look.

    Attached is an example Illustrating my problem. My cartoony textures get washed out when I turn off the metallic and smoothness settings, but in a specular setup, I can change the specular color to black, and the albedo retains it's saturation.

    I don't know much about shaders so this may be a stupid question, but I was wondering how I could change these shaders to use a specular setup instead of a metallic one? Would this be a simple thing to do? Would the shaders need to be re-written, or just a small amount of code changed?

    Anyways, this is such an amazing tool. There are lots more features in this tool, than a lot of the vertex painters I've seen on the asset store. Incredible. Thanks so much for releasing it to the public.
     

    Attached Files:

  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Metallic is the preferred workflow because it uses less data (no specular color) and just looks correct with less work. Specular workflow is nice because you can break the laws of reality, achieving some additional looks.

    Making a version of the shader which supported a specular workflow wouldn't be too hard, but if you're not familiar with shaders that shader is not the place to start- it's full of tricks to allow it to optimize our what isn't in use and not be a million lines of duplicate code. I'll look into rolling a specular workflow version of it when I have some time..
     
    mcbauer and ElectroMantis like this.
  9. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    If you would do that, I'd be forever grateful.

    Heck I'm already grateful.This tool is so cool, I never estimated how much fun it would be to paint flow maps hehe.
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, just submitted specular workflow to the repository..
     
    ElectroMantis, b4c5p4c3 and zenGarden like this.
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That work for you SecondBake?
     
  12. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    Ah yes, I downloaded it today and it worked pretty well for me. Thank you so much!
    Left you a tip on your github as well.
     
    Last edited: Feb 26, 2016
    jbooth likes this.
  13. ChBgt909

    ChBgt909

    Joined:
    Oct 1, 2015
    Posts:
    50
    This is an amazing tool!! However, i don't know if there will be compatibility issues with mobile devices, is that shader PC exclusive?

    Right now i'm using a simple splatmap shader that looks fine in the iphone 6 but everything looks pink in the iphone 4s, that's why im asking... since its an tool that i'd love to use to make my environments look more realistic
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's nothing platform specific about the shader; your main limitation is going to be cost if you add too many layers or turn on too many effects.
     
  15. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    Wow! Thank you for this. Is there a way to have any of the shaders utilize the alpha channel in the albedo texture?
     
  16. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    I believe the albedo texture's alpha is already used for blending the transition between the layers.
     
  17. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    Great asset works fantastic, just wondering is there a way to get this working with static objects? I'm getting these 3 errors "not allowed to acces vertices/triangles/colors on mesh" all assets are marked as Read/Write enabled in the importer.
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    When you mark an object as static, Unity no longer keeps the mesh data on the CPU- which means the vertex painter cannot access that data, hence the errors. Note that by default the vertex painter removed the CPU representation of the data after uploading it to the GPU in runtime mode. However, this doesn't make the mesh static, and in most cases you won't get the batching you'd like because every instance of your mesh likely has a unique paint job (which effectively makes it a new mesh). One way around this is to combine/bake the meshes out to unique assets on disk, and then they can be marked static.
     
    PartyD0nut likes this.
  19. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    Wow, thanks a lot for sharing! Great product!
     
  20. duplexius

    duplexius

    Joined:
    Apr 24, 2015
    Posts:
    44
    You wanted to know (in the video) what we think and here it is: Incredible! I love the way the flow is displayed with the arrows. Great work!
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I just updated this with a few new features to the shader, mainly the ability to create water surfaces with the flow layer, that refract what's beneath them.



    enjoy..
     
  22. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Unity should pick this and make it standard on the editor, as Unity doesn't have any vertex tool painter out of the box, what a shame in 2016.

    Thank you , that's so great.
     
  23. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi, thanks for sharing this.
    I am thinking about tinkering your tool so it can
    - smooth-harden normals
    - modify skinned meshes

    The later seems quite straightforward, I wonder about how to approach the first (normals). Do you have any suggestion ?
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Well, real hard edges require you to split the vertices so you have multiple normals. Is that what you're proposing? If so, you could write a utility to go through the mesh and split the vertices outputing a new mesh. Once that is run, you could have a brush that smooths/hardens the normals by lerping between the regular normal and a hard one. The system already keeps a list of connections from one vertex to it's neighbors, which might be useful.

    Also, if you are going to do normal editing, you likely want to add some mode to draw the normals as well.
     
  25. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Thanks for the feedback, I 'll post back in this thread when I have some results.
    It seems like I should "weld" somehow the vertices to smooth an edge and create new ones to harden it, kinda makes sense now.
    Kind regards.
     
  26. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    That sounds like a worthwhile feature imo. something to change the normal's direction would be neat to see too.
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I suppose what I would do is make two utility functions: One which splits all the verts, and one which merges any vertex together that is exactly the same as another (within some epsilon of position, normal, uv, etc). Then, what the user would do is make all the verts unique and use your smooth/harden brush to lerp between the flat and smoothed normal. When this is done, they run the merge utility to finalize the mesh.

    The reason I wouldn't change it dynamically as you paint is that the invalidation and re-upload of meshes is going to be slow. Additionally, the vertex painting system works on the .additionalVertexStream mesh, not the main mesh, and in this case you'd need to modify both with every edit. By making these utilities, you can modify the mesh once for editing, creating all the extra vertices and invalidating the meshes once. Then the user can paint normal modifications into the additionalVertexStream as they do normally- and once everything is the way they like it, the mesh gets welded back together to be optimal.
     
  28. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Surprised this hasn't got more attention :D

    Combined with
    http://forum.unity3d.com/threads/standard-shader-with-vertex-colors.316529/ its really good. Glad you made it free, why doesn't unity come with a built in vertex painter or any good tools and shaders like this I dunno but this really helped.

    Anyway added a little improvement to the UI.. couldn't stand having to use Unity colorpicker just to have color presets.. so I've added a color palette, it only uses playerPrefs to store/load color swatches when the ui/unity is closed.



    Would have liked to add color history, but unity color picker doesn't seem have any callback for when the user has closed the color picker ui and decided on a chosen color. Also kinda dumb how their color picker disappears after choosing a color (with no way to keep it open while using it) so I know it has its own color presets feature but not that useful for quicker workflow when you still have to open the picker panel everytime to use it.

    Also its really annoying how the active mesh shows the selected object polygons, with no way of toggling that in the Unity editor, really makes painting some objects annoying. Anyone know of a fix for that to hide selected active object polygons?
     

    Attached Files:

    wolfen231 likes this.
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hey Player7,
    Thanks for the submission. I've cleaned it up a bit and added it into the repro. It now uses EditorPrefs instead of PlayerPrefs, and the color array is stored in a small scriptable object, which allows it to be serialized using the new Json serializer in Unity. This allows it to be stored as a single item in the EditorPrefs as a string, and avoids any string garbage when serializing.

    Yeah, I considered having a workflow where you manually add meshes to a list of meshes to be edited rather than using the selection, but it seemed much clunkier that way. In many cases, it's nice to see the mesh, but in others, not so much. It might be possible to add a way to lock the list to the current selection and then deselect the items, but it could easily become confusing - I might play with the idea when I get some time.

    Glad your enjoying the toolset; I was having a particularly non-graphics month or three at work (dealing with AssetBundles and Unity's broken import and build system) and had to work on something fun for a while. I was writing a shader and needed to edit some vertex colors, and couldn't believe I couldn't find a half way decent vertex painter. I wrote one in a few hours and released it, but then just kept going for fun, eventually adding the splat map shaders, etc.
     
  30. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    EditorUtility.SetSelectedWireframeHidden(yourRenderer, true);
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, nice find! I'm going to add an option for that soon..
     
    zenGarden likes this.
  32. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    This tool seems really cool, but is their any documentation for it? I've set up a few layers but I'm kind of lost as to how to choose what layer I actually want to paint. I watched the video, had a play with the example scene but not really sure how the colours in the palette relate to my layers? I must be missing something obvious.

    Edit: See how it's supposed to work now, but whenever I try to paint nothing happens. No errors. But nothing changes, in the normal view or vertex data. Fill/Random does work though. Strange.
     
    Last edited: Apr 9, 2016
  33. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    Try changing the flow value to be higher, that helps for me.
     
  34. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    :rolleyes: Total brain fart on my part, I was trying to paint a huge plane made out of one poly then realised why it wasn't working :D

    Any plans to support custom brush shapes?
     
  35. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    yeh PlayerPrefs was just seemed quicker for me to use, I like the new way... the EditorUtility.SetSelectedWireframeHidden(yourRenderer, true); would be good to see a toggle for that.. I ended up back in maya doing vertexpainting, found the tool was a little slow on visual updates when painting heavier geometry and I can just hide the polygons while painting on the active object in maya still, but then back in unity its still useful to see the materials so I'm still using the the tool plus tweaking. Funnily enough I miss the color swatches in maya (not sure if its possible to edit its own vertexpainter window to include the same addition now lol, I haven't touched mel in years and would not want ever again, really can't stand those type of scripting languages c# much nicer :)

    As another suggestion can you make the occlusion baking have a multiplier bake option, so it doesn't completely wipeout the current vertex colors
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    [q] As another suggestion can you make the occlusion baking have a multiplier bake option, so it doesn't completely wipeout the current vertex colors [/q]

    So, just multiply whatever is there by the result? Sure. I usually bake it into it's own channel and combine in a shader, but that's easy enough to do..

    [q] Any plans to support custom brush shapes? [/q]

    Never needed such a thing for painting vertices, what's the use case?
     
  37. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    yeh that would useful.

    If you have experience with writing shaders, it would be easier though right :D
     
  38. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    @jbooth I think I was just approaching it wrong, a mesh with higher poly count allows for more detail. But I was wondering, it looks as if the tool expects albedo to have height in it's alpha? Or is their magic going on for it to figure out the height from the albedo?

    It's just with most of my materials, and probably most other folk aswell, the height map is separate and it's a bit frustrating to have to go through them, add height to alpha then save it out separately for use with the tool. Seems like it would be easier if each material had it's own height slot?
     
    Martin_H likes this.
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Having each material have a separate height slot would add an extra sample for the height information, which would make the shader significantly slower. Unity doesn't pack things this way with the standard shader because the height information is only used for parallax, and is therefor highly optional, where as in my shader it's fundamental to making it work.

    So, in the end, you're much better off packing your textures over having an extra slot, even if the extra slot would be more convenient.
     
    mantekkerz likes this.
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Multiply AO mode as well as the ability to turn off wireframe drawing are both added now..
     
    hippocoder likes this.
  41. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Works great thanks

    but wait...ain't be done here yet :D what about missing brush hotkeys ie maya/ps like interactive brush adjustments while holding down [key b?] + mouse left/right for brushsize, up/down for falloff or maybe flow.. a toggle wireframe hotkey wouldn't go a miss either ..

    edit_ Quick check of the source and I seen you actually had a hotkey for adjusting brush size interactively... I've made some improvements and included the above suggestions myself.. now brush handle doesn't follow mouse when you are holding [shift]+move mouse to adjust brush(adjustments work same as photoshop style) .. also instead stays in exact position you left it at just before invoking the brush size/falloff adjustments so you can clearly see the changes you make instead of the handle following the geometry shape while moving mouse (brush handle visual cue for brush falloff adjustments would be good though). Previously you also had it on [alt] aswel only as alt +mouse move +lmb is the same for viewport rotating, but was also adjusting brushsize, the value adjustments were so low I didn't even know you had already added basic support for it in code until making this post.

    oh and toggle wireframe I've put at ctrl+w

    i'm sure you'll tidy it up some more but should all work
     

    Attached Files:

  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Great, I'll take a look and integrate back into the project!
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    done
     
    wolfen231 likes this.
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Latest update is online. Here's the overview video:



    Included in this release:

    - MASSIVE optimizations for large meshes and large object counts. My test case is painting on hundreds of objects with over half a million vertices in real-time.
    - Custom Brush feature, which allows you to write your own brushes for the system. Want a brush that paints onto the color and UV channels all at once? A brush that paints 3d simplex noise over your mesh's colors, or displaces the vertices with noise? No problem, just write a small class to do whatever you want.
    - Example custom brush that paints 3d, world space, simplex noise onto mesh colors.

    This update was driven by a need I had at work to be able to paint "material like" sets of parameters onto terrain meshes. Traditionally, you'd do something like this in photoshop, but in our case we had 5 attributes which needed to be carefully matched, and a texture file only contains 4 (RGBA). So you end up having to reproduce the work in another texture, which can be very tedious and error prone. Plus, all that switching back and forth between photoshop and Unity slows you down. So the solution was to extend the vertex painter to allow us to paint custom data into the channels we want (in this case, a brush stroke will paint into all 4 UV channels and the color channels at once). We're then able to work right on our terrain, with our shaders, in realtime.
     
  45. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Glad you got the performance issues sorted out, it was the biggest detracting point of using this utility before.
     
  46. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    yeah :), i got a desktop game project starting soon and your shader will enhance a lot the scene.
    Thank you.
     
  47. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    There should be a notice that importing this can take a long time. The UnityShaderCompiler runs with 99% CPU (on a single thread) for minutes while Unity appears to hang. No idea what's going on there. But the 5 layer specular shader alone took over 3 minutes to compile.

    Probably that's just how it is, but a notice would make sure that other people don't make my mistake, think Unity is hanging and kill -9 it. :)
     
  48. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    After trying it out for a bit I run into a strange problem. I can paint nicely, but as soon as I click anything, in the hierarchy or even switch to deform or flow, the plane I'm using reverts to the Default Material, and everything is lost. What am I doing wrong?
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hey Tom,
    There's already a note about it both the readme and github page. Those shaders take a long while to compile because unity compiles multiple shaders for each combination of features, and since the shader has lots of features, it means it produces a ton of different shader variations.
    As for your error, I haven't seen this- are you using the default plane from Unity or something else? It may be something with how the editor caches off the material so it can revert it when your done painting.
     
  50. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Yes, I'm using the default plane. I'll try on a custom mesh soon.

    For the moment, I noticed that if I close the Vertex Painter window before I do anything else, changes are saved. If I keep it docked and go somewhere else, everything goes blank.