Search Unity

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

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

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The "VR HVLP" and "VR Pen" demo scenes show you a basic setup. You can see how the P3dVrTool component's events are used to enable/disable various settings, and this can be applied similarly with other VR systems.
     
  2. miryam12

    miryam12

    Joined:
    Apr 28, 2022
    Posts:
    1
    Hey,
    I try to paint in the VR HVLP scene, without success. Particles come out, and the sprayer moves, but the wheel is not painted.
    It's not clear to me what I'm supposed to do.
    Can you please give me a detailed explanation?
    (Once I understand how coloring is supposed to work in your scene, I can use it for my projects.)
    Thanks
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You should first follow the tutorial demo scenes, especially "01 Basic Setup", and "35 Particle Painting". This is configured the same way, except the P3dVrTool component enables/disables the particles and sound.

    The painting works for me so I need more information about your setup to be able to replicate it.
     
  4. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    Best is to use a local mask and use an outer cover on moving objects.
     
  5. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    I want to ask on the VR spray - What determines from what distance you can draw with it?
    30 באפר׳, 22:40
     
  6. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    I would be happy to get a response, want to understand how the spray VR works,
    In my scene sometimes it works sometimes no, only paints part of the area, and I could not understand from the documantation how it works exactly and what I am missing,
    thank you!
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The particle demo scenes apply paint whenever the particle hits something, so the distance is based on the particle speed and lifetime. This particle collision requires your objects to have colliders (e.g. MeshCollider). Keep in mind particles have a collision radius, so you may need to decrease this depending on your scene setup (or increase the paint radius).
     
  8. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    Thanks for the explanation!
    I have another question: in creating an object that can be painted, written
    Open the Window/Paint in 3D to the Scene tab, and click the Make Paintable button.
    i didnt find this button...where is it?
     
  9. Skylight2512

    Skylight2512

    Joined:
    May 3, 2022
    Posts:
    1
  10. regentenxing

    regentenxing

    Joined:
    Jan 4, 2022
    Posts:
    1
    Hello. We have a room full of static objects we'd like to paint. We're having difficulty painting some of the objects, though.

    We've tried attaching a Paintable to the object. This works, but the room has several tiled textures, and those don't paint properly.

    Then, we tried using the Overlay material. This does not work with static objects at all. Unity will complain about there being too many materials, and remove the Overlay, which stops PaintIn3D from working. You can recreate this in the "08 Overlay" scene by setting the horse statue as static.

    How do we successfully paint the room? We've checked the documentation, but haven't found anything on static batched objects.

    We are using PaintIn3D 2.0.2 and Unity 2019.4.38f1.

    Thank you!
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The documentation shows you where this button is HERE. It also tells you the requirements for the button to show.


    Don't make it static. Each paintable texture has its own unique material & textures, so it can't be batched anyway.
     
  12. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    Thank you very much for the answer, it helped me a lot and the asset is wonderful! now I want to create an invisible object, but when I paint it there are places that are not painted, mainly in the connection lines of the object,
    I would be happy to know how to fix this, thank you!
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Can you post a screenshot of the issue? It sounds like you need to enable the P3dHitScreen component's Advanced/Connect hits setting.
     
  14. GreaterHawkeye

    GreaterHawkeye

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

    I'm not sure if you could help me on this one but I got a weird issue when painting on my 3D model. This is definitely coming from either my code or the 3D model itself. Note that I'm using unity webgl if that could make any difference.

    When drawing on certain part of my model with a rather small brush thickness, the stroke seems to disappear at certain location.

    upload_2022-5-9_17-11-8.png

    Here on the right I made a stroke which looks correct, but on the left as you can see the stroke seems to disappear at certain location.

    My thought is that the hitbox are incorrect but I'm not sure. Our unity developer says it works well on Unity but in the webgl build I got this...
    I'm sending you the URL to test it out yourself as well as the .fbx, if you could take some time to take a look that would be wonderful, we are blocking on that for like 10 days now... :/

    Thank you very much
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It looks like you're using P3dPaintDecal, which has a maximum near/far paint distance defined by its Scale.z setting, and the fade range is defined by the Hardness setting. What's (likely) happening here is your visual mesh and collider mesh are different and there is some distance between these two surfaces, and on the left line the distance is exceeding the depth of the brush, so it's going out of range and fading out. So to fix this you can increase the paint depth, or adjust one of the meshes to be closer.

    You can attach the P3dPaintDebug component and check in the Scene view to see where the paint is being applied vs where the visual (paint) is being applied, and there should be a difference.
     
  16. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    Thanks, I will try that!

    On another subject, I just found out 2 issues I'm having:

    1) When I repaint on top of an existing line, the overlapping produces another color:
    upload_2022-5-11_15-33-47.png

    Here I painted with green decal and the overlapping produces blue.

    2) When using soft decals, the edges are yellow
    upload_2022-5-11_15-35-46.png

    For some reason, if I use a blue color there is no problem and if I use a white color the edges are blue instead of yellow

    Thanks for you help!
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Are you using the Subtractive blending mode, or a shader/material with some special blending mode?
     
  18. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    I don't believe so. Here are my settings:

    The Decal Tool
    upload_2022-5-12_11-0-26.png

    The 3D Model
    upload_2022-5-12_11-1-11.png
    upload_2022-5-12_11-2-6.png
    upload_2022-5-12_11-2-32.png
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
  20. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    It works fine on Basic Setup scene.
    We are using 2021.2.15f1
     
  21. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    Your answer in the forum is very helpful!
    I made some object like demo scene 15, but when I paint the texture repeated many times in small,
    Can it be changed?
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I just noticed your P3dpaintDecal component's Blend Mode / Channels.z is set to 5?! It should be 0 or 1.


    You can adjust the tiling scale/rotation/offset by dragging and dropping a GameObject (e.g. the current one) into the Advanced / Tile Transform setting, and then scaling that GameObject.
     
  23. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Hi,
    I need help in graffiti reveal.
    I want multiple graffiti on top of each other. I am trying it in sample scene. but its not working. When I change texture it erases the older graffiti.
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    What is your setup like? If you're using multiple materials with multiple P3dPaintTexture, then you must use different groups for each paint Groups for each texture, or change the paint groups in-game so you're only targeting one at a time.
     
  25. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    Hello - I am trying to use Paint in 3D to recolour some first person arms and weapons that I bought as an asset. However, after following the instructions I cannot get the paint to register on the mesh - the marks do not appear over the mesh when the cursor is there. I can get it working on primitive shapes like cubes and spheres by following the same instructions, but not on the asset.

    I do not know why it is not working, as there are no error signs. The paint just won't appear under the cursor.

    Any help or ideas would be greatly appreciated.

    Here are the screen shots of my set up:

    upload_2022-5-13_14-46-55.png

    And here are the properties for the asset (the FPS arms and weapon come as one game object):

    upload_2022-5-13_14-48-50.png
     
  26. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    To clarify, I am trying to get it working in Editor mode, but I also tried in Runtime mode, and it also didn't work.
     
  27. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    Here are the properties for model I am trying to paint:

    upload_2022-5-13_15-10-58.png
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    What does your mesh look like in the Mesh Analysis window? It sounds like it may not be UV mapped, and therefore not directly paintable.
     
  29. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    In the mesh analysis it says that there are no vertices in the UV section. You cannot see any mesh.

    When I had a look in Blender, for the gun part of the model, the UV map was actually positioned above the texture that was displayed. Could this be something to do with the model having two textures/materials - one for the gun and one for the arms?

    I originally tried retexturing the model in Blender, but when I exported it back into Unity, the armature was all messed up so the animations did not work. Which is why I tried using Paint in 3D instead.

    Is there a solution to the UV problem?
     
  30. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Kindly explain it more.I am new to this tool.
    My setup is simple. Sample scene "75 Reveal Graffiti" is being used. Its working fine.
    Now I want to add another graffiti.
    Like masked painting in layers. Layer 1 back texture, Layer 2 another texture, Layer 3 another texture on top of each other.
    I am digging into documentation. I want to be more specific related to my project instead of learn everything.

    I want to paint textures like this.
    upload_2022-5-14_12-3-20.png
     
    Last edited: May 14, 2022
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Many low poly meshes are UV mapped like this, where the UV data is collapsed onto a single pixel to give it a color. However, this cannot be painted. To be paintable it must be UV mapped so each triangle actually has some UV area (i.e. be mapped to multiple pixels).

    Paint in 3D comes with some ways to work around this as detailed HERE, this requires using a different shader though.


    I see. It sounds like you want to use the Mask or Local Mask features (see the demo scenes by these names). These features allow you to define a texture shape that restricts where you can paint. You would have to use a custom script to swap out the paint color, and mask texture/GameObject as needed.
     
  32. GreaterHawkeye

    GreaterHawkeye

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

    Thanks for your previous post it was very helpful!
    I'm stucking again on another subject though :oops:

    I'm trying to apply an already made texture to a 3D model then paint on the model.
    I've successfully managed to apply the existing texture but then I cannot paint on the model.
    All MeshCollider, P3DPaintable, P3DPaintableTexture and P3DMaterialCloner are on the model.
    P3DHitScreen is also on the tool gameobject.
    But it doesnt allow me to paint on the model anymore.

    I'm pretty sure this has to do with the way I apply the already made texture:

    Code (CSharp):
    1.  public void CreateModelFromMetadata(Metadata data)
    2.     {
    3.  
    4.         foreach (TextureData texture in data.textures)
    5.         {
    6.             Texture2D tex = new Texture2D(512, 512);
    7.             tex.LoadImage(Convert.FromBase64String(texture.textureBase64));
    8.             model.parts[texture.name].GetComponent<SkinnedMeshRenderer>().material.SetTexture("_BaseMap", tex);
    9.         }
    10.  
    11.     }
    Do you have any clue on that?

    Thanks again!
     
  33. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Is it possible to use splat painting in mask?
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You must call the P3dPaintableTexture component's Replace method with your new texture. Directly replacing the material's texture will make P3dPaintableTexture not do anything anymore as you won't be able to see the painted texture.

    The masking feature works with all other painting modes.
     
  35. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    I tried that without luck, am I missing something?
    Code (CSharp):
    1.  foreach (var part in model.Value.parts)
    2.             {
    3.                 P3dPaintableTexture paintableTexture = part.Value.GetComponent<P3dPaintableTexture>();
    4.                 paintableTexture.enabled = true;
    5.                 paintableTexture.Replace();
    6.  
    7.                 P3dPaintable paintable = part.Value.GetComponent<P3dPaintable>();
    8.                 paintable.enabled = true;
    9.  
    10.                 MeshCollider collider = part.Value.GetComponent<MeshCollider>();
    11.                 collider.enabled = true;
    12.             }
     
  36. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Kindly help me with this one. When I replace texture manually from editor "P3dPaintableTexture" this happens.
    My requirement is previous texture should stay and next texture should be painted on top of previous texture. Anim.gif
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You need to pass your texture to the Replace method as an argument, otherwise it will use the texture set in the Texture setting.

    Keep in mind Replace (and all other methods) only works after the texture has been activated. If it's not activated yet then you could just set your texture in the paintable texture's .Texture setting, then it will use it when it activates (assuming the texture slot has no texture, in which case you also need to set .Existing to Ignore).


    I have no idea what I'm looking at or what it's supposed to look like. Please explain in greater detail exactly what you want to have happen.
     
  38. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    73
    Hi - thank you for the info - it all works now with your help :)
     
  39. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    I want this output after paint.

    Not like this.
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It's still not clear what you want. You want to begin with the graffiti on the wall, and then paint the masked white splat shape behind the graffiti?? If so, you could use the AlphaBlendInverse blending mode, or set up two material layers and using the Group system you can restrict painting.
     
    tahir_ali likes this.
  41. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Its just idea that I want to achieve in my game. Kind of makeup type thing on characters. I will make my own textures that will reveal like this during painting.
    Game flow will be like this:

    Start with empty wall
    Then reveal/paint 1st texture.
    After 1st texture completion. 2nd texture will be reveal/painted over 1st texture.

    Issue: You can see in above mentioned gif. After revealing first texture. 2nd Texture does not reveal on the top of 1st texture. 1st texture gets erased when I paint 2nd texture.

    I hope now you understand what I want to achieve. Its like make up. start with 1st layer of makeup then 2nd layer of makeup then 3rd layer and so on. In the end final output.
     
  42. LiamVisionary

    LiamVisionary

    Joined:
    Apr 2, 2020
    Posts:
    48
    Hi, I'm trying to figure out how to paint blood on zombies with my own gunfire raycasts, instead of using the p3dhitscreen component. What would be a good way of going about this? I've already set up my zombie identically to the one in the zombie blood example scene.
     
  43. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    Okay, I've tried few things but with no luck.

    Here is the code:
    Code (CSharp):
    1.     public void CreateModelFromMetadata(Metadata data)
    2.     {
    3.         foreach (TextureData texture in data.textures)
    4.         {
    5.             Texture2D tex = new Texture2D(512, 512);
    6.             tex.LoadImage(Convert.FromBase64String(texture.textureBase64));
    7.             model.parts[texture.name].GetComponent<SkinnedMeshRenderer>().material.SetTexture("_BaseMap", tex); // I apply the already made texture here
    8.             Texture baseMapTexture = model.parts[texture.name].GetComponent<SkinnedMeshRenderer>().material.GetTexture("_BaseMap");
    9.             model.parts[texture.name].GetComponent<P3dPaintableTexture>().Activate();
    10.             model.parts[texture.name].GetComponent<P3dPaintableTexture>().Replace(baseMapTexture, Color.white); // not sure if I should use Color.white here
    11.             model.parts[texture.name].GetComponent<P3dPaintableTexture>().Existing = P3dPaintableTexture.ExistingType.Ignore;
    12.         }
    13.  
    14.     }
    I still cannot paint my model. :-/
    As a reminder, I want to apply an existing texture on my model then being able to continue painting afterward.

    I am surely doing something wrong but I'm not sure where?

    Thank you very much for your patience.
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I understand now.

    There are multiple ways to do this. The simplest way that requires only one paintable texture is:

    1) Begin with the "Reveal Graffiti" demo scene setup.
    2) Add the P3dMask component to the Wall_Outline GameObject.

    When you finish painting the current layer, you must:
    1) Swap the Wall P3dPaintableTexture's Texture to your new graffiti texture.
    2) Swap the Wall_Outline P3dMask's Texture to your new graffiti texture.

    If you need the graffiti outline to appear then you should also update the Wall_Outline MeshRenderer's Material to your new outline.



    Check out the "79 Paint From Code" demo scene.


    If you set your texture in the material before it gets activated, then Paint in 3D will automatically read this texture if Existing = Use or UseAndKeep (the default). Therefore, if you set this texture beforehand as you are there, and then set Exiting = Ignore as you do, then there's no point of setting the texture in the first place, because it will get ignored.

    Also, you probably don't want to activate the paintable texture directly like this. If you want to manually activate it, you should first activate the P3dPaintable, which will activate the P3dMaterialCloners first (very important).

    So basically here's what you should do:

    a) If your paintable texture is activated already, then call Replace(...) and nothing else.

    b) If your paintable texture is not activated yet, then set the material's texture as you are there, and let the paintable texture use this texture when it later activates.

    You can check the paintable texture's Activated setting to decide which to perform, and then wrap this all in a simple method that you can call any time.
     
  45. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Awesome. Thanks for the help!
     
    Darkcoder likes this.
  46. Deiran

    Deiran

    Joined:
    Aug 6, 2014
    Posts:
    6
    Hey!
    Would it be possible for a P3D Paintable to "expect" a certain color? As in, a certain model expects to be painted blue, but when painted yellow the part of the texture that is colored in a wrong way gets highlighted (i.e. a red outline of the yellow color). I've tried wrapping my head around it but to no avail :(
    Thanks!
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can use the P3dChangeCounter to see if the user has painted the expected color. However, changing the painted color to red when an unexpected color is painted would require custom logic, which is most easily done using a custom shader. For example, your shader could read the current _MainTex, as well as a reference _ExpectedTex, and you compare the pixels. If they are outside of the expected range, then you instead output red.
     
    Deiran likes this.
  48. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    Hello,
    Is there any way to make the paintin3d overlay shader to act like unlit. Because when I am using the paint in 3d overlay it is interacting with the directional light thus resulting in a blurry vision of my textures with details. I am using replace original to reveal this material
     
  49. atul20032006

    atul20032006

    Joined:
    Jan 6, 2019
    Posts:
    4
    Hi, we have been trying to do a game, but on entering the play mode, the FPS use to be at 30 FPS, but as soon as any paint is applied, the FPS drastically reduces to 1/4 of the normal. We tried everything and every way to optimize, but failed.
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    No, there are no unlit versions of the example shaders. I'll add this to my to-do list and they will appear in the next version.


    Without any information about what you're painting, what you're painting it with, how often it's being painted, what optimizations you've tried, etc... there's no way I can help you.