Search Unity

Vertex Painter

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

  1. hmacyt

    hmacyt

    Joined:
    Jul 1, 2010
    Posts:
    203
    I did everything you said, the vertex colors are all pure red, it doesn't look much different from my last screen shot.
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    n00b alert ;)

    Can't get this to work in the latest version of Unity 3 (next version after beta 7). Not sure if we've recently changed something shader/rendering related since beta 7 or if it's too late here to be fooling around with this.

    Besides not being able to get it to work I also noticed that the Mesh Collider that you generate while the Vertex Painter is active is not properly deleted when exiting the tool. A minor thing if the user is aware of it, but might get certain people into trouble.

    Also, it would be nice if the painting required a mouse down as well as the Control/Command modifier key.

    But this is a really nice contribution to the community and thanks for sharing it... hopefully I'll get it working soon ;)
     
  3. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Thanks! Yes, I need to figure out what to do with the collider, but too many variables were involved in when I should / shouldn't delete a mesh collider, deselecting, closing, duplicating, etc so I left it for now. I need to revisit it I think...

    I will add a left mouse button to the painting as well.

    Any other suggestions welcome too :)

    aNTeNNa trEE, are you getting any errors or anything in the console?
     
  4. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Hmm, I'm still trying to think of what would cause this. I haven't forgotten!

    *EDIT Ok I fired up good ole' 2.6 and seems like I'm getting something similar to what you have. I'll see if I can find the cause.
     
  5. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @hmacyt

    Download the new 2.6 blend shader linked on the front page, it should fix the issue you were seeing. Let me know if you run into anything else. ;)
     
  6. hmacyt

    hmacyt

    Joined:
    Jul 1, 2010
    Posts:
    203
    thanks, I'll check to see if that fixed anything when I get hope, I'm excited to start messing with this shader and adding different maps for the B and G channels.
     
  7. hmacyt

    hmacyt

    Joined:
    Jul 1, 2010
    Posts:
    203
  8. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Pretty cool. If anything I will add a damage map channel. I doubt it will work on yours and other SM2 cards though because of the shader instructions required to do this.
     
  9. hmacyt

    hmacyt

    Joined:
    Jul 1, 2010
    Posts:
    203
    my card has sm3.0, any Nvidia card from the last 4 years has sm3.0
     
  10. SquishyPixels-Glimmer

    SquishyPixels-Glimmer

    Joined:
    Apr 30, 2010
    Posts:
    125
    this looks VERY cool! How do i install it to run the app within Unity? Does it work with Unity 2.6 basic? Thank you for sharing this awesome tech!
     
  11. Slem

    Slem

    Joined:
    Jan 28, 2009
    Posts:
    191
    Very, very nice!
     
  12. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Possible to have the blending be adjustable? Like a slider that sets the blend amount from 0 to full?
     
  13. SquishyPixels-Glimmer

    SquishyPixels-Glimmer

    Joined:
    Apr 30, 2010
    Posts:
    125
    would someone mind linking to the script that seems to be missing from the Unitypackage file, please? I need it for 2.6. Thanks in advance!
     
  14. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
  15. SquishyPixels-Glimmer

    SquishyPixels-Glimmer

    Joined:
    Apr 30, 2010
    Posts:
    125
    Hey! thank you very much for posting the script, reissgrant. I'll get to fiddling with this soon.
     
  16. Nick3d

    Nick3d

    Joined:
    Jan 28, 2010
    Posts:
    100
    Ok, something is missing in my material...

    I followed the tutorial and I can paint on the mesh, however I don't have the blend map assigned in the material.
    Since I placed manually each texture using the custom/blend shader I don't know how to get the blend map...

    Can someone helo me please?

    @reissgrand: this is awesome!!
     
  17. Al-Anselmo

    Al-Anselmo

    Joined:
    Apr 6, 2010
    Posts:
    86
    This is great!

    Would be even better if we got the possibility to chose a hue and randomize the value and/ or saturation of that hue, with a specified range.

    Example: I choose a blue hue and want the Vertex Painter to randomize the saturation, varying it in a range of 150-170. So, all I need to do is apply these settings and go crazy selecting my planes and hit the button "randomize", so each plane that I apply the effect will have a slight change on its saturation. Would be really great to have this too!
     
  18. Al-Anselmo

    Al-Anselmo

    Joined:
    Apr 6, 2010
    Posts:
    86
    Code (csharp):
    1. Bump ();
     
  19. gogopie

    gogopie

    Joined:
    Jun 25, 2010
    Posts:
    11
    I downloaded it but how do I install it on the unity engine? Does it work on macs?
     
  20. tornadotwins

    tornadotwins

    Joined:
    May 21, 2008
    Posts:
    308
    It's working pretty well for me, great idea!!
    A couple of bugs I found for ya:

    - When starting the game while still in 'see vertex colors' the shader won't get flipped back and you loose your drawing
    - A couple times when I restarted Unity after saving the scene the vertex colors didn't save and I had to start over
    - The draw-pane seems to have trouble sometimes (also on flat surfaces) to find the normal-rotation
    - ...but perhaps that's because of other geometry in the way?
    - When having multiple materials applied to a mesh painting can get a little weird

    Other than that it's working pretty darn spiffy!!
    I've been looking for this the last 2 weeks!

    -TT
     
  21. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @ Al Anselmo: Thanks I'll look at adding something like that, although you can apply different shades of blue already. Just click "apply random colors" and check only blue, now whichever mesh you select and apply, will have random colors of blue. However, you cannot select what range of blue you want yet ;)

    @gogopie: Yes, it will work on Macs, Unity version 2.6 and 3.0. Place the script in a folder named "Editor" in your main assets directory and it will appear as a menu on your top bar.

    @TornadoTwins: Thanks for the bug report, I'll see about fixing these when I can find some time. ;)
     
  22. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I've been using this, and it's really good. However I just upgraded to Unity 3.2, and now, every time I click "Save Scene" all my vertex colours get reset to white.

    T-T this is so annoying that it makes it pretty much unusable for me.
     
  23. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    OK, script has been updated to work with v3.2. Download the updated script in the first post.
     
  24. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    @reissgrant : THANKS A LOT FOR SHARING FOR FREE SUCH AN AWESOME TOOL !!!!!!!!
     
  25. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I'm still experiencing the same problem using the new script :\ has anyone else got it working in Unity 3.2 when you press "Save Scene"?
     
  26. ivanzu

    ivanzu

    Joined:
    Nov 25, 2010
    Posts:
    2,065
    This is awsome man.It looks so realistic.
     
  27. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Zomby, don't download the package, download the separate vertexpainter.cs added earlier, at the end of the first post.

    Where it says:

    Click here for the latest script to work with v3.2
    vertexPainter.cs

    place that vertexPainter.cs in your Assets > "Editor" folder.
     
    Last edited: Feb 14, 2011
  28. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    will you release a version with a 3 blended effect ( with R / G / B) ???? even though it has a cost this would be really appreciated. really nice tool.
     
  29. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Yes, if I have some time I want to release a shader that uses RGB channels instead of Grayscale.
     
  30. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    wOWWWW !!!!!! really waiting for such an asset !!!! good job !!!
     
  31. Broken-Toy

    Broken-Toy

    Joined:
    Jan 16, 2010
    Posts:
    455
    I expanded your work to use RGBA channels a while ago. This provides up to 5 different terrain textures, including the base background!
    Should be more than enough for most terrains...


    This example uses ice (background) then pebbles (red), leaves (green), snow (blue), and ...some kind of zerg creep (alpha).

    It works somewhat like layers, stacking one channel over the other (alpha being on top):
    Code (csharp):
    1.     // Calculate the first texture blend using Red channel.
    2.     colorBlend = tex2D(_BlendTex1, uv).xyzw;
    3.     normalBlend = UnpackNormal(tex2D(_BlendBump1,uv)).xyz;
    4.     vertBlend = IN.color.r;
    5.     mapBlend = colorBlend.a;
    6.     blendVal = pow((vertBlend+((1 - vertBlend)*mapBlend)+(mapBlend*vertBlend)*_blendPower),20);
    7.     blendVal = clamp(blendVal, 0.0, 1.0);
    8.    
    9.     _MainTex = lerp(_MainTex, colorBlend, blendVal);
    10.     _BumpMap = lerp(_BumpMap, normalBlend, blendVal);
    11.    
    12.     // Calculate the second texture blend using Green channel.
    13.     colorBlend = tex2D(_BlendTex2, uv).xyzw;
    14.     normalBlend = UnpackNormal(tex2D(_BlendBump2,uv)).xyz;
    15.     vertBlend = IN.color.g;
    16.     mapBlend = colorBlend.a;
    17.     blendVal = pow((vertBlend+((1 - vertBlend)*mapBlend)+(mapBlend*vertBlend)*_blendPower),20);
    18.     blendVal = clamp(blendVal, 0.0, 1.0);
    19.    
    20.     _MainTex = lerp(_MainTex, colorBlend, blendVal);
    21.     _BumpMap = lerp(_BumpMap, normalBlend, blendVal);  
    22.  
    23.     // ...And so on and so forth.
    I hope that helps.
     
  32. pinkhair

    pinkhair

    Joined:
    Dec 17, 2010
    Posts:
    141
    Will the shader show vertex colors saved in an FBX?
     
  33. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    @Werewraith : damned !!! yep i've seen this thread a long while ago it interested me but i was missing something with it. i think it might be helpful in many of my projects. Is it the same use than the one of reissgrant ( i mean painting vertex, sorry for asking i can't remember that, maybe i'd rather go and visit a new time your thread )
     
  34. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I really wish I had downloaded the wrong thing. But alas I downloaded the c# script and put it in the correct folder: 10.6 kb, Date modified 02/14/2011.

    I'm running windows XP 32bit, Unity 3.2.0f4

    I've tried making a new project and importing just the bare minimum, and I still get the problem.

    Could it be to do with my meshes ? I use .blender files, could the vertex colours be getting overwriten when the meshes get re-imported or something? (which maybe now happens when you save the scene?).
     
  35. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    @Werewraith: Awesome! That looks great! :)

    @Zomby138: Wow, I use it with Studio Max FBX files and got it to work; I would modify the vertices and click save, and they would stay the modified color. The meshes vertex colors will get overwritten if you re-import the model, but not if you save. I'll look a little closer tonight on my home machine (which has 3.2) to see if I can figure it out.
     
  36. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I've now tried it with some FBX files from the bootcamp demo, I got the same problem when saving.

    One difference I noticed was that with the FBX file the vertex colours start black, where as with the .blend they start out white.
     
  37. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    @reissgrant : how does this work if i'd like to export directly from 3ds max my models with vertex color info inside ???? May this be possible ???
     
  38. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Yes, this is possible. You just export an FBX with no special settings. As long as you assign vertex color in Max, they will be exported.
     
  39. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    OK, back to the drawing board...The mesh data is now being overwritten every time the scene is saved, in version 3.2. I have to figure out another solution...
     
  40. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    Oh what a shame !! too bad !!!!
     
  41. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    New version now works with version 3.2! Download the .cs script above.

    Now you will notice a "save" button to save your mesh.
    This will create a clone of the original mesh so it will not be overwritten.
    It will be saved in the directory of the selected object you are working on and automagically assigned to the meshfilter of your object.

     
  42. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Thank you Reissgrant! It works now :) although I noticed that it always generates a mesh called "_vertexPainted" which means if I paint on 2 different meshes the second one overrides the first. That isn't a big problem as I can just re-name the painted mesh as soon as it is generated.
     
  43. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    OK, I just made a small change, it will now generate a unique name based on the selected object ID, so you won't have to rename them manually. Link updated at the top.
     
  44. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    @reissgrant : you're just GREAT !!! By the way, if i use your tool to create assets, is it possible to sell them ???? your shader is really a damned important piece of code for those you create layout by cube / plane primitives, a real alternative to the terrain build in object. thanks again !!!!
     
  45. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Sure, no problem. I released the shaders and vertexpainter for free in hopes it would help others. Have fun :)
     
  46. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
    wOW !!!! so nice !!!!!! will put a read me file in those assets mentionning your thread and the one of Werewraith so that they have more information in case they'd like to tweak the assets. ( i didn't used those script and shader yet in a test scene but according to other users it seems to work as i want. a "must have" piece of code for artists ) this will really improve the result of my creations.
     
  47. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    Where?
     
  48. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    OK link is fixed now, somehow a bracket got lost in my editing, or just use this:

    View attachment 17686
     
  49. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    good work
     
  50. wagner.sz

    wagner.sz

    Joined:
    Feb 26, 2011
    Posts:
    5
    Hi reissgrant ,
    I installed the script, but I could not apply the materials to make the transition, can you help me?

    thanks