Search Unity

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

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

  1. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Hi Carlos, do you know how I could have a preview of the radius of the eraser, when I work with a secondary shader with a substractive paint tool ? I's just to see wher I'm going to delete the drawing, and the radius of my tool... Thank's !
    Olivier
     
  2. unity_QLADgJWFSMtcXg

    unity_QLADgJWFSMtcXg

    Joined:
    Mar 17, 2020
    Posts:
    1
    Hi. I have a problem. Everything works well on all test phones except the Samsung Galaxy A50. The game crashes on this device. Thanks!
     
  3. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Hello Carlos,

    Is it possible to apply paint counter to MetallicGloss painting ?

    Thank you
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If you're using a tool like P3dHitScreen and enable the ShowPreview setting, then it should work even with erase. I think I disabled this setting in the example scenes though. If it doesn't work for you, can you post some pictures of your P3D component settings?


    Hmm, I'm not sure, and I don't have any Samsung devices to test with. Can you enable logging and see if there is anything there?

    Assuming the MetallicGloss paint is applied to one channel of a texture, then you can use the P3dChannelCounter component, which will count the amount of pixels in each channel above the Threshold level. You can then read the SolidR/G/B/A or RatioR/G/B/A values to get this value. The "Channel Counter" example scene shows you how to use this, albeit in a different scenario.
     
  5. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    73
    Wouldn't it be useful to have more Actions in P3dPaintableTexture so we can for example get notified when a new state is added.
    Might be great for syncing over network so we don't have to always sync all commands but only the last added state. This will also enable all clients to use the undo/redo?
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can hook into the P3dPaintableTexture component's OnModified event, which will be called once all paint commands have executed for the current frame. This is used by the pixel/channel counters, and could be used for networking.

    [edit] unless by state you mean undo/redo state? If so, that would indeed be a good idea!
     
  7. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    73
    Yes I meant the undo redo states.

    Also I just discovered that HitNearby calls ManuallyHitNow even if the pencil is just in front of the P3dPaintableTexture geo. Not just when the PaintSphere is actually painting. Whichs gives tons of unnecessary commands in the queue.
     
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It attempts to paint because the mesh boundary overlaps the paint boundary (both spheres). Testing if the surface was actually painted or not is rather expensive, so it's not worth it usually. If you really need to, you can use the P3dChannelCounter to check for changes.
     
  9. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Thank's, Darcoder, preview works, I had make a mistake in parameters... Thank's for your quick response. I will try to fix UV Seams because on my mesh, it seems like a secondary object a little bit transparent when I paint on the secondary transparent texture. When I move the camera, the "seams" looks like there is a glass model on the primary mesh. Or perhaps the second map has a small decalage or something like that.
     
  10. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    73
    Hm still struggling to make a byte array out of the P3DCommand to transfer it via network. Currently I plan to build my own struct to reconstruct it on client side. Do you think it is the right way?

    Code (CSharp):
    1.         struct CommandData
    2.         {
    3.             public P3dBlendMode Blend;
    4.             public int Index;
    5.             public int Material;
    6.             public P3dModel Model;
    7.             public bool Preview;
    8.             public int Priority;
    9.             public int Submesh;
    10.         }
    Still I have to convert P3dBlendMode and P3dModel to basic types to Marshal them. At the moment we are using Photon as network solution but might switch later to a different one.
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    De/serializing the raw command data is difficult unless I simplify the Material data, so I don't recommend it.

    The easiest way to network the painting with Photon which I've done before is to make a new component that implements IHit and IHitPoint (and maybe IHitLine), you can then add this component to your paint tools. When you paint something it will call HandleHitPoint/Line/etc, and you can then broadcast this data which is just positions+rotation+a few other simple values. Once received, you can then broadcast the hit data again to all IHit__ components that aren't the current one.
     
  12. Eckhart3D

    Eckhart3D

    Joined:
    Feb 28, 2020
    Posts:
    3
    Hi. I'm having an problem with "paint in 3d". I use HDRP in Unity 2019.3.7f1 and "Paint in 3d" doesn't work. Not even in demo scenes. No paint what so ever. I did switch it to scriptable pipeline. Any ideas? I imported it to an new empty project and it's the same thing. Thank you in advance.
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I just tested HDRP in 2019.3.7f1 and noticed no issues. Did you follow the steps HERE to activate SRP in Paint in 3D?
     
  14. Eckhart3D

    Eckhart3D

    Joined:
    Feb 28, 2020
    Posts:
    3


    As you can see I did activate SRP. Every demo is like this for me, dark no matter the light source and no paint. Also no console errors.
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Strange these settings work for me:



    Here you can see that I've set HDRP 7.1.8, with default settings:

     
  16. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Hi Carlos, I come toward you because I had not solved my problem, when I have 2 material, and the second transparent, to allow erasing the drawing. All works fine, but the mesh seems to have like a second transparent mesh in front of the firt, and when I move the camera it makes visual bugs... It certainly nothing, but I can't find the problem in the parameters. I have looked at mesh collider, materials, etc, I have fixed the mesh.
    Thanks if you can help me !
     
    Last edited: Apr 21, 2020
  17. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    The webgl export is with URP renderer, but I decided to use the buil in renderer. I have the same problem with both.
     
  18. TrueProger

    TrueProger

    Joined:
    May 26, 2017
    Posts:
    40
    Hello! I just bought your asset!
    He looks cool!
    But I ran into a problem. I create a machine dynamically and it has no statics.
    I get an error

    MissingReferenceException: The object of type 'RenderTexture' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.RenderTexture.GetDescriptor () <0x5116fd00 + 0x0008a> in <b4f5285dbb9e4d199556920be8fbf17d>: 0
    UnityEngine.RenderTexture.get_descriptor () (at C: /buildslave/unity/build/Runtime/Export/Texture.cs: 176)
    PaintIn3D.P3dPaintableTexture.ExecuteCommands (System.Boolean sendNotifications) (at Assets / PaintIn3D / InGame / Scripts / P3dPaintableTexture.cs: 875)
    PaintIn3D.P3dPaintableManager.UpdateAll () (at Assets / PaintIn3D / InGame / Scripts / P3dPaintableManager.cs: 144)
    PaintIn3D.P3dPaintableManager.LateUpdate () (at Assets / PaintIn3D / InGame / Scripts / P3dPaintableManager.cs: 118)

    How do I get around this? Could you give the code to search for texture dynamically?

    I want to use the decal system for racing, the android platform.
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It looks like your base rock material is transparent (alpha blending) too? If so, this won't work, because transparent (alpha blending) shaders don't write to the z buffer, and this z buffer data is needed. The trick where you paint a transparent material on top only works if the base material is opaque or uses cutout transparency, because these shaders will write to the z buffer.

    I should make a demo scene to clarify this, as the Paint On Top demo scene does indeed use two alpha blended shaders, but in this specific demo scene the glass panel is flat so the z buffer data isn't important.

    Can you show me the code you're using to dynamically paint your objects that results in these errors?
     
  20. TrueProger

    TrueProger

    Joined:
    May 26, 2017
    Posts:
    40

    Hello! I just hang your scripts on an object. p3d paintabloe.cs and p3d Paintable Texture.
    Create an object to draw on
    car = Instantiate (cars, new Vector3 (0,0.8f, 6), transform.rotation) as GameObject;
    Then there are errors.

    Object comes with a rigid body

    I do as shown in the Car Decals example.

    I also have a question regarding how to save and load textures on objects that are created dynamically.
    In your examples there are no examples that would really work for games.

    PC Android WebGL Platform

    If this asset does not have the ability to work with dynamic objects, then it does not make sense and I will make a refund.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      138.6 KB
      Views:
      355
    • 2.jpg
      2.jpg
      File size:
      78.8 KB
      Views:
      375
    Last edited: Apr 21, 2020
  21. TrueProger

    TrueProger

    Joined:
    May 26, 2017
    Posts:
    40
    Another problem was revealed that even if you simply paint a static object with a mirror scan, it draws on the other side and doesn’t respond and doesn’t get thousands to draw.
     

    Attached Files:

    • 3.jpg
      3.jpg
      File size:
      850.8 KB
      Views:
      374
    • 4.jpg
      4.jpg
      File size:
      852.3 KB
      Views:
      376
  22. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Great, I understand ! Tahnk's a lot !
     
  23. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Hello, it's certainly a silly question, but when I use 2 materials, the base one Standard, and the second one P3DAlpha is transparent to allow an erase tool, the painting (of the second) doesn't receive any shadows from the environment, whereas the base material do... And the second material isn't affected by a bloom effect... Where is my mistake ? Thank's you very much
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I've attached a package showing that you can spawn a paintable prefab multiple times from C# without issue. Can you show me how to modify this working scene to demonstrate the issue you describe?

    I'm not sure I understand the issue? The mirroring looks fine to me?


    Aha, you can try using the P3D Cutout material on your second layer instead. I'll have to make a new shader or modify P3D Alpha so it can receive shadows.
     

    Attached Files:

  25. TrueProger

    TrueProger

    Joined:
    May 26, 2017
    Posts:
    40
    You do not have normal examples in the examples with the choice of machines that are dynamically created.
    At the beginning of the scene, I create a car.
    In your examples, they are prepared in advance and lie in the scene.
    I can’t allow even hidden objects to be kept in the scene since they will take up space.
    I wrote a refund, this asset is difficult for me. And you can’t draw on models if they are rigid body. Is it possible to draw decals on models without using a mesh collider?
    It is also not at all clear how to save textures and load them later.

    At the expense of the scan. The model has a mirror scan and for this one doesn’t get to draw on one side of the car, nothing happens, if you turn the model on the other side, it will be completely absurd to draw!

    Is it possible to do something like showing here with the help of your asset?
     
  26. iconnary

    iconnary

    Joined:
    Feb 9, 2020
    Posts:
    6
    Hi, just purchased this asset. I'm trying to use the Editor paint window. I can bring an object from my scene into the paint tool (standard shader) and it comes up correctly. Once I switch to the Paint tab and select a paint material, as soon as I mouse over my object it turns completely white. It appears to lose it's underlying textures, and after I paint my object and export the textures they also don't include the original underlying textures.

    Any help is appreciated.

    Thanks
     
  27. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    23
    Hello, this is my implementation step. Although the Material is displayed after the update, it still cannot be painted on it. I hope it can help solve the T-T
    I am unity2019.3.6f1
    Attach the picture, hope to get an answer
     

    Attached Files:

    • 1.png
      1.png
      File size:
      28.1 KB
      Views:
      361
    • 2.png
      2.png
      File size:
      49.9 KB
      Views:
      351
    • 3.png
      3.png
      File size:
      93.1 KB
      Views:
      356
    • 4.png
      4.png
      File size:
      202.9 KB
      Views:
      357
    • 5.png
      5.png
      File size:
      164.2 KB
      Views:
      349
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The demo scene package I attached to my previous post shows that you can dynamically spawn and paint prefabs, exactly as you described: "car = Instantiate (cars, new Vector3 (0,0.8f, 6), transform.rotation) as GameObject;"

    You'll have to explain your issue in a way that I can test and see for myself.

    You can paint objects with Rigidbodies, and they don't need a MeshCollider. However, components like P3dHitScreen/P3dHitBetween use raycasts, so they won't know where to paint if you don't have any colliders. Components like P3dHitNearby/P3dHitThrough don't use raycasts, so they don't require any colliders.

    The "Auto Save Load" demo scene shows you how to implement save/load, though you can also manually call P3dPaintableTexture.Save/Load if you want to do this manually.

    Your car model has mirrored UVs, so painting one side will paint the other. To fix this you must redo your mesh UV so it's not mirrored.

    Painting like in your video is indeed possible, it's a combination of features like the "Live Painting", and others. You will have to implement the UI for this yourself though.

    The in-editor painting tool is currently designed for painting textures from scratch only. Being able to modify an existing texture makes a lot of sense though, I'll see what I can do.


    I'll test this out tomorrow.
     
  29. TrueProger

    TrueProger

    Joined:
    May 26, 2017
    Posts:
    40
    I figured it out a bit, but still the problem remains. I can’t draw on one side because it just doesn’t respond, and the other side works and is drawn on it. Applying a scan.
    The scan can not be redone, as these are already finished models.
    Model and texture provided to you for verification.

    I tried to use other models, it happens that does not paint the object in places at all.


    Another question is, can I make different layers of the first layer of ordinary paint, the second layer of decal, 3 layer uncoiled?

    Another point is it possible to save textures simply in png format, if so, how does it work?
     

    Attached Files:

    • uw1.jpg
      uw1.jpg
      File size:
      382.4 KB
      Views:
      354
    • Car.rar
      File size:
      405.9 KB
      Views:
      353
    Last edited: Apr 24, 2020
  30. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Thank's Darcoder, for your response.
    A Shader wich could receive shadows would be great ! I use the asset in a nature environment, and I have shadows around :) I am not the only one I think. I tried to used CutOut shader, but on the second transparent mat I have strange comportement like "blobs" when I drag the pointer... So I have only the Alpha wich work, but without shadow or Post processing like bloom.
     
  31. code749

    code749

    Joined:
    Jan 17, 2009
    Posts:
    100
    can I paint textures within unity...eg terrain and then bake it out to a single texture

    thank you
     
  32. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    23
    Well, I also agree with this, hoping to keep the basic texture material, the new texture is superimposed and fused.
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The latest version of Paint in 3D (1.8.5) includes the new "Automatic UV" demo scene, which shows you how to paint meshes even if they have UV data unsuitable for painting (e.g. mirrored UVs, like your mesh).

    You can make layers by adding multiple transparent materials to your mesh. This is how the new "Automatic UV" demo scene work, and you can extend this to has 2, 3, 4, etc layers. You can control which layers receives paint using the Group setting which is on the P3dPaintableTexture and P3dPaintSphere/P3dPaintDecal/etc components.

    You can save .png textures using the in-editor painting features, but this system is separate from the in-game features. I'm currently working on a new version that greatly simplifies this, and allows you to directly save in-game painted textures to png.


    Indeed, the cut out effect isn't suitable for many scenarios. I've new made a shader called P3D Overlay, which has shadows. I'll send you an early build in a bit.


    You can only paint normal 3D meshes (MeshFilter+MeshRenderer or SkinnedMeshRenderer), and with the in-editor painting features you can save it out to .png. This feature will be updated soon so in-game painted textures can be saved to .png too, which is useful since the in-game painting features are much more advanced.


    I'm currently working on an update that will fix this :)
     
  34. TrueProger

    TrueProger

    Joined:
    May 26, 2017
    Posts:
    40
    Sounds great!
    We will be waiting for new versions!
    Good luck to you!
     
    Darkcoder likes this.
  35. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    23
    very powerful ;)
     
  36. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Hi Carlos,

    I have another issue. When I replace a texture with another texture, the old texture seems to come back (and the painting counter starts to going down on pourcentage).

    Do you heard about this issue ?

    Thank you very much
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    How are you replacing the texture?

    If you call the P3dPaintableTexture.Replace method then it should work. You can't just call Material.SetTexture anymore, as the texture slot is taken over by P3dPaintableTexture.
     
  38. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hey Carlos, I posted earlier about having that issue on iOS where the painted line would blur. It turns out it actually happens on Android as well, but just not as much.



    This uses the 05 Connected Lines example file, with the camera moved closer, and the brush size set to 0.005.

    The small size of the brush makes it more apparent. With a larger brush you can still tell but happens right on the edge of the brush.

    My goal is to be able to paint thinner lines.

    This is using version 1.85 and I'm using Unity 2019.2.10f. Tested on Pixel 2, Android 10. Doesn't happen in Editor.
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks for the info, it will be much easier to fix this out if it works on Android too!
     
  40. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Hi Carlos,

    Thank you for your quick answer. In fact we followed the example for Paint Counter. We set 2 textures and we remove the upper texture using subtractive soft. We set the removable texture in the Cutout Material in order to detect the pourcentage of removed texture.

    The issue is that it works on Editor normally but on the phone device it keeps dropping and the texture keeps coming back.

    Please check the below drive folder to see the issue and the screenshot of the settings
    https://drive.google.com/open?id=1YZUzZLKivEnl4AUZIS0VIvGOhKhFix9U

    I've also included a screenshot of our UV map analyze if you want to check if this could be the cause.

    Thank you very much
     
    Last edited: Apr 25, 2020
  41. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Hi,thanks for the very complete tool it saves me a lot of work!

    I'm trying to use the tool on a car that has the body mesh separate from the doors, but they use the same texture template.
    If I insert the cloner script I can draw the both meshes but this creates distinct temporary textures ( TempBuffer 6*** ).
    Instead I would need to use a single render texture so that I can export the unique template.
    How can it be done?
     
    Last edited: Apr 25, 2020
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks, I'll check it out tomorrow.


    This can be done using the P3dPaintable.OtherRenderers setting and P3dModel component. It's demonstrated in the "50 Atlas Painting" demo scene.
     
  43. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Thanks for the reply.
    Yes, I am trying it but I am having problems.
    If the mesh are too close to each other in the template it does not draw within a certain distance.
    I can only draw on very distant links such as the front hood, rear hood and the doors.

    If I insert the main body which being the central part is close to everyone, it starts to give problems avoiding the external areas of the plot.

     
    Last edited: Apr 26, 2020
  44. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Hi Carlos!

    So I'm having issues with the accuracy of the HitNearby and PaintSphere.

    On the image below it shows that for the Zombie, it works accurately, however for the girl, it's very inaccurate.


    Here's the setup for the girl:


    And the setup for the paint.


    What do you think it's causing the inaccuracy?

    Many thanks,
    Gabriel.
     

    Attached Files:

  45. BusterTheWizard

    BusterTheWizard

    Joined:
    Jul 2, 2012
    Posts:
    55
    Hi!
    I'm having issues with URP in 2019.3.7, I get these errors on the shaders after changing it to SRP.
     

    Attached Files:

  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    This looks like an issue with your colliders being too far from the surface of your mesh, so the paint sphere gradually drifts from the surface until it can't reach. If you replace your colliders with non-convex MeshColliders you should see the paint can apply as normal.

    This may be an issue with the skinned mesh, as they seem to behave differently depending on their setup or program used to export them. Can you try disabling the P3dPaintable.IncludeScale setting? If not, I may need a copy of this mesh to see what the issue is and add some additional parameter.

    I've almost finished work on the next version, and I'll test out SRP next and get back to you!
     
  47. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    The colliders are all non-convex but in many points it still does not paint, while the decal is fragmented.

    On simple 3d models it works well, but not on models like slightly more detailed cars.

    It only does this with Atals Painting, if I use a different material for each object it works well, but unfortunately I need to have them all on the same texture.
     
    Last edited: Apr 27, 2020
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Are your colliders very low LOD/detail with triangles that don't line up with the mesh too well? You can try disabling them, and adding the MeshColliders directly to your visual meshes to see if it works.
     
  49. GiselleBris22101

    GiselleBris22101

    Joined:
    Apr 26, 2020
    Posts:
    1
    I'm looking to hire people who can do custom mesh...simple items like clothing and furniture! Please shoot me an e-mail with price if intrested! Erin22bris@gmail.com....can pay via PayPal
     
  50. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Hi Carlos,

    I tried disabling the IncludeScale setting, and it didn't work.

    I shared with you through Google Drive the file, my email is gliealonso@gmail.com.


    Many thanks,
    Gabriel.