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. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    This has been fixed, a new version should be out in a few days!


    Aha, I changed the input system for P3dHitScreen, and forgot to add a check for when you click in the UI, so what happens is you click undo but because it doesn't check for the UI it actually just paints a new dot when you click and then undoes that. I think earlier versions had a different issue that I since fixed. Expect a new version in a few days!


    The P3dPaintableTexture component has the OnModified and OnAddCommand events (C# only), which you can hook into. Keep in mind being 'modified' or reviving a paint command may not mean it was actually painted, just that you painted near enough to the mesh for it to attempt to paint it. If you want to detect when you actually painted you can use P3dChangeCounter to detect for pixel changes, or use some kind of trigger to detect when your tattoo is close enough to your object that it must have painted something. You could also use live painting so you explicitly know how many tattoo decal objects there are, and you can move them around, etc.
     
    Gwynbleidd00 likes this.
  2. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    105
    Can you tell me a workaround or fix for 1.8.5? I'm in production now and rather not upgrade. Thanks!
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I checked out 1.8.5 and the undo/redo seems to work. The only issue I notice the Car Decals demo scene is incorrectly set up. To fix this you must set the State setting on the Chassis+Windows paintable textures, otherwise it doesn't record anything. Also, using LocalCommandCopy doesn't preserve the original color for the Windows object, because the original window color is from the window texture, which you can fix by clicking the Copy button to the right of its texture slot.
     
  4. arie1994

    arie1994

    Joined:
    Jun 30, 2016
    Posts:
    85
    will the skinned mesh painting work with UMA character(created in runtime)?
    what kind of setup will this require?
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Last time I tried it works, you just have to make sure the UV has no tiled/mirrored/shared areas. The setup is the same as any other object, but if you want to paint using the mouse/finger then you need to add colliders (e.g. capsules). These colliders don't have to match the visual mesh exactly, but their required accuracy must be lower than the size/depth of the decals you want to paint.
     
  6. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    105
    It wasn't the undo on its own but what I showed in my previous video where the undo didn't work when the model has a texture applied.

    That said, I fixed my issue! I had a look at the Car Decal demo, and that demo didn't exhibit the same problem. Turns out it was the Mip Map option that was causing the issue. In the Car Demo it is turned off, but in the video I showed above, it was set to Auto. I'm ok with disabling Mip Map so this is a good enough work around for me.
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Ah yes, Undo/Redo ultimately calls the P3dPaintableTexture.Clear method, which blits the current texture, but it doesn't update its mip maps. I fixed this in 1.8.7 or 1.8.8 by adding:

    Code (csharp):
    1.                 if (updateMips == true && current.useMipMap == true) current.GenerateMips();
     
  8. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Hi, before I go and purchase this asset, I have some questions.
    1. Can we export edited/painted texture so that we could edit it in PS or other tools?
    2. Can we paint on already applied texture and once we are done painting, can we export that texture?
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    1 - Yes, all painted textures can be exported to .png.

    2- Yes, your paintable textures can be set to load a previously exported one, so you can modify -> export -> modify -> etc.
     
  10. Darkcoder

    Darkcoder

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

    Version 1.9.1 of Paint in 3D is out!
    • Fixed P3dPaintableTextureMonitorMask with MaskMesh.
    • Fixed undo/reco when using P3dHitScreen.
    • Fixed console warning when using automatic save/load.

    Also, just a heads up to anyone using HDRP: Paint in 3D does work with it, but for some reason the lighting in the example scenes is so dim that you can't see anything. If you increase the light intensity to 5000000 lux then things appear. I'll try and find a solution to this that doesn't require me to write HDRP specific code.

    Also, when switching pipelines in HDRP you get some errors in the console. As far as I can tell is a harmless bug with Unity and they don't seem to impact the way Paint in 3D works, so you can ignore them.

    Enjoy :)
     
    ObiOneStenobi likes this.
  11. Abnormalia_

    Abnormalia_

    Joined:
    Jul 23, 2013
    Posts:
    124
    Is it possible to do some painting or splat a decal and save this as permanent ?
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    By default all painting is applied to the texture so it's 'permanent', unless you mean save/load where the paint remains between scenes or app close/open? In that case you just need to set the P3dPaintableTexture component's SaveLoad setting to Automatic, and specify a unique SaveName.
     
  13. songjiekun

    songjiekun

    Joined:
    Jan 21, 2017
    Posts:
    29
    hi @Darkcoder

    i used "analyze mesh" tool . i found my mesh is strange.
    in texcoord mode this utilization% is zero and the preview is black.
    in triangles mode it has preview but still utilization is zero
    is this normal?

    ScreenClip1.png ScreenClip2.png
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    This means your mesh has no UV data, so it cannot be painted. You can use automatically generated UVs if you don't know how to make them yourself, this is covered in the UV Requirements section of the documentation.
     
  15. shayk2012

    shayk2012

    Joined:
    Oct 13, 2017
    Posts:
    11
    Saved paintableTexture is too dark

    Hi,

    When I save a paintable texture:
    byte[] bytes = MyPaintableTexture.GetPngData();
    File.WriteAllBytes(FileName+".png", bytes);

    the colors in the saved file are darker than the original texture.
    (I can see it in a photo editor or when I load it ingame to the PaintableTexture).

    Here is what it look like when I save and load 2 times in a row:
    upload_2020-8-3_11-41-53.png => upload_2020-8-3_11-42-10.png => upload_2020-8-3_11-42-24.png

    I'm using P3D version 1.8.9 , Unity 2019.3 (Project settings-Player-Color Space=Linear).

    How can I solve this?
    Thank you
    Shayk
     
  16. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Hi Carlos. I'm trying to find a way to paint an RGB mask texture in the editor at runtime so that I can paint terrain onto your SGT planets. Is this asset what I need? Cheers.
     
  17. LucentGames

    LucentGames

    Joined:
    Feb 28, 2017
    Posts:
    8
    Hi Carlos/Darkcoder,

    Thanks for your previous support, I upgraded to latest and that resolved the issue I was having with gaps between the paint points. I'm unfortunately now having a new issue! We've recently made the switch to Universal Render Pipeline on our project and it seems that the P3D Solid shader doesn't support this out of the box. Is there anything we could do locally to upgrade the shader to support URP? This is a showstopper for us at the moment!

    EDIT: Found it! There's a conveniently provided SRP shadergraph which you can use! Great work man!
     
    Last edited: Aug 7, 2020
    Darkcoder likes this.
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I sent you a private message with a new build, let me know if you encounter any issues.


    This asset might work for that, but one thing to keep in mind is Paint in 3D paints to RenderTextures, whereas SGT usually requires readable Texture2Ds. You can easily convert between the two with Paint in 3D's built in functions though (e.g. P3dPaintableTexture's .GetReadableCopy() method).

    I might make an SGT specific version of the painting tools for the new terrain asset, which I should be showing off more of soon, stay tuned :)


    Indeed, there are SRP versions of all P3D shaders. You can also run the PIPELINE tool in the root PaintIn3D folder to auto convert an materials with non SRP versions and vice versa!
     
    joshua_42 and LucentGames like this.
  19. shayk2012

    shayk2012

    Joined:
    Oct 13, 2017
    Posts:
    11
    Thanks a lot, that build fixed the saving problem!
    Appreciate your great support.

    I have another problem , maybe its related to the linear space too?

    I set the color of the paint component (e.g. PaintSphere, PaintDecal), but when painting, the color resulting on the PaintableTexture is lighter than the one that was set.

    what could be the problem?
    (BTW, I didn't update my P3D to the version you sent me, I just used the changes you made in P3DHelper.GetReadableCopy)

    thanks
    greetings
     
    Last edited: Aug 9, 2020
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I sent you another build which should fix this too :)

    Let me know if I missed anything else!
     
  21. shayk2012

    shayk2012

    Joined:
    Oct 13, 2017
    Posts:
    11

    Wow! That was super fast reply and it's working!! fixed the issue.
    (I just checked the SetColor/FromGamma changes, I'll will look into the other changes later :)
    Thank you !! your'e great :)
     
    Darkcoder likes this.
  22. pirek5

    pirek5

    Joined:
    Nov 5, 2018
    Posts:
    1
    Hello,
    I have same issue as shayk2012 (colors are darker after save). Will there be an oficial release with fix?
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    The next version with these fixes and more will be out in a few days. I sent you an early copy via private message.
     
  24. Darkcoder

    Darkcoder

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

    Version 1.9.2 of Paint in 3D is now out!
    • Fixed P3dHitBetween when using Interval of -1.
    • Fixed P3dHitThrough when using Interval of -1.
    • Textures now save and load in sRGB color space only.
    • Fixed P3dChangeCounterEvent menu entry.
    • Fixed P3dReadColor in linear color space.
    • Fixed color painting in linear color space.
    • Fixed simulated VR controls when interacting with UI.

    Enjoy :)
     
    ObiOneStenobi likes this.
  25. Ilyoushin

    Ilyoushin

    Joined:
    Sep 19, 2019
    Posts:
    3
    Hello, I have a problem with your plugin, my project works great on unity on PC, but its crashed with this error, when Im truing to run it on android device

    Code (CSharp):
    1. [./Runtime/GfxDevice/GfxDevice.cpp line 1743]
    2.     (Filename: ./Runtime/GfxDevice/GfxDevice.cpp Line: 1743)
    3. 08-19 12:51:06.453 17157-17179/com.appscraft.mehanic E/Unity: This GfxDevice does not support asynchronous readback
    4.     UnityEngine.Rendering.AsyncGPUReadback:Request_Internal_Texture_2(Texture, Int32, GraphicsFormat)
    5.     UnityEngine.Rendering.AsyncGPUReadback:Request(Texture, Int32, GraphicsFormat, Action`1)
    6.     PaintIn3D.P3dReader:Request(RenderTexture, Int32, Boolean)
    7.     PaintIn3D.P3dPaintableTextureMonitor:Update()
    8.     PaintIn3D.P3dPaintableTextureMonitorMask:Update()
    Please help
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I sent you a private message with an updated build, let me know if this fixes the issue.
     
  27. GambitAnimating

    GambitAnimating

    Joined:
    Feb 20, 2015
    Posts:
    7
    Hi, recently bought this for a project I'm working on, GREAT asset! Love it. one thing I'm wondering if there's a fix for though is if the android is old enough (or something) it has a really weird bug. Anywhere you paint, this weird texture glitch happens. My phone is a samsung galaxy s6 running on android 7.0, also this happens on this game as well for the same phone: https://play.google.com/store/apps/details?id=com.majorfrank.sneakerart&hl=en_US which means it's using your asset I suppose

    Thanks for your time!
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Another user reported an issue like this and it appears to be some kind of issue with certain Mali GPUs (S6 has Mali T760MP8). I have a test device with the older Mali 450MP, but I don't notice any issues with it. I believe newer Mali devices work fine, so somewhere in the middle there's some difference.

    If you don't mind I could send you some test builds to track this issue down?
     
    GambitAnimating likes this.
  29. GambitAnimating

    GambitAnimating

    Joined:
    Feb 20, 2015
    Posts:
    7
    For sure, I'm down for that just send me the builds whenever you can and ill get them tested asap :)
    Thanks for the quick response!
     
  30. Darkcoder

    Darkcoder

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

    Version 1.9.3 of Paint in 3D is now out!
    • Fixed texture modifier de/serialization of texture references.
    • Fixed P3dReader error on devices that don't support async texture reads.
    • Fixed quick clicks making paint components behave incorrectly.
    • Disabled component activation context menu option when in edit mode.
    • Added warning to activated components when in edit mode.
    • Fixed P3dHitParticles error on first frame.

    NOTE: Fixing the paint modifiers required changing their data structure, which means your modifier data is now lost. To update, you must manually recreate your modifiers and their settings. Sorry for the inconvenience!

    Enjoy :)
     
  31. xpath

    xpath

    Joined:
    Dec 3, 2018
    Posts:
    20
    Hello, Thanks a lot for this nice package.
    I cannot paint or delete some objects I downloaded from free3d or asset store. Do I need to make a different setting while creating or painting objects?
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Maybe they need UV data. Click the "Analyze Mesh" button on the P3dPaintable component, or directly from the mesh context menu (gear icon). You can follow the steps in the UV Requirements section of the documentation if they're missing.
     
    xpath likes this.
  33. XB23

    XB23

    Joined:
    Sep 12, 2018
    Posts:
    20
    Hello, I just found your "paint in 3D" tools and I would like to ask you if it feat my needs. I need a tool to draw, in play, on a transparent layer (to keep background's transparency) and the possibility to erase a drawing, erase all and undo/redo actions.

    I'm really sorry to ask if the answer is in the forum but I'm at work and I don't have much time to search, it's why I ask directly.

    Thanks you!
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    No problem, feel free to ask questions here!

    Yes, Paint in 3D allows you to paint a transparent texture, and still keep it transparent (assuming I understand your scenario). For example, your texture begins as RGBA 0,0,0,0 (transparent black). You could paint using a red brush, but skip writing to the alpha, which will give you pixels like RGBA 255,0,0,0 (transparent red). You can also paint red normally and it will give you pixels like RGBA 255,0,0,255, and it will retain the 0 opacity of the surrounding pixels that you didn't paint.

    All of this can be erased using a variety of paint methods (e.g. subtract opacity, replace the RGBA values with their original, replace the RGB values with their original, etc). You can also undo/redo all of these, or replace every pixel in your texture with a specific RGBA value, or a specific reference texture (e.g. original, or a custom one).
     
  35. XB23

    XB23

    Joined:
    Sep 12, 2018
    Posts:
    20
    Hello again, I have another question, in your webgl example, we can draw on a black board with 3 marker pens, I want to do something like that in my app. Did we need a 3D objects to draw on his texture or can I display and draw on another object like plane or something like that (something more UI) ?

    Thanks you again and have a nice day!
     
  36. XB23

    XB23

    Joined:
    Sep 12, 2018
    Posts:
    20
    Edit: The draw feeling that I search is more like the examples when you draw on the 3D aircraft than the black board in fact.
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Painting must be done on a 3D object. This can be a flat plane like a sprite, but not a normal UI element.
     
  38. hecali_aj

    hecali_aj

    Joined:
    Sep 1, 2015
    Posts:
    24
    Hello! Does this asset have a feature where you paint vertex colors onto a mesh without UV in real-time?
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Nope, only texture painting on meshes with UV.
     
  40. Yavvn

    Yavvn

    Joined:
    May 8, 2019
    Posts:
    18
    Is there any way to make paint (individually) fade from its base paint color into another color over time? From what I'm seeing the GraduallyFade script won't work for this purpose.

    Also, is it possible to alter the scale and position of paint after something (e.g. PaintSphere) has been painted? I'm only seeing methods of altering previewing paint, not paint that has been painted onto an object.
     
    Last edited: Sep 7, 2020
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    This can be done using the Live Painting examples as a base, which work using the preview painting system. Once your paint has transitioned to its final state you can actually apply the paint.

    If you want to modify the paint that's already been applied then you can:

    A) Set UndoRedo to LocalCommandCopy, and modify the commands directly (they're in the States list). You can then repaint your object from scratch with these modified commands by calling RebuildFromCommands (this is currently private, but will be made public in the next version). Just keep in mind this approach will be slow if you have many paint commands.

    B) Use a custom shader to modify your painted textures. This can either modify the texture itself using Blit, or you can leave the texture as-is, but simply change the way it renders to the screen.
     
    Yavvn likes this.
  42. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    105
    Hey Carlos, would you know what's happening in the attached image?

    paint in 3d seam fixer issue.png
    So I'm using the seam fixer on a beveled cube. And on some of the beveled corners, the seam fixer looks like it's interpreting the edges (?) incorrectly. Whatever is happening, the incorrect version prevents the area within the triangle from being painted properly.

    I've been able to fix it by recreating the mesh, but just want to know if it's something I can fix so I don't have to recreate the mesh each time I come across it.

    Thanks!
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    It's hard to tell from that image, but it looks like there is a small triangle hole in your UV there, and this hole is being seam fixed outward to create this big triangle. The green lines show the UV island edges, and there shouldn't be one there for best results.
     
  44. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    105
    The hole is actually a face. It's a beveled cube. I've attached the fbx if you could take a look.

    paint in 3d seam fixer beveld cube.png
     

    Attached Files:

  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Indeed, the mesh looks fine. This must be a bug with the seam fixer then, I'll look into it!
     
    Yavvn likes this.
  46. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,465
    I miss painting in the scene view
     
  47. LucentGames

    LucentGames

    Joined:
    Feb 28, 2017
    Posts:
    8
    Hey Carlos,

    Me again! Everyone is absolutely loving my multi-user VR implementation of a whiteboard utilising your P3D plugin so thanks again!

    One thing that I've recently come across and wanted to ask about is the transparent painting. I'm not sure if this is a problem exclusive to the SRP variant of the P3D shader or not, but when using P3D Alpha, there is noticeable fringing on the edges of the brushes, rather than using alpha transparency they seem to be using white/sometimes random colours to fade the edges. Any idea if this can be improved upon or if I'm doing something wrong?

    See examples here.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    So do I, but I don't miss having to write the same code twice to support it. Almost all Paint in 3D users only use the in-game painting features, and with the current setup I can focus on development of that and still have the new features more or less automatically work with the in-editor features too. Making the paint work in the scene view without entering play mode and without modifying the GameObjects requires a lot of extra code, and much of this code changes between each major Unity version, so it's a nightmare to support. I previously tried to make it work in a custom painting window, which would have been a nice middle ground, but no matter what I tried I couldn't get the lighting in that view to work properly.

    I have some ideas to improve the in-editor painting workflow though, like a way to automatically create a new scene based on your selection, and some better camera controls.


    This is caused by bilinear filtering and/or mip mapping. Basically, if you imagine a 3x3 pixel image that is RGBA 0,0,0,255, and you paint the center pixel white (255,255,255,255). When you use bilinear filtering the texels between the center pixel and the outside pixels will be a linear blend between 0..255 on the RGB channels. This will give your center white pixel a 'fringe' that starts white and gradually fades to black.

    The best way to fix this is to use premultiplied alpha, which requires modifying the shader's output Blend:

    upload_2020-9-10_8-22-26.png

    You must also modify the texture:

    upload_2020-9-10_8-22-58.png

    And also the paint components:

    upload_2020-9-10_8-23-24.png

    You can read more about it HERE.

    As you can see, it's a little complex. Also, most shaders don't use this, so I didn't include these settings by default.

    [Edit] The changes I mention don't actually work. Let me experiment a bit and see what I messed up!

    [Edit2] I experimented with it some more and I can't really wrap my head around what Unity's implementation of the Premultiplied blending mode is supposed to do. Someone HERE mentioned the same thing, and it seems like Unity is premultiplying the albedo with the alpha after you pass it albedo+alpha values, which makes this mode useless... Unless you write a custom shader that implements actual premultiplied alpha (Blend One OneMinusSrcAlpha), you will have to settle for the below method:

    One thing to keep in mind is that Paint in 3D's "Alpha Blend" blending mode does perform special calculations to try and hide this fringe. However, this feature only works if the edge of your paint has some smoothness (e.g. doesn't have a high Hardness value), or if there's some border around your paint. The P3dPaintSphere component has no such border and paints right to the edge, but you could use P3dPaintDecal with a sphere shape that does have some border, and this will improve things.
     
    Last edited: Sep 10, 2020
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I've now fixed this bug. The issue was these triangles were smaller than my threshold value for ignoring triangles that don't exist, so I've now made the threshold 0.
     
  50. LucentGames

    LucentGames

    Joined:
    Feb 28, 2017
    Posts:
    8
    Thanks so much for the info, strange to hear Unity seem to be implementing the pre-multiplied blend mode weirdly! I'll give your suggestion of using a P3DPaintDecal a try! Much appreciated