Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    83
    Thanks a lot for the reply !

    I was a bit unclear about the issue, apologies : it does not crash, it simply freezes, and I have to force quit. Just tried it again right now, it's been stuck changing material for 5mn... But it did work in the end, I just used to force quit after a couple minutes. So I guess your explanation of paintin3D scanning the whole project makes sense (it is much faster on smaller projects). I avoid the preset button and manually add the components, but I have to switch the material to white...

    I have a few questions while I'm here : when I export a texture to paint, is there any way to have it black instead of white ? Or, alternatively, is there any way to fill a whole mesh a certain color when painting in editor ?
    Also, seing your old video tutorial, it seems that paint in 3D used to allow to paint directly in the scene window, without entering play mode, and that seems just incredible to me (at least with the setup I have going on right now, where I need to paint in big scenes so entering play mode can be annoying, take more time, etc.), is there any particular reason you dropped this ?

    Anyway, thanks again for the help !

    EDIT : haha I just got a crash after sending the message, when leaving playmode after painting (without exporting the textures).

    Here is the upm log :
    Code (CSharp):
    1. [2021-03-11T17:18:20.287Z][INFO] Creating server instance
    2. [2021-03-11T17:18:20.347Z][INFO] Starting Server
    3. [2021-03-11T17:18:20.361Z][INFO] Server started on port [53949]
    4. [2021-03-11T17:18:20.645Z][INFO] Health Request received
    5. [2021-03-11T17:18:20.939Z][INFO] Resolving dependencies using SAT solver
    6. [2021-03-11T17:18:34.018Z][INFO] com.unity.entities@0.11.2-preview.1 has conflicting dependencies
    7. com.unity.nuget.mono-cecil: Resolved version [1.10.1] has a different 'major' than requested version [0.1.6-preview.2]
    8. [2021-03-11T17:18:34.019Z][INFO] com.unity.properties@1.5.0-preview has conflicting dependencies
    9. com.unity.nuget.mono-cecil: Resolved version [1.10.1] has a different 'major' than requested version [0.1.6-preview.2]
    10. [2021-03-11T17:23:46.096Z][INFO] Resolving dependencies using SAT solver
    11. [2021-03-11T17:35:29.979Z][INFO] Resolving dependencies using SAT solver
    12. [2021-03-11T17:53:22.668Z][INFO] Resolving dependencies using SAT solver
    13. [2021-03-11T18:08:17.086Z][INFO] Resolving dependencies using SAT solver
    14. [2021-03-11T18:09:39.919Z][ERROR] [Unity Package Manager (Upm)]
    15. Parent process [1812] was terminated
    16.  
     
    Last edited: Mar 11, 2021
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    When it crashes the Editor.log should contain something like "CRASH!!!" followed by a stack trace of useful information. The UPM part there looks normal.

    I changed the way the in-editor painting works because integrating it into the scene view like this basically means I have to rewrite all the in-game painting code to be in-editor specific. Making them both work in the game view means most of the code can be shared, which saves a lot of time. Paint in 3D will soon move to Unity 2019 though, which has some different scene view editing tools. This may allow me to bring the painting itself back to the scene view, we'll see.

    I'll send you a new build in a few minutes with a different project search method.
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,407
    I need some help trying to figure out how to implement paint layers. I want to be able to switch which layer is active (being painted on) at any time. Earlier, @Darkcod
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,407
    I need some help figuring out how to properly implement paint layers. I want to be able to switch which layer is active (being painted to) at any time. Earlier, @Darkcoder you wrote:

    But when I try this, enabling/disabling the P3dPaintableTexture components, it doesn't work properly.

    upload_2021-3-11_21-45-48.png

    Here I have two layered textures (materials) on the cube in the foreground. The floating panel in the background is showing the first of these materials, which is currently covered up by the second (white) material on the cube. I was attempting to draw a horizontal stripe on the underlying (colored) texture, and a vertical stripe on the white one.

    I started with only the first P3dPaintableTexture (referencing slot 0) enabled, and used a P3dPaintDecal to draw the lower horizontal line from left to right. This correctly applied paint to the underlying texture, as I could see from the floating panel, and did not affect the overlying white texture. So far so good.

    Then I disabled that P3dPaintableTexture and enabled the second one (referencing slot 1). At this point, the red horizontal stripe suddenly appeared on the second (white) texture also! From there I dragged the brush up, and you can see that after that point, it applied only to the second texture, as it should. But the fact that previous painting suddenly appeared on that layer when I enabled it is not acceptable.

    So... is there another way to implement layers? Or something I should do when switching layers to tell the P3dPaintDecal to clear some cache or something?
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    I experimented with this a bit and the best way to implement it was a bit different to what I explained. I'll send you a test build shortly!
     
    JoeStrout likes this.
  6. Unity_gl

    Unity_gl

    Joined:
    Mar 15, 2021
    Posts:
    4
    upload_2021-3-15_16-33-36.png
    Hello, how can I get the current percentage instead of RGBA? @Darkcoder
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Total percentage of what? You can Mathf.Max the RGBA values, or add them up, or use the P3dChangeCounter, etc.
     
  8. Unity_gl

    Unity_gl

    Joined:
    Mar 15, 2021
    Posts:
    4
    upload_2021-3-15_19-11-31.png
    Thank you. Can I use basic mapping and color coloring besides color and texture?
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    1 - What is 'basic mapping'?

    2 - What is 'color coloring besides color and texture'? Like flood fill?
     
  10. Unity_gl

    Unity_gl

    Joined:
    Mar 15, 2021
    Posts:
    4
    No, I want to apply translucent to the object
     
  11. Unity_gl

    Unity_gl

    Joined:
    Mar 15, 2021
    Posts:
    4
    Hello, may I ask, using P3dChangeCounter to count the smear percentage, the count cannot be read, and it is found that the HandleComplete method is caused by distance> threshold32. Is there any solution? upload_2021-3-16_17-32-35.png upload_2021-3-16_17-32-35.png
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    You can change the BlendMode to Subtractive and change the Color to 0,0,0,1. This will 'erase' the alpha/opacity, and make the texture translucent.


    The Count can be read from the public property called Count:

    upload_2021-3-17_0-34-3.png

    I don't know what you mean by distance and threshold32. This is how the change/difference between the current painted texture and the original/reference texture is calculated. If you want different behaviour then you can change the code?
     
  13. cansuaydin

    cansuaydin

    Joined:
    Apr 9, 2019
    Posts:
    1
    How to make the player save painted texture and export the image by button click?
     
  14. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    432
    Last edited: Mar 17, 2021
  15. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    216
    Hey there! Is there a recommended way to compare two drawings? Say if the player had to trace a signature on a texture and you get a percentage of how close the two drawings are? Thanks!
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    You can connect the button's OnClick event to the P3dPaintableTexture component's Save and Load methods. To export you would have to write some custom code though, which would be platform specific and far outside the scope of what I want to implement.


    Paint in 3D only supports painting normal meshes (MeshFilter+MeshRenderer or SkinnedMeshRenderer). Terrains use their own magic system that can't be accessed in the same way. You 'could' paint a terrain with Paint in 3D if you generated a normal mesh on top of it, in the area you want to paint, and then somehow use that painted texture on the terrain. This would require custom code though.

    The P3dChangeCounter component can do this, where it compares the pixel differences between the current painted texture, and a reference texture you specify. It may not be suitable for signatures though, because they would have to draw it in the exact same area and size for you to get useful results. If you want any kind of accuracy then you could use Paint in 3D for the drawing part, and then store the drawn signature's hit points to a list, and then directly compare the drawn points to the reference points. You could then perform some transformations to align them, and use some sort of algorithm to see how much they match.
     
    nosajtevol likes this.
  17. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    216
    Thanks so much for the quick response! I'll try that :)

    Edit: The P3dChangeCounter works perfectly. I don't need it to be 100% because I can just "fake it" to say if they did perfectly or not. Thanks so much for this wonderful asset!
     
    Last edited: Mar 18, 2021
    Darkcoder likes this.
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Hey everyone,

    Version 1.10.1 of Paint in 3D is now out!
    • NOTE  This update changes a lot of features. Back up your project before updating!
    • Moved main build to Unity 2019.4.12f1.
    • Added Seam Fixer / Auto Seam Fix demo scene.
    • Added Auto UV demo scene.
    • Added Base Color demo scene.
    • Added Line Painting demo scene.
    • Added Line Painting / Arrows demo scene.
    • Added P3dHitScreen.Frequency setting.
    • Added P3dPaintable.OnActivating event.
    • Added P3dPaintable.UseMesh advanced setting.
    • Added P3dHitParticles.Emit setting.
    • Added P3dHitParticles.Layers setting.
    • Added P3dHitParticles.Root setting.
    • Added P3dHitCollisions.PressureMode setting.
    • In-Editor: Added Build Material As Decal button to materials.
    • P3dPaintableTexture now shows a warning when trying to paint a Slot with tiling or offset.
    • Improved inspector organization of all P3dHit___ components.
    • Improved inspector organization of all P3dDraw___ components.
    • Reduced Solid shader instruction count.
    • Reduced Alpha shader instruction count.
    • Improved VR Pen demo scene setup.
    • Simplified hierarchy of all demo scenes.
    • Moved fill painting to new P3dHitScreenFill component.
    • Fixed P3dBlendMode overlap with narrow inspector.
    • Replaced example shaders with Better Shaders.
    This is a really big update with lots of changes, so back up your project before updating!

    The biggest change many will appreciate is that you no longer have to seam fix meshes. The P3dPaintable component now has the Advanced / Use Mesh setting, which can be set to Auto Seam Fix. This should save a lot of time during development. Of course there is a little startup performance penalty if you use this feature, and you lose the ability to customize the seams, but for most cases it should be fine. I plan to extend this new feature in future versions to remove this performance penalty, but there were just too many nice new features piling up to wait.

    I also tidied up the P3dHitScreen code into multiple classes. This makes implementing new features much easier, so much so that I added many new painting modes via the new Frequency setting, and also added line painting via the new P3dHitScreenLine component.

    I also went though every demo scene and tidied them up. It should now be much easier to understand how everything is set up.

    I also implemented Better Shaders (not required), as well as some scripts to modify the scene based on the rendering pipeline. This means all the Paint in 3D example scenes now 'just work' in standard, URP, and HDRP.

    Let me know if you encounter any issues!

    Enjoy :)
     
  19. Varun_Mhatre

    Varun_Mhatre

    Joined:
    Apr 4, 2018
    Posts:
    1
    Hi!

    I was looking through you documentation (thanks for sharing it, btw!) and noticed that in your Getting Started (In-Editor) section you only require MeshFilter + MeshRenderer components to paint but no Colliders (assuming I didn't misunderstand your instructions). I am creating an In-Editor tool that put decals on models and wanted to ask if I can achieve this without needing to add colliders on them (I need to use high poly models and colliders on them causes the performance to tank severely).

    Thanks!
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    The in-editor painting used to work like this, but then I changed the design to make it easier to update which required doing the painting in the game view with colliders. However, since moving Paint in 3D to Unity 2019 and rewriting the painting code it may be possible to make it work in the Scene window without colliders once again. I'm a little too busy to experiment with this though, if you remind me in a week or so I'll see what I can do :D
     
  21. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,040
    Hi Just bought this, but none of the scenes work in URP in 2019 LTS latest. I have done everything in the docs but all comes out pink - please help I need this for a client project and the store page led me to believe this would work.
    Please help! @Darkcoder

    EDIT: its pink now if I swap to inbuilt too! I literally cannot use the asset - please advise

    EDIT2: I also sent you an email via support email
     
    Last edited: Mar 24, 2021
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Sorry for the problems.

    The issue is that I forgot to rename a file that I share across multiple projects to support all render pipelines. You can fix this by opening the Project view to the "PaintIn3D\Shared\Scripts" folder, and renaming the ShaderBundle file to P3dShaderBundle.

    I'll submit a fix right away!
     
    MadeFromPolygons likes this.
  23. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,040
    Thanks mate, appreciate it
     
    Darkcoder likes this.
  24. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    234
    Thanks for the reply. I can confirm this is no longer an issue on the latest version. Thanks!
     
    Darkcoder likes this.
  25. schmoey

    schmoey

    Joined:
    Aug 30, 2012
    Posts:
    7
    Hi!

    Can you please help me understand why I can't paint on parts of this mesh that are not in submesh 0? Using your mesh analyser you can see that there are three submeshes, but I can only get it to paint on areas that are in the first submesh!

    I've attached the model in a zip file here.

    Thanks so much for your help!
     

    Attached Files:

  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    3 submeshes requires 3 materials to render, and therefore 3 P3dMaterialCloners, and 3 P3dPaintableTextures. These must also point to the right Index/Slot of 0, 1, and 2.
     
  27. schmoey

    schmoey

    Joined:
    Aug 30, 2012
    Posts:
    7
    Thanks yeah I was already doing that, but parts of the mesh were still not playing ball. We figured it out in the end, turns out the artist was "expanding past u1v1" as they put it, so I guess going past the uv bounds. Now they've squished the uvs down so they're in the main uv space and it works.

    Is there anything from your end that could mitigate this problem or will it always be a case of having to stay within the main uv space?

    Sorry if my terminology is a bit wrong here, tech art world is not my strong suit :cool:
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Oh I see. Well if the UV is outside of the normal texture space then it's very likely to give you unexpected results, since each pixel could map to multiple 3D points. The "04 Unsuitable UV" demo scene shows you what might happen if your UV is tiled and overlapping, and there are some mitigation techniques shown in the scenes after.
     
    schmoey likes this.
  29. schmoey

    schmoey

    Joined:
    Aug 30, 2012
    Posts:
    7
    Cheers I'll have a look and see if there's something there that can help out :)
     
    Darkcoder likes this.
  30. phil-R

    phil-R

    Joined:
    Nov 20, 2020
    Posts:
    8
    Hello! First, I want to say this is a great asset, very well documented and supported - thank you!

    I have imported the asset into a URP project, and all the in-game demo scenes run perfectly. However, I have one particular existing scene where I can not seem to get Paint3D to work. I was just wondering if there are any known things to look out for when adding to an existing scene (cameras, mouse event scripts, canvas, layers, etc.)

    One possible hint: I had a few cameras in the scene and when I disabled all but one, I was finally able to see the paint dot projected on the sample mesh, but I was unable to actually click+drag to paint. I have made the _BaseLayer shader edit for URP.
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    If you're painting with P3dHitScreen then your scene needs to meet these requirements:

    1. Your scene must have a camera tagged as MainCamera (unless you manually specify a camera in P3dHitScreen.Camera).
    2. Your UI cannot block your fingers/mouse where you want to paint (check your UI layers and P3dHitScreen.GuiLayers).
    3. The objects you want to paint must have colliders that are close enough to the actual mesh to be within the radius of your paint component.
    4. Your paint Group setting must match the one on your paintable texture.
    5. Your object's shader must be rendering the texture that matches your paintable texture slot.

    In most cases the issue is 2, where people often have a full screen UI element that they don't notice. Like a UI panel with RaycastTarget enabled, even if the panel is transparent. You can select your EventSystem during play mode to see what/if the fingers are seeing in the inspector. You can also add the P3dPaintDebug component and see the scene view and see if it's painting anywhere.
     
  32. phil-R

    phil-R

    Joined:
    Nov 20, 2020
    Posts:
    8
    Thanks for your help. I have checked all the things you mention, but I still seem to be unable to interact with a Paintable when the Canvas' Graphic Raycaster component is enabled. When I disable the graphic raycaster, I can paint, but I can no longer interact with the UI.
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Your UI must be blocking the fingers then. What does the EventSystem show you when you try to paint?
     
  34. Abnormalia_

    Abnormalia_

    Joined:
    Jul 23, 2013
    Posts:
    68
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Nice!!
     
  36. unity_rxzPLUt7IprzEg

    unity_rxzPLUt7IprzEg

    Joined:
    Dec 8, 2020
    Posts:
    1
    I am using the paint in 3d package in unity, but I cannot paint my object on maya. Can you tell me the solution?
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Click the "Analyze Mesh" button. Likely, your mesh has no UV data. The first few demo scenes and documentation list some strategies to fix this.
     
  38. songjiekun

    songjiekun

    Joined:
    Jan 21, 2017
    Posts:
    28
    hi @Darkcoder
    I have a character stand on the ground. and the ground is paintable, some part of the ground has been painted. is it possible to check if the character stands on the painted part or the non-painted part of the ground? (the ground is one single object)
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Demo scene 69 "Read Color / Under" shows you how to read the pixel color between two points. Keep in mind the object you're reading from must have a non-convex MeshCollider for this to work.
     
  40. Briggzee

    Briggzee

    Joined:
    Mar 3, 2021
    Posts:
    2
    Hi I'm looking at this great solution and debating whether to buy it. Is there a way I can enable/disable the ability to paint in-game easily? For example, from a keydown or having the character walk into a certain area of the scene?
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    To enable/disable painting all you need to do is enable/disable the components that activate the painting, which is every component whose name starts with P3dHit (e.g. P3dHitScreen, P3dHitBetween, etc). While P3dHitScreen has a built-in feature to paint using a specific key, there is no component that comes with Paint in 3D that can enable/disable these components outright using just a key or character position. This kind of feature is very game specific and unrelated to painting and is best done using a custom script or some visual scripting tool.

    Also, Paint in 3D may or not be going on sale in 4 days, so you might want to hold off on your purchase for a little bit longer ;)
     
    Briggzee likes this.
  42. Abnormalia_

    Abnormalia_

    Joined:
    Jul 23, 2013
    Posts:
    68


    I wanted to “clear” details normal too (now only albedo deduction), for some reason failed to setup. Is it possible to do both on same material and source?
     
  43. Briggzee

    Briggzee

    Joined:
    Mar 3, 2021
    Posts:
    2
    Thanks for the detailed response and the heads up on the sale, very kind.
     
    Darkcoder likes this.
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    Can you give me a timestamp in the video of the issue? Or more details, then I can help you more easily!

    You can clear both normals and albedo paint the same way (e.g. the Clear method on each P3dPaintableTexture). Keep in mind the P3dPaintableTexture's Color and Texture should be correctly set - for normals this should be white, and a normal texture (e.g. the Normal_Default textures that comes with the asset). You can also 'paint' the normals back, as seen in the "PBR Painting" demo scene using the aforementioned Color and Texture. Or paint using the "Replace Original" blending mode, etc.
     
  45. Abnormalia_

    Abnormalia_

    Joined:
    Jul 23, 2013
    Posts:
    68
    There is no issue I turn off normals for now. Probably missed default normal texture settings, will try it asap
     
    Darkcoder likes this.
  46. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    185
    Hi, this is a great asset! I'm hoping you can give me some tips and point me in the right direction.

    I'm working on a tattoo system. During run time I want to display tattoos on a Skinned Mesh Renderer (the player).
    1. In the editor I want to position the tattoos on the Skinned Mesh.
    2. During runtime, I want to unlock and display the tattoos one by one. The player would start out with no visible tattoos.

    Is there an example of this, or maybe several examples showing the different steps and approaches I would need?
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    This can be done using the "58 Live Painting" demo scene as a base, and applied as seen in the "59 Apply" scene. However, while in preview mode the tattoo would appear to move with the skinned mesh as it animates. To fix this you could make the player go into some kind idle state while you preview and apply the tattoo, or you can use a setup like the "61 LOD Painting" scene, where the paint is shown using one mesh (e.g. animated character), and painted using another (e.g. T-pose character).
     
  48. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    185
    Hi, thank you for your very quick and detailed reply. What do you mean by "preview"?
     
  49. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    185
    So I think I understand what you suggested after looking at the scenes you pointed me to.

    What do you think about this as a solution...
    1. I have two of the Player models. The Player Model, and the Tattoo Dummy Model
    2. I position the P3D Paint Decal (Tattoo) game object on a the Tattoo Dummy Model in the editor. This tattoo game object would have the P3DHitNearby component and the P3DPaintDecal component.
    3. Then to show the tattoo during runtime, I would call, in the tattoo game object, P3DHitNearby.ManuallyHitNow.
    4. And the tattoo game object would write to the Player Model's renderer.

    But what I don't see is how would the tattoo game object write to the Player Model renderer? I see in the P3DPaintable component there are Other Renders. But then the Play Model would have to have colliders. I don't think P3DPaintDecal can write to another render like P3DPaintable, right?
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,458
    There are 2 types of paint applied in Paint in 3D: preview painting, which only shows for the current frame, and non-preview painting, which gets applied to the objects/textures in your scene.

    You only only need a collider if you're painting with a component that uses raycasts or collisions (e.g. P3dHitScreen). P3dHitNearby just paints at the current Transform position, so the location of where to paint is known, thus no colliders are required. If both your 'real' and 'dummy' objects begin with the same material, then you can use the OtherRenderers list, and it should automatically clone the material once and apply it to both. This means you can paint your 'dummy' object, and the paint applied to it will also show on the 'real' object in the same places.
     
unityunity