Search Unity

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,412
    Yes, this can be done by setting the texture of your canvas to be of the final painted picture. You can then make it invisible by changing the P3dPaintableTexture component's Color setting to 1,1,1,0 (transparent white). You can then 'reveal' the picture by painting using a brush that uses the Additive blending mode, with a color of 0,0,0,1 (only paints opacity). Something similar is demonstrated in the "Reveal Original" demo scene :)
     
    karonte likes this.
  2. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    Hello. Does anybody know if this works in LWRP? (in editor)
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    All features should work in LWRP/URP and HDRP. The only issues may be if you mix and match Linear and Gamma textures.

    I'm currently working on a big update to the in-editor painting painting features, so I'll be sure to test all of this again. I will be posting some updates to this very soon :)
     
  4. Blue-Wolf

    Blue-Wolf

    Joined:
    May 27, 2014
    Posts:
    20
    Hello,

    I bought this add-on yesterday primarily for the decal ability without fully understanding the implementation. My hope was that I would be able to add lots of variety to my models via decals to make the world look more unique, which this can do, however it seems that this can only be done by duplicating additional material/texture for an object? I was hoping that I wouldn't need to create new materials for this process as it could quickly get out of hand. Am I correct in my understanding of how this works? Thanks in advance!
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Yes, this is a texture painting asset. If every paintable object shared the same material then painting one would paint them all. If all these objects were UV mapped to separate areas and shared the same material then you could still use one material & texture set though. You could also keep the base material untouched and instead paint on a secondary layer that is unique to each object. The main advantage of this approach is that you can paint your objects as many times as you like with no performance degradation, and the main disadvantage is that it requires more texture memory. If you use the secondary layer approach then you can use a lower resolution paint texture though, and then still make it look good with a detail map.
     
  6. Blue-Wolf

    Blue-Wolf

    Joined:
    May 27, 2014
    Posts:
    20
    Thanks for the prompt reply. I'm not quite sure what you mean by secondary layer? A secondary map?
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Either seconday map (e.g. custom multi-layer shader), or a second transparent material on the same renderer.

    For example: if your base material is very high detail then making it paintable will be expensive due to a high texture resolution, and reducing the resolution of that paintable texture will make it look bad, so you could instead paint on top of it with a lower resolution texture and apply some kind of detail map to make it still look high resolution.
     
  8. Darkcoder

    Darkcoder

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

    I think the current in-editor painting implementation is too difficult to use, and it lacks some important features. So...


    I decided to rewrite it from scratch, and this is a screenshot of what it looks like so far!

    The main goal of this new version is to be as easy to use as possible, while still having a full feature set. As you can see, this now features a layering system, as well as a material system. This material system is really easy to set up and use, and it supports full PBR texturing. You just pick your material, and paint it to the object. Setting up your object is now just one click, and your scene objects are no longer touched (non destructive).

    I have plans to add other cool features missing from the original, like: painting lines, clicking to paint triangles, automatic edge painting (e.g. scratched edges), and much more. The first release will be simple though, and will just replace the existing in-editor painting tool.

    Stay tuned!
     
  9. adrienmaroisysocorp

    adrienmaroisysocorp

    Joined:
    Nov 18, 2019
    Posts:
    2
    Hello,

    I have buy this assets, and I am trying to apply decal over cars model (like bullets holes), but when I draw them on a side of the model they also appear on the other side of the model (because the texture of the mesh seems to only contain one side of the hood for example on which both side of the mesh get mapped). So do you have any advice, on how I can fix this issue ?

    Thanks in advance.
     
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    To fix this you must either:

    a) Change your UV map so both sides use different areas of the UV.
    b) Split your mesh into two (left & right), then both sides will have their own textures that won't interfere.
     
  11. adrienmaroisysocorp

    adrienmaroisysocorp

    Joined:
    Nov 18, 2019
    Posts:
    2
    Thanks for the answer, I will try this.
     
  12. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Some feedback on the new version screenshot.

    The red and green colors take a lot of attention.

    I would keep all the buttons a shade of gray, and any highlights blue consistent with the unity interface.
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks for the feedback, I agree that the coloring is too loud. I've already improved the brush highlight to be easier on the eyes. I'll post another update hopefully tomorrow :)
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Here's an update to the new in-editor painting feature:


    As you can see, the colors are easier on the eyes now, and I also moved the delete/remove buttons to the corner to clean it up.
     
    Lars-Steenhoff likes this.
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Yes looks much cleaner!
     
    Darkcoder likes this.
  16. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    And I don't remember if you already added pressure support for wacom tablets?

    Would you be willing to see if that can be added, for example the alpha of the brush could be controlled by pressure
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The mouse pressure is used, but I don't have any tablets to test on, so I have no idea if it works with one.
     
  18. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    874
    How goes the fixes on normal map decals across seams?

    You can also make a custom shader to support 2 UV maps, one with the base texture and one for painting.

    That what i plan to do to paint some effects on my hair model.
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    This will most likely be in the next version, which is almost complete. However, I'm about to go on holiday, so it will have to wait until next year. This next version will contain many cool features to make the wait worth it :)
     
    sacb0y and Lars-Steenhoff like this.
  20. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    I have a Mac and a Wacom tablet but the pressure does not seem to be used
     
  21. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    874
    Also how do I clear/reset a surface? A bit confused on that...

    EDIT: I've tried many things and followed the example but for some reason the paint is not coming off the texture.

    EDIT 2: actually i got it working by reapplying the paintable texture component, but now i can reset the paints to "_MainTex" but not my specgloss map.

    It seems to only do one and not the other.
     
    Last edited: Dec 20, 2019
  22. toyhunter

    toyhunter

    Joined:
    Mar 5, 2018
    Posts:
    76
    @Darkcoder I'm going to buy this for my game with a weapon working like Splatoon 2, please confirm if your asset can do something like in Splatoon that in game spraying color painting on any mesh inside the game, and this can be undone in runtime too, thanks
     
    Last edited: Dec 24, 2019
  23. talharing

    talharing

    Joined:
    Oct 27, 2013
    Posts:
    14
    Hi!

    What's the best way to make this asset work with probuilder meshes?

    Thx,
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Hey everyone, I'm back from my holiday. Things are still going to be busy for the next week though!

    That's unfortunate! In the future I'll have to implement something that overrides the pressure with the actual pressure. For now though, I need to finish off the new core painting features.


    Can you upload a video or screenshots showing your P3d components and settings used?


    Yes, you will have to combine several demo scenes and specially optimize your meshes and use some custom shaders to achieve something that works exactly like Splatoon though. The painting/erasing itself can be done quite easy though.


    Make your ProBuilder mesh, then generate lightmap UV data for it, and paint using the lightmap UVs. You can see the "Paint Ball Throwing" demo scene and click 'Analyze Mesh' on the Map to see what the UV1/2 (lightmap) should look like.
     
  25. toyhunter

    toyhunter

    Joined:
    Mar 5, 2018
    Posts:
    76
    @Darkcoder

    Thanks for your reply, would you mind sharing more about "specially optimize your meshes"? Thanks
     
  26. dannyoakley

    dannyoakley

    Joined:
    Jun 18, 2016
    Posts:
    11
    @Darkcoder
    I have a feature in a VR project where the user can place a decal on an object using the tracked controller. I would like to not rotate the decal, but it seams as if the rotation of the decal is based on my headset camera. If I bank my head, the decal rotates. Is there a way to lock the rotation of the decal independent of the headset camera? The striped rectangle in the images below is the decal.
    headset_straight.png headset_Tilted.png
     
    Last edited: Jan 2, 2020
  27. francoiscoiscois

    francoiscoiscois

    Joined:
    Oct 23, 2019
    Posts:
    38
    Hi everyone, best wishes for this new year !

    I am starting planing for my next project, which will use paintin3D.
    I am wondering if you worked on thoses features already (drag and drop decals and move rotate scale), as I will need it for this project ?

    Thank you.
     
  28. tatakaeotaking9000

    tatakaeotaking9000

    Joined:
    Jan 3, 2017
    Posts:
    10
    Hello. I was following this tutorial on your site, but stuck at Step 3.
    upload_2020-1-7_14-2-26.png
    For some reason i cant choose UV1 channel in Paintable Texture script. What should i do then? upload_2020-1-7_14-1-35.png
     
    Pouic likes this.
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Splatoon is designed for consoles, and it allows you to paint a fairly large map hundreds of times a second, so you must optimize your meshes well. Specifically, you must make sure the paintable UV map area has no wasted space, like it doesn't need any UV underneath the map or between solid objects. You must also keep in mind that painting performance depends on the resolution of the painted texture, which you should reduce to the lowest possible size you can get away with. To cut this down even more you should slice your map up into logical 'areas', so you're always manipulating a minimum amount of pixels.

    One of the key optimizations Splatoon does is that the painting is very low resolution, and it only looks sharp and high resolution through the use of cut-out style blending (using one team color per texture channel), and augmenting this with well designed detail maps. For example, if you attempt to paint the splat shapes using a high detail splat shape on your original map texture resolution then your game will quickly slow to a crawl, because you'll be painting millions of pixels per hit to get the splat to look good.


    The decal paint angle is based on the Orientation setting in most components. For example, P3dHitBetween.Orientation. If this angle is changing based on the headset bank, then it sounds like this is set to CameraUp? The default is WorldUp though, which should work as you desire.


    Not yet, this may have to wait until the next-next version. The next version is almost ready for release, and it already includes a ton of really nice features. I'll add this as soon as possible!


    I meant UV2. In the next version I've renamed the UV channels to hopefully reduce this confusion!
     
    francoiscoiscois and toyhunter like this.
  30. Darkcoder

    Darkcoder

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

    I've made some really good progress with the new in-editor painting feature. Here's a sneak peak of what it looks like now:


    I ditched the earlier idea of using multiple windows, because it quickly made the interface look cluttered, and harder to use.

    The in-game painting features now include live decals, which can be moved around and have their order changed, etc.

    I think I've added enough new features now, so I'll try and submit this version today :)
     
    johaswe and francoiscoiscois like this.
  31. argonauta

    argonauta

    Joined:
    Nov 24, 2014
    Posts:
    2
    is there a way to paint an object white, actual white? seems like any blending mode just removes the color and shows the original material
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If you paint white with Alpha Blend then that will paint actual white. However, if you use a material with lighting then 'white' areas may appear different.

    If you want to force the painted area to draw as fully white and ignore all lighting, then you must either paint the illumination map white too, or paint to a secondary unlit (possibly cutout) material later that sits on top of your lit base material.
     
    argonauta likes this.
  33. Darkcoder

    Darkcoder

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

    Version 1.7.8 of Paint in 3D is out now!

    This includes the completely new in-editor painting features. These features will be expanded upon soon :)

    This version also includes many changes to the in-game painting features to make them simpler to use and a bit more flexible. For example, the painting groups mask feature was replaced by just picking one group, as I don't think the mask was too useful. I also made it so you can use more or less unlimited groups, and give them custom names rather than just using a 0..31 index. I also added in live decal (movable) decals, and made improvements to many of the demo scenes.

    Any and all feedback is welcome. Enjoy!
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It's hard to see what's happening in your screenshots. Does this extremely big painting issue happen when you paint the body first, or only when you paint the head? Does the body contain any overlapping UV areas?

    Perhaps a video of you painting with a simpler decal texture would make it easier to see what's happening.
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I sent you a private message with a fix for the gradually fading mip map texture, thanks for pointing it out!

    [Edit] regarding performance, P3dGraduallyFade will constantly activate, even if there is nothing left to fade. This is because this component has no knowledge of the texture data that is being painted, so it's not possible to optimize like this. You can increase the Threshold setting to make it activate less frequently though.

    The easiest way to test for overlapping UV is to open your mesh in a 3D modelling program and check the UV. I should add this feature to the P3dMeshAnalysis tool to make it easier though. It's probably not the cause of your issue though, so you don't have to worry about it yet.

    I will test painting a skinned mesh with two materials later today and see if I encounter any issues.
     
    Last edited: Jan 14, 2020
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You probably want to use the "Replace Original" blending mode, which will return it to its original state.

    Regarding multiple skinned materials, I tried it and noticed no issues:



    As you can see, both sides of the skinned and animating cylinder have different materials, and I can paint across both without seams or any change in size.
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I sent you a private message with a new version that should fix this!

    Sure, you can send it via private message or to my email (in documentation).
     
  38. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    46
    Hello!
    Is there a way to share a RenderTexture between several P3DPaintableTextures?
    I have a level of 8 large objects with all uvs tightly packed into one atlas. Each object has its own material, but shares the same decal texture. If I use Paint in 3D as intended - I'll end up with 8 RenderTextures coloring different pieces of a single atlas. Is there a hacky way to provide a single RenderTexture for all my 8 objects? :)

    If I modify Activate() method of P3DPaintableTexture and provide my own RenderTexture from other P3DPaintableTexture, Unity just crashes when I try to paint.
     
    Last edited: Jan 18, 2020
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can put the P3dPaintable+P3dMaterialCloner+P3dPaintableTexture components on one of your GameObjects, and put the P3dModel component on your 7 others. Then set all 7 P3dModel.Paintable settings to your first one. Then drag + drop the 7 other GameObjects into the P3dPaintable.OtherRenderers list in the first, and it should work. I should really make a demo scene showing how to do this!
     
  40. Leeong

    Leeong

    Joined:
    Sep 10, 2018
    Posts:
    11
    @Darkcoder
    Hi!
    I have a few questions about "40 Live Decal".
    1, how to add decals at runtime, can I add decals by hit points?
    2, when moving the decal, can I automatically rotate based on a certain normal, like "P3dHitScreen.NormalType".
    3, how to save and load.
     
  41. francoiscoiscois

    francoiscoiscois

    Joined:
    Oct 23, 2019
    Posts:
    38
    Hi Darkcoder,

    I have a few question concerning using Paintin3D for a kids game I am doing.
    -Is it possible to paint to remove a texture, like when a windows is dirty and you clean it with a brush (instead of painting color)
    -Is it possible to know when a suface is fully painted or almost, and get an event.
    -Not beeing a programmer I use playmaker to create all my game logic. Playmaker can recieve and send event and variables,
    How would you recommend to communicate with paint in 3D.
    Like I want on touch to trigger a spray paint with particle... Using playmaker when I touch the spraycan I can trigger something and detect the touch position. Would like to trigger paintin3D particle paint
    Then when the surface of the object I paint on is fully covert or almost, I want to get an event so I can with playmaker create a win state, stop painting and so on.

    Hope it is not too complicate to achieve,
    regards
     
  42. songpwc

    songpwc

    Joined:
    Nov 6, 2018
    Posts:
    14
    @Darkcoder
    i have a question about performance.
    we need to clone our material for each gameobject. will this affect Unity's "Draw call batching", because unity can only batch gameobject sharing same material.
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    1 - You can instantiate/clone the Live Decal GameObjects. This could be done with P3dHitScreen + P3dSpawner, but it wasn't really designed for this scenario.

    2 - The live decals currently must be moved manually in the editor with the default transform tools, and they have no knowledge of what they're being placed on, so no.

    3 - Either by manually save/loading them yourself, or using some kind of asset that can save scene objects.

    Making a fully featured in-game live decal editor as you're basically describing here is a lot of work, as is mostly out of the scope of what I planned to make for this asset, which is why you don't see any example like this. Most of this selection and movement functionality can be implemented using my other Lean Touch+ asset, and I imagine an asset like Easy Save would be able to handle the save/load of the live decal prefabs. Maybe in a future version I will expand on these features, but for now there are many more important things I want to focus on.


    1 - Yes, on the specified P3dPaintableTexture component you can call the Clear(texture, color) method (e.g. Clear(null, Color.clear)) to reset the whole texture to a specific state.

    2 - The Paint Percentage demo scene shows you how to display the % of a P3dPaintableTexture you have painted. This value can be read from a script to perform an action, but there is currently no event built into these components to do this. Perhaps PlayMaker can read component values?

    3 - Particle painting can be enabled/disabled using the ParticleSystem component's Play and Stop methods, which you can access from PlayMaker maybe? This is how the VR HVLP demo scene works to enable spray painting.
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If you want each object to have its own unique paint then yes you must break batching, as they require unique materials.
     
  45. vorokoi

    vorokoi

    Joined:
    Oct 18, 2019
    Posts:
    39
    Been playing around with P3D and really enjoying it. Brilliant stuff!

    Can you elaborate on the cut-out style blending? I've been trying different decals/textures/hardness/blur and resolutions of paintable surfaces, but haven't been able to nail the fluidity and sharpness of the paint.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Cut out transparency is where you output the alpha as:

    Code (CSharp):
    1. alpha = alpha > 0.5;
    This causes the output to either be solid or opaque, with no gradation, also called thresholding. This is similar to how SDF texture fonts work, and it allows you to not only have solid edges to the transparency, but have edges that can curve around very gradually. If you take this same principal but apply it to all 4 texture channels separately, then you can construct an image that has 4 separate (team) layers that are independent of one another, and can form their own isolated smoothed out regions. Instead of using Red, Green, Blue, and Alpha as the output, you can replace these channels with any (team) color you like. To make it look like Splatoon and look more like paint you can then mix in some kind of ink detail texture before you perform the thresholding. You can then apply a normal map, and even deform the normal map based on the underlying team channel value (gradient) to make it look like it has some thickness.
     
    vorokoi likes this.
  47. vorokoi

    vorokoi

    Joined:
    Oct 18, 2019
    Posts:
    39
    Gotcha. Your insight is much appreciated. Cheers
     
    Darkcoder likes this.
  48. francoiscoiscois

    francoiscoiscois

    Joined:
    Oct 23, 2019
    Posts:
    38
    Thank you for your quick response, I didn't know you already had implemented such feature like Paint Percentage and Paintable Texture, that is awesome!
    Looks like it will be easy to integrate it with playmaker too.
    I will send a message when I successfully integrate it with playmaker to say how it was achieved.
    Regards.
     
    Darkcoder likes this.
  49. Darkcoder

    Darkcoder

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

    Here's a sneak peak of what to expect in the next version:



    The Mesh Analysis tool now shows you which areas of the UV space are filled, and which overlap, as well as a % of both. Also:



    I've added a new painting mode called P3dPaintThrough. This works like P3dPaintBetween, except instead of painting the first point that gets hit between the two specified points, it paints all surfaces between the two. This can be used to make effects like really powerful lasers, light sabers, etc!

    Stay tuned :)
     
  50. Rheet3

    Rheet3

    Joined:
    Jan 21, 2020
    Posts:
    1
    Hey how would I go about fixing white artifacts that come up along the seams of a model while trying to paint it?