Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Paint In 3D ️️✏️ In Game & In Editor & Skinned Mesh Painting

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

  1. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Hello, I have some p3D Hit between objects in my scene, each of them adds 2 batches. Is it possible to enable gpu instancing for them?
     
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Painting requires rendering the paint, which cannot be instanced since each paint operation requires a lot of entirely unique settings, and even if it were instanced there would be no benefit.
     
    alms94 likes this.
  3. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Ok, Thanks for the quick reply
     
  4. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    I have one more question. I'm generating a mesh at runtime. I tried to add needed components to make object paintable at runtime and also try to add these components to its prefab. I have box collider component on my object. But still cant paint this object. I cant paint other objects in my scene but can't paint this one. I attached my meshes analysis.
     

    Attached Files:

    • 2.png
      2.png
      File size:
      16.6 KB
      Views:
      250
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    As analysis shows, this mesh has no UV data so it cannot be painted. Your mesh generation code must also generate the UV data so that there are no overlapping or tiling (outside 0..1 range) coords.
     
  6. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    Awesome!

    I tested it out and it looks great but I have one issue: when I paint it overlaps on some places. Here's a video



    As you can see when my brush touches a previous spot it paints on top of it.
    Is there any option to change this?

    Thanks!
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    No, removing overlap there would be very performance intensive.

    If you need this feature then you should use an additional paint layer (e.g. separate material, or custom shader), paint with full opacity, and then make that layer semi-transparent.
     
  8. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Hello again, I'm using p3d Hit particles component for painting. I have a big cube and on top of it I have a small cube. When I try to paint I'm first painting small cube than particles go underneath the small cube and paints the big cubes surface. I want to paint the first thing that collides with particle. How can I do that? If you can help, I will be very glad.
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    All paint is applied in 3D (unless you use UV space painting), so any paintable surfaces in range will receive paint. You can override this using layers or paint groups. However, in your scenario you probably just want to change the shape of the paint so it doesn't hit your other surface. For example the P3dPaintSphere and P3dPaintDecal components have the Scale setting, where you can set the Z value to something small like 0.1. P3dHitParticles rotates the paint to face the hit normal, so the Z axis should always point in the same direction as the hit normal.
     
  10. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Again thanks for the quick reply, Is there a way to mix two colors correctly? I looked to the demo scenes but couldn't find.
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    What do you mean 'correctly'? Subtractive color blending? Paint in 3D currently only implements RGB additive color blending. I can look into a new blending mode for the next version though.
     
  12. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Like I have blue in my scene than when I paint the object with yellow, I want to see green. Is it possible?
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Currently no, because all painting uses additive RGB color like Photoshop. See HERE for more information. To make colors mix like this I would need to implement subtractive color, which I think could be done with a new blending mode that converts the RGB color space before and after blending. I will have much more time in about 2 weeks to look into this feature and others.
     
  14. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Thanks, hope there is a color mixing feature in future verison. That will be very fun to work with.
     
    Darkcoder likes this.
  15. JohannUlbrich

    JohannUlbrich

    Joined:
    Feb 15, 2019
    Posts:
    6
    Thanks for this great asset.

    I have a problem with slicing meshes. During slicing I clone the current GameObject (
    Instantiate(currentGameObject)
    ) and add a part of the previous mesh to the clone. After cloning, they share the same texture. If I then destroy one of game objects, the shared texture for both objects gets destroyed.

    What is the best way to copy a texture and attach it to the new game object?
    I tried it like this, to apply a copy of this texture to the new Paintable but it does not work:
    texture.Texture = texture.GetReadableCopy();


    And is there a way, to disable the Paintable but keep it's painted texture?
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    The main paintable components currently don't support being cloned. I will look into this for a future version, it's a little tricky with undo/redo and other features.

    The current way to do this is to call Deactivate() on the P3dPaintable component, clone it, and then call Activate() on both clones. This will of course lose the current paint state, so you will want to copy the original P3dPaintableTexture component's Current texture to a temporary RenderTexture (e.g. using Graphics.Blit), and then after write it back by calling Replace(yourTempRT, Color.white) on both.
     
  17. Wilburampton

    Wilburampton

    Joined:
    Feb 17, 2022
    Posts:
    2
    Thanks!
     
    Darkcoder likes this.
  18. JohannUlbrich

    JohannUlbrich

    Joined:
    Feb 15, 2019
    Posts:
    6
    I will try this out. Thank you very much!
    It would be really great if you could implement this feature in a future version. Even without undo/redo. Or just a "bake texture" feature.
     
  19. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Hello, I'm using p3d Read Color Component to read colors. It's working like expected in pc but in IOS it reads every color as RGBA(1,1,1,1). How can I solve that?
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    I've added it to the to-do list HERE, I'll try and get to it soon.


    Does this issue exist in the example "69 Read Color" scene as well, or only your scene?

    Also, what exact iOS device and Unity version do you experience the issue with?
     
    JohannUlbrich likes this.
  21. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    I will try with "69 Read Color" scene and get back to you soon. I'm using Iphone 12 and for Unity I'm using 2020.3.15f2
     
    Darkcoder likes this.
  22. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    I tried the "69 Read Color" scene on iphone and it doesn't working correctly. When I click red it shows cyan or when I click green it shows purple. It's not working like expected.
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    It sounds like it's reading the texture upsidedown, I'll see what I can do in a few days.
     
  24. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Ok, thanks for your help. Hope the solution will be easy for you
     
    Darkcoder likes this.
  25. JohannUlbrich

    JohannUlbrich

    Joined:
    Feb 15, 2019
    Posts:
    6
    Many thanks for your help. This worked for me.
     
    Darkcoder likes this.
  26. nantoaqui

    nantoaqui

    Joined:
    Oct 1, 2014
    Posts:
    40
    Hello!

    How do you integrate Paint in 3D with Synty low poly models?

    I tried to use "Unsuitable UV" example as starting point but no success. What i did was to copy the scripts and materials from the horse onto the character. Any tips?

    Thanks :)
     

    Attached Files:

  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    This demo scene shows you want happens when you paint a mesh with unsuitable UV. The demo scenes after this show you how to fix this.
     
  28. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    hello again, did you find any solution for this?
     
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Not yet, it's only been a couple days :)
     
  30. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17
    Yes, I know. I'm just excited for the game :)
     
    Darkcoder likes this.
  31. nantoaqui

    nantoaqui

    Joined:
    Oct 1, 2014
    Posts:
    40
    Hello!

    The problem is that synty models doesn't get painted at all :(
    I found this thread on Synty Studios' discord:

    "You can also generate lightmap UVs, which are all unwrapped, but not neatly. And potentially tell Paint in 3d to use that UV set instead of the default ones. That could work too."

    https://discord.com/channels/502587764299006004/504459896662655003/928858963775225856

    I'm using this free asset provided by them:
    https://assetstore.unity.com/packages/3d/props/polygon-starter-pack-low-poly-3d-art-by-synty-156819
     
  32. nantoaqui

    nantoaqui

    Joined:
    Oct 1, 2014
    Posts:
    40
    Darkcoder likes this.
  33. Darkcoder

    Darkcoder

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

    Version 2.0.1 of Paint in 3D is now out!
    • Removed global shader keywords.
    • Fixed P3dChannelCounter component setting changes not being reflected.
    • Fixed P3dChangeCounter component setting changes not being reflected.
    • Fixed P3dColorCounter component setting changes not being reflected.
    • Every P3dColorCounter now updates when a P3dColor is enabled or disabled.
    • Fixed P3dReadColor reading incorrect UV location on the Metal graphics API.
    • Changed Solid shader's Tiling setting to be a vector.
    • Changed Alpha shader's Tiling setting to be a vector.

    Enjoy :)

    This should now be fixed. Apparently SystemInfo.graphicsUVStartsAtTop returns the wrong value for the Metal API... yay.
     
    alms94 and GreaterHawkeye like this.
  34. alms94

    alms94

    Joined:
    Jun 3, 2020
    Posts:
    17

    Thanks for the quick solution and thanks for this amazing asset
     
    Darkcoder likes this.
  35. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    Hi @Darkcoder!

    Do you know how to fix this behaviour?

    upload_2022-3-25_10-24-31.png

    I'm referring to the fact that when I make a stroke with low opacity you can see the circle appears. I'm pretty sure it's not related to the brush in itself because I tried with the "dot" decal provided and it does the same.

    Thanks :)
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Can you post your P3dPaintDecal component settings so I can try to replicate this?
     
  37. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    There you go
    upload_2022-3-25_12-26-56.png

    And also the decal settings:

    upload_2022-3-25_12-27-39.png
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    I think the issue is because you've set the shape in both the Texture and Shape slots. If you only set it the Shape and leave Texture as Null/None (white), then it seems to work:

    upload_2022-3-26_10-16-43.png upload_2022-3-26_10-16-56.png

    I think this is because the overlap clipping code doesn't check the Texture (to slightly improve performance). Only the Shape, Color.a, and Opacity settings are calculated.
     
  39. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    Hello,

    I have been using Paint in 3D in my game to enable the player to paint vehicles and buildings, and it works really well.

    I am writing to ask if it could be used for something else in my game. I need to place markings on a Unity terrain, to show the player where they can place buildings. The player will be able to mark out an area using the mouse, where buildings can appear, and I would like to show this zone on the terrain. At the moment I am using a projector, but I am not very happy with the results.

    Would it be possible to use Paint in 3D to mark out the selected area of terrain using decals? The terrain is divided up into a grid, so the decals would have to appear on the map in the middle of the grid squares when this game mode was activated, and then disappear again when another game system was selected. There could be a hundred or more needed on-screen at any time, when the building mode was activated.

    I am going for a similar look to the zones used in a city building game called Cities: Skylines. Here is a screenshot of how they display their building zones:



    Any suggestions of how something similar could be achieved using Paint in 3D would be greatly appreciated.

    Thank you.
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Paint in 3D cannot paint terrains, only normal meshes or skinned meshes. Even if it could, this is a texture painting asset, so your terrain would either have to be tiny or have an incredibly high resolution texture for you to be able to paint decals with any kind of detail. When you 'paint' a terrain you typically only paint a splat map, which is basically a very low resolution texture (e.g. 1 pixel per meter), and then each pixel gets replaced with a high resolution tiling texture depending on which colors you paint. To place high resolution decals at specific locations on your terrain you're best off using a traditional decal or projector system.

    There is one hybrid approach you could use where you paint the aforementioned low resolution splat map, except instead of just painting the texture ID to each pixel, you would paint the decal ID and decal XZ offset to the splat RGB. This would allow you to paint one decal per splat map pixel/cell with almost no overhead. However, this would require you to write a fairly advanced custom shader.
     
  41. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    Thank you for the info - appreciate your advice. I will look into your hybrid approach suggestion, and see if I can create something with shader graph.
     
    Darkcoder likes this.
  42. Darkcoder

    Darkcoder

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

    Version 2.0.2 of Paint in 3D is now out!
    • Fixed connected hit painting on touch screen devices.
    • Added Dynamic Mask demo scene.
    Enjoy :)
     
  43. LaniusXR

    LaniusXR

    Joined:
    Jan 12, 2022
    Posts:
    2
    Hello,

    Im currently making a car painting simulator using Paint in 3D and i Love it.

    But i got some problem, there's 2 step painting the car, first paint using white paint, and on the next step using other colors. Im using counter to get percentage of how much the car is painted.

    but how do i reset the counter when im on the second step? so like after i paint using the white paint the percentage is 40%, and if i decide to go to the next step, i want the paint to stay as is but the counter start counting again from 0%.

    is there anyway to do this?? thank youu
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    If it's ChannelCounter then you must use multiple material layers (or texture layers via custom shader), so you paint them separately with separate counters. If it's one texture then you would have to use the ChangeCounter, where you change the reference Texture to a copy of your texture (e.g. RenderTexture + Graphics.Blit), which will make it 'reset' to 0 change.
     
  45. NenadNikolicTech

    NenadNikolicTech

    Joined:
    Jun 22, 2021
    Posts:
    7
    Hey I am using Paint in 3D and I am getting different values in Editor and in WebGL for P3D Change Counter. I am changing texture from old to new and tracking ratio with change counter, since camera angle is fixed, only partial texture swap is possible, but I can't set a reliable value. In fact ratio in WebGL is not the same every time for the maximum painted amount possible, varies wildly sometimes.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Are you using the latest version of Paint in 3D? Does this issue occur in the example scenes, or only your setup?
     
  47. NenadNikolicTech

    NenadNikolicTech

    Joined:
    Jun 22, 2021
    Posts:
    7
    Hey I tested building scene 55 change counter and uploading to Itch.io and here are results:

    Unity 2021.2.7, Paint3D 2.0.0, instant 35% on first tap of paint, stuck there for whole painting process, also plain invisible before paint
    Unity 2021.2.7, Paint3D 2.0.2, same behavior
    Unity 2020.3.23, Paint3D 2.0.2, same, just stuck on 0%

    For editor, Paint3D 2.0.0 went evenly from 0 to 49%, Paint3D 2.0.2 went from 100% to 54% evenly. All results were same in my project and in new clean projects. Only thing I changed in clean projects is switch to webgl and resolution to 812x375. This is painting whole plane without moving camera.

    For my project, I paint 4 objects, they are mostly stuck close to a certain percentage though, it decreases slightly, not proportional to amount of painted. So it goes instant 82%, then slowly to 80% and sometimes jumps to 45%.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    Do you have a link to the itch.io test? If I make a WebGL build with Unity 2021.1.15f1 in a new BiRP project with just Paint in 3D then it works fine on my PC. It sounds like this might be a browser or GPU issue.
     
  49. NenadNikolicTech

    NenadNikolicTech

    Joined:
    Jun 22, 2021
    Posts:
    7
    https://brainzy.itch.io/paint3d-test , it is in built in render pipe line.
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,336
    I just tested it again and:

    Unity 2021.2.7f1 - Counter doesn't work properly.
    Unity 2021.2.15f1 - Counter doesn't work properly.
    Unity 2021.1.15f1 - Counter works properly.

    So it looks like somewhere around 2021.2 they changed something that caused it to break.

    If I disable the P3dChangeCounter's Async setting, then it works in 2021.2.15 (I didn't test 2021.2.7), so I guess the issue lies with the gpu async readback. This is likely to be a bug in Unity, so for now at least I recommend you use 2021.1.x.