Search Unity

VPaint: Advanced Vertex Painting [Released]

Discussion in 'Assets and Asset Store' started by beck, Jul 27, 2013.

  1. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Thats really strange SilverStorm, are you receiving any errors in the console? If not, here are some things that might cause lag:
    - If there a lot of objects in your VPaint group, it might help to break it up into multiple groups
    - Very high resolution meshes are unavoidably laggy - meshes that exceed 10k verts are likely to slow down a bit

    As for the video tutorial, I'll be recording it soon but for now if there is anything you need help with feel free to ask and I will be happy to help.
     
  2. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    707
    Hey we wanna ask if your tool can be used in runtime mode. We wanna have ability to paint our models in game. Can we use your VPAINT outside unity editor in runtime mode?
     
  3. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    @reddotgames The VPaint editor was built only for use from within the Unity Editor. However, many of the features in VPaint have API access during runtime, for example AO baking, color blending, and interpolation.
    When asked this question from another user, I demonstrated how a runtime tool is rather simple at its core. Here's a link to the code that I sent him: https://gist.github.com/becksebenius/8480885
    Obviously it is missing accompanying UI elements, but hopefully that shows the general concept and helps you understand how to reach your goal. Just attach the script to any game object in the scene, drag an object with a mesh collider on it into the "paintTargets" array, and assign a material that displays vertex colors.
     
    Last edited: Jan 17, 2014
  4. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    I don't remember if this was asked already, but how does vpaint handle submesh materials?
     
  5. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    It doesn't actually need to: the only difference in a mesh that uses submeshes is how its triangles are assigned, so VPaint should function the same regardless of how you've handled your material ids.
     
  6. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Awesome, thanks :)
     
  7. Deleted User

    Deleted User

    Guest

    Hey, Not used VPaint for a while, just updated and I'm getting some weird results.
    $VPaintTexBlend.png

    I'm just trying to blend textures and I'm getting a really dark area where the 2 textures blend.
    I'm following your process outlined in the Pdf. I'm I missing something?

    How do I get a nice clean blend between 2 textures like you have here?
    (30 secs in) http://www.youtube.com/watch?v=8lXcHsP-6Ws do I need to set layers up as well? I don't recall doing this last time I used it.

    Thanks

    Wayne
     
  8. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Hey wr_uk, for the clean blend in the video I used a heightmap blend shader. It's a bit special in that it considers a heightmap and normal map when doing the blend. I'd like eventually to include a larger suite of those in VPaint but in the current version only the one in the demo scene exists.

    As for the dark area in the 2 textures blend, it seems that somehow that shader was broken in some cases! I'm surprised this hasn't come up yet, thanks for bringing it to my attention and I apologize for the discrepancy. Here's a fixed version of the shader; paste it into the file VPaint/Shaders/TextureBlendx2.shader.

    Code (csharp):
    1.  
    2. Shader "VPaint/Lit/Blend 2 Textures" {
    3.     Properties {
    4.         _Color ("Base Color", Color) = (1,1,1,1)
    5.         _Texture1 ("Texture 1 (Red Channel)", 2D) = "white" {}
    6.         _Texture2 ("Texture 2 (Blue Channel)", 2D) = "white" {}
    7.     }
    8.     SubShader {
    9.         Tags { "RenderType"="Opaque" }
    10.         LOD 200
    11.        
    12.         CGPROGRAM
    13.         #pragma surface surf Lambert
    14.  
    15.         half4 _Color;
    16.         sampler2D _Texture1;
    17.         sampler2D _Texture2;
    18.  
    19.         struct Input {
    20.             half2 uv_Texture1;
    21.             half2 uv_Texture2;
    22.             float4 color : COLOR;
    23.         };
    24.  
    25.         void surf (Input IN, inout SurfaceOutput o) {
    26.             float4 color = IN.color;
    27.            
    28.             half4 t1 = tex2D (_Texture1, IN.uv_Texture1);
    29.             half4 t2 = tex2D (_Texture2, IN.uv_Texture2);
    30.            
    31.             half4 cum = t1 * color.r + t2 * color.g;
    32.             fixed fac = color.r + color.g;
    33.            
    34.             if(fac != 0) cum /= fac;
    35.             cum = lerp(_Color, cum, saturate(fac));
    36.            
    37.             o.Albedo = cum.rgb;
    38.             o.Alpha = cum.a;
    39.         }
    40.         ENDCG
    41.     }
    42.     FallBack "Diffuse"
    43. }
    44.  
     
  9. Deleted User

    Deleted User

    Guest

    Super that works great!
    yeah the height map blend shader look impressive.

    A similar thing seems to be going on with a few of the other 'blend textures bump'. The one I'm actually looking to use is the 'Blend 5 Bump Textures'. Is there any chance you could look at the one?

    Many Thanks
     
  10. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Bump on the tutorial. Making it should be pretty easy, I understand you might think you have better things to do. But as a customer I find that I don't feel like I spent my money well when I end up with a product I can't even use due to it's unorthodox design and a basic PDF that does not show at all the product in action. I has been around 2 weeks since I purchased your product and I think I have been waiting long enough.
     
  11. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    @wr_uk Dang, sorry about that! Here's the fixed version of the x5_Bump shader. I'll have all of these patched up in the next update:
    https://gist.github.com/anonymous/8553496

    @SilverStorm Sorry that you've had so much trouble figuring it out, your prodding has expedited the process ;) Here's a link to a tutorial video I recorded tonight:

    I hope that helps! Feel free to seek my help about any issues you may still encounter.
     
  12. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Thanks for the tutorial, I would like to see more if possible texture painting using textures as I don't intend to paint with simple colors. The AO was well done so thanks for that - I gave the video a like but I still want more !!!!

    :)

    A trick for the AO you could implement would be some sort of subdivision algorithm where it would subdivide the mesh by about 2 - 4 x and then use that shell to render the AO out - and then apply it to the original mesh - it should solve the resolution problem, one could do this outside of Unity but I think it would be much easier done within the editor, let me know your thoughts on this?
     
    Last edited: Jan 22, 2014
  13. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Thanks for the comments. I'd like to add more as well, in due time.

    For the AO, since it's not actually baked to a texture, it wouldn't end up with any different results. The resolution problem is pretty much inherent of how vertex colors work, so unless I either subdivide the mesh permanently (which would in most cases cost more than benefit) there would be no increase in resolution. The other option is to bake out to texture, which as I mentioned earlier doesn't really fit into the VPaint toolchain. When talking about baking AO to textures, you're talking about a total lightmapping implementation. That's just too much of a featureset to tackle for this tool - perhaps for another other tool, someday!
     
  14. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Nice video tutorial Beck.

    "The other option is to bake out to texture, which as I mentioned earlier doesn't really fit into the VPaint toolchain. When talking about baking AO to textures, you're talking about a total lightmapping implementation. That's just too much of a featureset to tackle for this tool - perhaps for another other tool, someday! "

    It's a shame you're not planning on implementing some sort of bake vertex paint to texture :(
    I'm not talking about AO bake, just vertex colors to texture, that would be super awesome.

    Anyway I understand some things could take too much time to implement.

    Thanks for video :)
     
  15. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Actually, baking vertex colors to texture is much more feasible (assuming that you have a unique UV set). The issue occurs when trying to do sampling that matches the resolution of a texture - for example, lightbaking directly to texture. That would require that I do per-pixel sampling rather than per-vertex, which VPaint really just isn't structured to do.

    Don't worry, baking vertex colors to texture is still on the table :)
     
  16. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    oh now I see :)

    Nice one beck :)
     
  17. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Purchased VPaint. Thanks for the awesome tool! Have just started using it on my project!

    Gary
     
  18. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    I have to agree with Mohoe. Baking out the vertex colors would be very nice, because then we could use it as a splat map for large meshes with where maybe it would be cheaper as a texture. Or maybe just to use vpaint to get the bulk of painting done, bake it to splat, then be able to fine tune it in photoshop.
     
  19. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Hey beck, so do you need a separate material per vpaint blend or can you have different blends per material? I'm guessing separate. I'm wondering because I want to use the same material on several meshes but the only thing that would be different between them is how they are blended. But maybe since your painting the vertices I don't need to duplicate the material? Hmmmm...
     
  20. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    As long as you're using the same set of textures, you can use the same material instance on as many objects as you want with no change in VPaint behavior. Definitely one of the advantages of using vertex colors - draw calls can still be batched together despite the meshes having different texture blends.
     
    Last edited: Feb 2, 2014
  21. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Hey beck,

    I've just encountered a minor issue with VPaint.
    I've dragged a prefab into the scene that contains a VPaintGroup and opened that group.
    I then duplicated parts of the prefab, selected the copies and assigned them to the last opened VPaintGroup via main menu.
    Now I tried to do some VPainting on the different layers - but every action took ages to perform, the editor suffered from severe hiccups.
    Trying to delete the old base color information and the old ambient occlusion information didn't yield better results.
    Is this a bug or am I missing a step here?
     
  22. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    What you've described definitely should work, and I just followed the steps your posted and wasn't able to reproduce the symptoms you described. Are there any errors showing in the console? Anything special about the objects you're duplicating? If not, a more detailed description of what you're doing could help me deduce the problem.
     
  23. Eduardo_BR

    Eduardo_BR

    Joined:
    Feb 7, 2014
    Posts:
    1
    Hey,

    I´ve been looking around and couldn't find if anyone asked this, so, can I use the Vpaint to blend between two textures within a single texture atlas?
     
  24. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    If you're using Unity's atlas functionality, it should work. Unity sets up your UV inputs on a per-texture basis, and I believe that's where they inject the proper offsets for your texture atlas.
    If you're atlasing your textures manually, you will likely need to use multiple UV channels to properly blend them together. The built-in VPaint shaders don't support this, but it would just require simple modifications.
    If you're talking about using Unity2D's atlas functionality, I doubt that will be possible.
     
  25. Deleted User

    Deleted User

    Guest

    Hey can we use our own shaders? Does VPaint work without any issues on mac?
     
  26. Filto

    Filto

    Joined:
    Mar 15, 2009
    Posts:
    713
    Can you "bake" lighting into the vertices in an easy manner. So one can light a scene, bake it and remove all realtime lights after that?
     
  27. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    @gotstyle Yup, VPaint provides a set of shaders but you can use any shader you like. VPaint's primary utility is getting vertex colors on your model, and what you do with them isn't restricted in any way. At some point I'll be putting up a tutorial on setting up vertex colors in ShaderForge. And yes, it's fully functional on Mac.

    @Filto VPaint doesn't have a direct lightbaking feature, however it can import lightmaps to vertex colors automatically. So to achieve what you're talking about, you would first bake your lights to a lightmap, then import the lightmap to vertex colors. You are then free to remove the lightmap in order to save memory. Unfortunately this requires that your models have a 2nd UV channel. There have been requests for a direct light baking feature in this thread, and I've responded to those with, effectively, this message: It definitely would be great, and it's not off the table, but it's a pretty large feature and probably won't make it into VPaint anytime soon.
     
  28. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Beck,

    Would VPaint work on iPhone?

    Regards,
    Carlos
     
  29. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Hi Carlos,
    I don't have the capability to build to iOS from my setup so unfortunately I can't give you an answer with full confidence. However, I have spoken with users who are building to iPhone and they have not reported any problems. If you purchase the tool and run into problems when building to any platform, I can offer high priority support in fixing the issue.
     
  30. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Beck,

    Thank you for your quick response. I have a final question, do your tools allow me to paint with textures, sort of like Unity's terrain? For example to paint with a sand texture and area of the mesh and with a rock texture on another area? And if so, would the mesh need to have UVs? Thanks.

    Regards,
    Carlos
     
  31. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Yup, that's definitely possible. VPaint comes with shaders which support up to 5 different textures on a single mesh. These shaders do require that the mesh has UVs, although you could write your own variation that uses triplanar or orthogonal projection.
     
  32. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    Hey! Have you released the update fixing the dark texture blending or am I doing something wrong?
    $3c1c1f90a9ed100018f3a47069186f64.png
     
  33. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Beck,

    I just bought your VPaint tool last night and I have played with it. I don't know yet how is going to work on the iphone because I used the tool in my PC and I trying to make a package to import into my iphone game that is running on my MAC. Could you explain to me(this is not in the pdf help file) how to do so please? The resume, I have the mesh in both my pc and my mac, I painted the the textures with you VPain tool in my pc and I want to send everything painted now, to my MAC.

    Regards,
    Carlos
     
  34. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    By the way the tool works beautifully. I recommend it to everyone. Oh and I am using the 3 texture blend shader, since I need it to run on the iphone.

    Regards,
    Carlos
     
  35. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Sorry. I totally forgot to check back on your reply. I'll try to replicate this behaviour when I find the time these days.

    And now for something completely different...
    Will there be vertex painting per face or per face vertex at some point like there already is inside packages like Maya?
     
  36. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    @Warrior1424
    No I haven't put that update up yet, I'm hoping to finish a few more additions before uploading it. If you can tell me which shader is giving you the trouble, I'm happy to post a fixed version for you in the meantime.

    @strongbox3d
    Thanks for purchasing!
    To transfer from one project to another, you could use Unity's built-in package system. Select your scene or prefab and use the menu item Assets/Export Package. Then, import your package on your mac project and you should be good to go. Transferring VPaint Objects will require that you have VPaint in both projects - to ensure this, you could just include the VPaint project in the package as well.

    @Marco Sperling
    Currently that isn't supported in VPaint. I agree that there is utility in this feature, though, so I'll add it to the future feature list.
     
  37. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Howdy, Beck. I just picked up Vpaint. Quite a suite you've made here! Forgive me if this has been asked, but is there a way to save over your mesh on disk with your newly painted vertex colors?
     
  38. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Hi djweinbaum, thanks for your purchase. There isn't currently a way to save over the fbx file itself - I've been tooling at an fbx exporter for a while now, but it's nowhere near a releasable state. I hope to finish it soon though, because the workflow implications of being able to export your VPainted object are awesome.
    There are two other ways you can make your mesh instance "permanent":
    • Select the Break Instance option in the Object Manager - this will break any connection to the original FBX file.
    • Export the mesh instance as a .asset file. The current version of VPaint doesn't include this functionality (the next version will) but I've released a little script which handles that, which can be found here. Select a game object and execute the menu item "Assets/Export Mesh Instance". Although this does not allow you to use your painted mesh outside of unity, it does mean that you can use the mesh throughout your project (or other projects) without having to use a VPaint Object.

    I hope one of those solutions help :)
     
  39. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Does this work with marmoset skybox?
    Are there detail shaders available (ex. Chickens shader bundle)?
    Does this use vertex alpha? Paint it in the edge of a mesh for blending...

    Thanks!
     
  40. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    1. I can't be sure what features that Marmoset have added to skybox - I think you'd be best to direct your question to them, whether their shaders use vertex colors in any way.
    2. This is the same case as above. Any shader which uses vertex colors in their calculations will work with VPaint, so it's up to the shader author to answer your question.
    3. VPaint does paint to the alpha channel, and comes with several shaders which use the alpha channel to determine transparency.
     
  41. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    fair enough, I'll check with them. Thanks! This looks awesome.
     
  42. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Skyshop has a category of vertex color shaders that include Bumb Diff IBL, Bump Spec IBL, Diff IBL and Spec IBL. The vertex color simply multiplies against these. Skyshop currently has no blend shader except the terrain shaders, which to my surprise, will indeed use the RGBA of verts on a non terrain mesh.

    Beck, I've noticed that erasing will always influence the vertex alpha toward fully opaque, regardless of your color settings, alpha settings, or channel lock. Even if only the blue channel is checked, for instance, your brush will slowly turn all vertex alpha toward 255 as you paint. Even locking the channel to alpha exclusively, then attempting to ERASE alpha will actually just add it. Am I crazy?
     
    Last edited: Feb 26, 2014
  43. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    You know, after messing with this for long it doesn't seem like a big problem. You can create a separate layer for alpha only, and that keeps whatever transparency you paint protected.
     
  44. murraysinclair

    murraysinclair

    Joined:
    Nov 28, 2013
    Posts:
    2
    Hello,

    I am having difficulty getting vpaint's object blending to work. I have watched up getting started video on youtube but can seem to get it to work the way i would expect. Can you help?

    Cheers

    Murray
     
    Last edited: Feb 26, 2014
  45. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    @murraysinclair
    I just responded to your PM, although I didn't elaborate on the blending process at all. Could you give some more info on where you're getting stuck so that I can help further?

    @djwinbaum
    VPaint layers actually store a separate transparency channel that is used to combine the layers together. This is a lot like how photoshop works - the alpha channel is just another set of data, and transparency is treated separately. When you use the paint tool, you reduce the transparency of the area you paint on, and when using the erase tool you increase it. I hope that explains the behaviour you're seeing.
    If it doesn't, let me know - perhaps there is a bug you're seeing?
     
  46. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    *edit- Thanks! I'm a silly man and missed them.
     
    Last edited: Feb 27, 2014
  47. tscott

    tscott

    Joined:
    Jan 11, 2014
    Posts:
    5
    I'm not sure what I am doing wrong here...

    I have an object setup to use the "Blend 5 Textures" shader. I can paint on the object and the different textures show up. However, the color mask does not seem to be working. So, when I try to paint into just the red channel by selecting only "Red" in the color settings it still paints into all four channels. I can see this clearly by changing from "Normal View" to "RGB".

    Do I need to have different layers setup?

    EDIT - I created a new layer, deleted the original one and things started working...sort of. I can now paint into specific color channels. However, when I use the erase tool the colors go to black giving the illusion that they are deleted. When I go back and start painting over them the colors that were supposed to be deleted show up again....

    Thank you for the help,
    Todd
     
    Last edited: Mar 1, 2014
  48. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Hi tscott,
    The problem you're seeing is caused by the erase tool - it will make that part of the layer more transparent, but will not erase color data. There are some minor issues that can crop up with this, and this includes seeing "old" color data pop up when you're painting on a previously erased area. This is a problem I've been trying to solve for a while now, I'm sorry for the inconvenience it's caused you!

    One workflow change which might help avoid the problem is to use the per-layer colormasking. By creating an individual layer for each texture you're painting and masking out that channel, you can be sure that only those channels will be displayed from that layer.

    Another solution would be to zero out the color data before you erase so that when you begin painting on that area, none of the old color data exists. You can also select a black color and mask out that channel in order to reverse the effect you're seeing when it pops up.

    I know neither of these solutions are perfect but until I can fix this bug it is all that I can offer.
     
  49. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    is there a way to paint directly onto terrain?

    Also you said a while back that you would be adding a feature to bake out vertex colors to texture.. so are you really working on this?

    Can you list the features you're working on

    Thanks
     
    Last edited: Mar 4, 2014
  50. beck

    beck

    Joined:
    Nov 23, 2010
    Posts:
    294
    Hey MoHoe,
    No, there isn't a way to paint directly onto terrain. I'm fairly sure that terrain uses vertex colors under the hood, but there's no direct mesh access which makes it difficult to hook VPaint into it.

    Yup that's in progress. In fact, I have a working prototype of it, but I haven't yet built the UI for it. When I release the next update, there will be both a runtime API and an editor panel.

    I haven't compiled a full changelog yet, but here's the changes off the top of my head:

    - Fixed a bunch of shader bugs (including the black painting issue)
    - Fixed UI problems in the object manager
    - Fixed hidden layers being rendered when running preview operations
    - Fixed some common naming conflicts
    - Added ability to save/load color palette from file
    - Added option to instanced export mesh to a file

    Here are some things that I still have planned for the next update:
    - Finish the Bake To Texture function (w/ UI)
    - Add a How-To tutorial for creating vertex colored shaders in ShaderForge
    - Add option to define radius ranges (for working with very large or very small scenes)
    - Add a family of flow shaders, with built-in painting controls (hopefully)

    There are other changes that have been made that I need to track down for the change log, but hopefully that satisfies your curiosity. I'm currently engaged in some other deadlines, but I should be able to switch over to this pushing out this update in 2-4 weeks.