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

Paint In 3D ✍️ Paint In Editor✏️ Paint In 2D

Discussion in 'Assets and Asset Store' started by Darkcoder, Jul 10, 2018.

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Paint in 3D currently doesn't support painting full PBR textures like you describe because they require storing the decal opacity in a separate texture, which none of the current blending modes support. However, this feature and a demo scene exactly as you describe is high on my to-do list, and will be in the next version. Perhaps mid next week I will have this feature implemented and included in the WebGL demo.
     
    beard-or-die and marcipw like this.
  2. beard-or-die

    beard-or-die

    Joined:
    Jul 12, 2017
    Posts:
    6
    Thank you for the quick reply and for actively working to add user requests. I purchased the asset and am playing with it now. :)
     
    Darkcoder likes this.
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    PBR painting is now implemented!

    I'll submit a new version soon.

     
    ParadoxSolutions likes this.
  4. tufeixp

    tufeixp

    Joined:
    Sep 6, 2015
    Posts:
    22
    How to paint on objects generated on the fly at runtime?
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Add the P3dPaintable & P3dMaterialCloner & P3dPaintableTexture components as you would in the inspector, but manually call the Activate() method on the last two components after you've set them up.
     
  6. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    325
    Is there a way I can apply a mask or brush type for decal painting? I have some square tiled images id like to paint rounded. Also the pbr texture painting supports the other maps right?
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Do you have an example image of what you mean by mask or brush type?

    Yes, the PBR painting supports all maps. It's implemented as a new blending mode (Replace), where all channels of the source texture are used as-is, and instead of using the alpha to define the shape (because PBR uses alpha for other things), the shape is defined in a separate texture. This means you can easily set up painting for any number of PBR maps with the same shape and have it work as expected.
     
  8. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    325

    Would this be possible with the blending layers? There are times where I don't always want a square texture when painting with decals but want more detail then when painting with just color. For example Procore's Polybrush texture blending:



    Example in p3d:

     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    You can do this using the P3dPaintSphereTriplanar component, demonstrated in the "Chalk Board" demo scene. You can't customize the shape using a texture though, that would require some combination of this and the decal painting. I'll add it to the to-do list, but I don't think it's such an important feature so it won't be high priority.
     
  10. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    325
    Ok awesome, I didn't catch that in the demo since the chalk was so small. So with the new PBR replace blend mode I can just set the sphere triplanar's mode to that and be able to paint both albedo and normal right?
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Yes, as long as you put the two textures in separate groups, and have two P3dPaintSphereTriplanar components each set to one of these groups.
     
  12. DrewDyksterhouse

    DrewDyksterhouse

    Joined:
    Mar 4, 2014
    Posts:
    1
    Does this tool keep track of the percentage of the mesh that is painted?
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    It can do if you use the P3dPixelCounter or P3dTeamCounter components, demonstrated in the 'Pixel Counter' and 'Team Paint Counter' demo scenes.
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Hey everyone,

    Version 1.5.7 Out Now!
    - Added multi touch support to P3dDragRaycast.
    - Added multi touch support to P3dDragRaycastSmooth.
    - Improved P3dBetweenRaycast VR support.
    - Added ‘Replace’ blending mode.
    - Added ‘PBR Painting’ demo scene.
    - Changed default P3dPaintable.Activation setting to make coding easier.
    - Fixed P3dPaintable.Activation = On First Use.
     
  15. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    I just started using this asset. nice job!

    I'm using it for character melee weapon collisions in order to apply damage in real-time.

    Quick Questions:
    1. I see the Groups option in the P3dPaintDecal component but I'm not sure what it does and there doesn't seem to be anything in the docs. What is a P3dGroupMask? And what is it used for?
    2. I would like to be able to use a List of Textures that can randomly be chosen with each collision. As far as I can tell P3dPaintDecal is only setup to apply a single texture over and over again. I plan to incorporate just what I need from your P3dPaintDecal code and use a List of Textures with a randomize option instead of only using one texture. I thought I would mention it as a possible feature request. Like sound FX, I'm sure some people would like the option to have a randomized selection of textures with each sword hit etc.
    3. I checked out the PBR demo scene but I didn't see any option to handle the normal map of Unity's Standard shader. Do you have any plans to be able to paint with a shader that can include normal maps?

    Thanks
    Allan
     
    Last edited: Sep 13, 2018
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    1 - Groups are used when your paint brush paints more than one texture at the same time, so you can specify which brush settings apply to which texture. This is demonstrated in the new 'PBR Painting' scene. I need to make some documentation for it though, so I'll add it in the next version.

    2 - Good idea, I've added it to the to-do list.

    3 - The 'Bullet Dents' demo scene shows you how to paint normals, you can just copy+paste that over and set up the groups so they don't interfere. I plan to improve the normal painting feature in a future version though, so I don't want to highlight it too much just yet.
     
  17. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Say Carlos!

    I have a product suggestion. A huge hassle in Unity is "painting lines on Terrain".

    screenshot.png

    For example that's a snow/ski scene, and we're trying to paint "lines" on it (rather as you might have lane lines in ski racing, or simply the white marker lines on a sports field.)

    (The above attempt is using dynamic decals, pretty much useless unfortunately, it's not the way to go.)

    Because Terrain shader is a tricky thing, nobody has ever really solved this.

    I can think of a couple approaches. (Perhaps perfectly build a mesh, which must be chopped in pieces, and perfectly LODs; or some sort of modification to the Terrain shading system.)

    I believe this is the single most common "unsolved problem" in Unity, maybe you're the man to solve it! :)
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    The problem with painting terrains is that they are rendered using a completely different system to normal MeshRenderer/SkinnedMeshRenderers, which means they require completely new code to handle.

    Another issue is that terrains are very large, and even a large 4096^2 texture is probably too low resolution to paint lines this thick.

    You can sharpen these lines using a thresholding approach like SDF does, but that means it requires a custom shader to render, which makes it incompatible with all terrain shaders, which are among the most popular Unity assets.

    These issues make it unlikely that the time spent developing these features will be worth it in terms of increased sales, and also it's unlikely the final result would please enough people. A depth buffer based decal system, or a mesh based one as you describe are probably better suited to this. If you're not finding the results you want then you may need to modify your game design by using pole/rope barriers, or some kind of holographic boundary, etc.
     
  19. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    HI Dark! Thanks for your time. Yes, TBC I was suggesting a totally new product.

    Whether (A) completely custom Terrain shaders (ie, a modification of Unity's base terrain shaders) (B) something that creates a mesh which works on top of Unity's Terrain or (C) decals that actually work on terrain - all three are tricky.

    My point was, you're smart enough you may be the man to do this :) It would be a great product! Cheers!

    BTW for alternatives for anyone who struggles with this (and everyone does), one natty solution is to use the incredibly handy voulmetric lines script (link) which you can then just "sit around" on your Terrain!

    screenshot 2.png

    Thanks again, cheers!
     
    Darkcoder likes this.
  20. MagicK47

    MagicK47

    Joined:
    Sep 5, 2017
    Posts:
    30
    How do I judgement which object to spray on? How can I get this object or object queue?


    emergency ,help
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    If you paint with P3dPaintDecal for example, you can see on line 184 it calls: P3dPainter.Decal.SubmitAll(...);

    Inside P3dPainter_Decal.cs line 157, you can see the SubmitAll method, which finds all paintables using P3dPaintable.FindOverlap(...), and loops through and paints them all. So you can just add your code to that loop, or filter the list beforehand.
     
  22. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33
    Hi Darkcoder,
    can it be used to activate/deactivate pre-made Decals on a car?

    Br, Alen
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    To do this you must maintain a list of decal information (e.g. texture, position, size), and each time you modify an old decal you revert the car texture to its original state, then paint all the remaining decals again.

    Inside P3dPaintDecal you can see the HandleHit method on line 164. You could add some extra code in here that stores the past arguments (and possibly the current decal state if you modify it) when preview = false.
     
  24. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33
    thanks!
     
    Darkcoder likes this.
  25. LuckyHamster

    LuckyHamster

    Joined:
    Oct 28, 2014
    Posts:
    50
    Hi, I just updated to the recent Paint in 3D and now I am getting this error:
    Assets/Paint in 3D/Scripts/P3dMeshAnalysis.cs(8,41): error CS0246: The type or namespace name `P3dEditorWindow' could not be found. Are you missing an assembly reference?
    Assets/Paint in 3D/Scripts/P3dMeshAnalysis.cs(86,27): error CS0115: `PaintIn3D.P3dMeshAnalysis.OnInspector()' is marked as an override but no suitable method found to override

    I see the script P3dEditorWindow but for some reason it is not being detected by P3dMeshAnalysis on Visual Studio.

    I am using unity 2018.2.7f1
     
    Last edited: Sep 21, 2018
  26. LuckyHamster

    LuckyHamster

    Joined:
    Oct 28, 2014
    Posts:
    50
    Ok, I removed paint in 3d and reimported it. Looks like the problem had something to do with all the changes including not having P3D_Paintable anymore.
     
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Yes, version 1.5.0 was a complete rewrite, including new class names. The change log mentions "WARNING: If you're updating from an old version (before 1.5.0) this update will break all painting features in your scenes. I recommend you only upgrade for new projects.". I forgot to mention you must delete the old "Paint in 3D" folder to upgrade though.
     
  28. Malzadore

    Malzadore

    Joined:
    Feb 13, 2017
    Posts:
    4
    Hi, this asset tool looks great! I am looking into using it possibly, just a couple questions:
    • Does this use the existing texture that the mesh is using? Or can it use it's own?
    • What is the performance like? Can it handle painting multiple at once in the same frame?
    • Can you erase decals you previously painted?
    • I love that you can keep count of decals, will the count be accurate if you remove decals if that is possible?
    Thanks!
     
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    1 - It uses at least one texture slot in your object's renderer. If there's already a texture there then it will duplicate it, if there's no texture there then it will create it.

    2 - The performance is very good, even across multiple objects. It only slows down when you paint many many times per frame, which can happen when you paint thin lines that follow the mouse/finger, because making it a solid line requires you to reduce the paint interval a lot. This is only a concern on mobile devices though, where you can increase the line thickness and thus increase the painting interval. If you're only concerned with decals then there's no performance concern.

    3 - As I mentioned in a previous reply, you must keep track of the decals yourself if you want to be able to modify or delete them. By default, all Paint in 3D does is handle updating the texture based on your paint requests, which allows for consistent runtime performance and memory usage.

    4 - The pixel counters are updated every time you modify a texture, so yes, they would be accurate.
     
  30. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Darkcoder,

    I just upgraded to version 1.5.8 and something odd started happening as I was testing the new Multiply blend mode. I'm using P3dPaintDecal on my weapon and P3d Material Cloner, P3d Paintable Texture and P3d Paintable on my character to be painted.

    When my weapon collides with my character, on about every 5th or 6th collision, instead of a single texture being applied, about 20 - 30 textures are applied spread across the entire character. It only seems to happen when I have Multiply selected as a blend mode.

    Thanks
    Allan
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Interesting, are you sure it doesn't happen with the other blend modes? This kind of issue could happen if your model has overlapping UV data (e.g. one stray triangle overlaps many other areas), or if your decal painting depth is set quite hit and your collision hits a strange area.

    Could you click 'Analyze Mesh' on your P3dPaintable and send a picture of the window? (assuming you're painting UV0, if not select UV1 first)
     
  32. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    It only started happening with this latest update and when I select Multiply as blend mode. All other blend modes work fine... the same as they did before. Just so you know, I'm only using this in runtime. What does the Depth setting do? The docs only repeat what the tooltip says and that doesn't say anything useful. Depth: "The depth of the decal painting" That's like saying, "This controls depth". That doesn't mean anything to me. How does a 2d texture have depth? Changing it from the default 10 to 1 or 1000 makes no difference as far as I can tell.

    Here are a few screen shots.
    Analyze Mesh of my Brute character that I am painting in runtime. The UV map goes all red with I am in play mode. I don't know if that means anything.
    BruteAnalyzeMesh.PNG

    Numerous hits with AlphaBlend, works beautifully along with all other blend modes except multiply.
    BruteAlphaBlendHits.PNG

    A single hit with confirmed single collision in Multiply mode
    BruteOneHitMultiply.PNG

    Finally, here are my P3d Paint Decal settings
    p3dPaintDecal.PNG

    Thanks for the help.
    Allan
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Thanks, there must be a bug in the painting code for the Multiply blending mode. I'll send you a new build as soon as I fix it.

    Decals are flat 2D textures, so to paint 3D objects with them they need to be given a depth so the system knows how far front/back from the paint point you want the decal to apply to. If you're painting flat surfaces then this can be very low, but for bumpy and complex objects you would want to use a higher value. I'll make the documentation better for this.
     
  34. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Sounds good. Glad I could help.

    Regarding Depth, that makes complete sense. It's the elevation of applied texture above the mesh surface. Higher value for rough surfaces, lower value for flat surfaces. Yes a quick update to the docs would be great.

    Thanks
    Allan
     
    Last edited: Oct 4, 2018
  35. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Can you explain the purpose and use of State Limit in P3d Paintable Texture. I couldn't find anything in the docs and none of the demos use it.

    I'm wondering if this is a feature to be able to reverse painting changes. It would be cool to have characters reverse their visual damage as they heal. I realize I could always just replace the altered cloned material with the original but State Limit sounds like it may an attempt to have a progression of reversing the changes.

    Thanks
     
  36. wechat_os_Qy027eTD2CBrbJxQkaBLaDkMM

    wechat_os_Qy027eTD2CBrbJxQkaBLaDkMM

    Joined:
    Aug 21, 2018
    Posts:
    1
    Hi Darkcoder,
    I came across a problem with spary paint in 1.5.6. When I replace Spaceship with cylinder,I paint on side of cylinder but the symmetrical side is also painted automatically. How can I only paint the side which the spray face to?
     

    Attached Files:

    • 2.png
      2.png
      File size:
      79 KB
      Views:
      780
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    States allow you to perform undo and redo operations, where the State Limit is the maximum amount of undo/redo states. I only just added this feature to the code and haven't had time to make a demo scene or documentation for it yet. You can currently test it via the context menu options, where you must call "Store State" before performing each painting batch, and then you can "Undo" and "Redo" within your State Limit. The C# API for this is exactly the same, but currently none of the painting components call "Store State" before painting which they need to, so it's not fully ready yet.


    To fix this you must edit the UV data so no parts overlap.

    If you want to keep your UV data, or you don't know how to UV map, then the "UV Data Requirements.pdf" can help you with various steps to fix it.
     
  38. faisal_tekfirst

    faisal_tekfirst

    Joined:
    Feb 21, 2017
    Posts:
    7
    Hi, is there any way we could find how much of the area is painted so far on the object we are painting?
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    The 'Pixel Counter' demo scene shows you how to count the amount of painted pixels in the R/G/B/A channels. If you're painting on an existing texture then this probably won't be useful to you, so you can either modify 'P3dPixelCounter.cs' to calculate the difference between the original and current pixels, or paint your object using a second material layer that's transparent, and then you can count the pixel alpha using P3dPixelCounter.
     
  40. marcipw

    marcipw

    Joined:
    Apr 18, 2013
    Posts:
    239
    Just dropping by again to say a massive Thank You! The latest updates have been awesome! You rock and I just gave you a (long overdue) 5 star review on the asset store.
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    Thanks! The next few updates will hopefully be even more amazing :)
     
    marcipw likes this.
  42. marcipw

    marcipw

    Joined:
    Apr 18, 2013
    Posts:
    239
    Is there such a thing as too awesome?!! I am excited!
     
    Darkcoder likes this.
  43. marcipw

    marcipw

    Joined:
    Apr 18, 2013
    Posts:
    239
    What is the best way to get Undo and Redo up and running at runtime?
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    The best way is to wait for the next version where I make a demo scene for it. The second best way is to read THIS post.
     
    marcipw likes this.
  45. marcipw

    marcipw

    Joined:
    Apr 18, 2013
    Posts:
    239
    Great! Thank you. :)
     
  46. marcipw

    marcipw

    Joined:
    Apr 18, 2013
    Posts:
    239
    What about a colour picker? Even a colour wheel type thing could be cool to see in a demo.
     
  47. Malzadore

    Malzadore

    Joined:
    Feb 13, 2017
    Posts:
    4
    Got your asset and have been loving how much time it has saved me from having to do this from scratch, thanks! I just ran into one thing, I have been using uv2 for the paintable shader, which works great! The problem is when I use the Fix Seams script, it seems to only change uv1. It is possible to have this configurable in the future? Thanks!
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    You can change colors and brushes using the P3dIsolateChild component as seen in most of the example scenes, a color picker is outside of the scope of the asset though.


    I sent you a private message with a new build that should fix this. This will be included in the next version when I can test it more.
     
    marcipw likes this.
  49. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    Could you explain in more detail what the Fix Seams tool is doing? Is it something I could do in my 3d program instead?
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,400
    It's extruding the UV island borders of your mesh. I've never heard of this feature being part of a 3D modelling program though, so maybe it's not possible. If you're asking because you frequently update your mesh then I recommend you develop without fixed seams, and only fix them when the mesh is more or less finalized.