Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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,390
  2. LegacySystem

    LegacySystem

    Joined:
    Jan 28, 2021
    Posts:
    52
    Hi,
    I am having a really wierd bug. I am trying to paint a car with custom shader. Car consists of 3 part: door, baggage and, body (at least where the bug occurs). All 3 part has different mesh, different material (but same shader with same parametres). Everything seemed fine at firest. the decal I want paint is visully correct most of the time. but when you look on some spesific angle to even though decal is very far evey (for example on door), baggage still has decal on itself. I checked the painted texture: Baggage and the door has 2 different render texture with different ids. But decal is present on both of them. I moved the baggae to a far away place hoping maybe mesh's border was broken some how but decal stays there. But again, only if you look on spesific angles. I checked the mesh and there a no surfaces overlapping bopth on 3D space and on UV. They all use different materials. Whe whould I look in such a case ? What could have been the problem. These are the screen shots:


    Door and baggage that are highlighted has different mesh and materials. It can be seen that decal is painting all of them correctly.
    upload_2023-3-28_11-34-34.png

    When I moved decal to different position and stand back a little still fine.
    upload_2023-3-28_11-35-59.png

    but when I get closer this happens:
    upload_2023-3-28_11-36-18.png


    Last 2 image has nothing cahnged but the camera position.

    This is baggage decal texture: upload_2023-3-28_11-37-14.png

    this is doors:
    upload_2023-3-28_11-37-33.png

    When I moved the baggage very far away. It is still there.
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    Hard to say. Is it possible for you to prepare a really simple demo scene to demonstrate this, and send it to me via private message or email?
     
  4. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    Hi,
    I used the Fixed Seams tool on the clothes and still have Seams, and I can see the red text With No UV with Mesh Analysis.

    How can I fix this problem
     

    Attached Files:

  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    It's hard to tell what's happening without seeing the full setup with the mesh. Could you send me a private message or email of just the clothing so I can test it?
     
  6. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    OK,I just sent you an email, the model file is too big, so I put it on Google cloud, please help me to look again
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    The issue is that these parts of the mesh aren't UV mapped:

    upload_2023-4-3_10-0-30.png

    If you switch the Mesh Analysis to Mode = Triangles, you can see the "With No UV" triangles marked in red on the right. These are the same as the unpaintable areas you can see on the left when erasing the alpha on a seam fixed mesh. You must fix the UV map so that these triangles have some UV area/pixels. Right now these triangles are UV mapped to be flat/squashed, so there are no pixels there to paint.
     
  8. Tu-Le

    Tu-Le

    Joined:
    Jun 5, 2015
    Posts:
    14
    Reveal Graffity demo error on some Chiniese device(Oppo,Vivo). How can i fix it?
     

    Attached Files:

  9. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    I asked ChatGPT, can use "Smart UV Project" or "Unwrap".
    Or use "Mark Seam" "Clear Seam" red line those commands are not repaired, are still With No UV
     

    Attached Files:

  10. Tu-Le

    Tu-Le

    Joined:
    Jun 5, 2015
    Posts:
    14
    i just find out their devices use GPU powerVR GE8320
     
  11. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    Hi,
    I'm new to 3D software, so I asked ChatGPT how to repair cloth fix seams
    ChatGPT Reply me If you're fixing clothes in Blender and you encounter the issue of having no UV map, you can follow these steps:

    First, select the clothing mesh you want to fix. In Edit mode, select all faces (press A to select all), then press the space bar and search for the "UV Unwrap" command.

    In the UV Unwrap command menu, choose the "Smart UV Project" option. This will automatically generate a UV map for your mesh.

    Once the UV map is generated, you can view and edit it in the "UV/Image Editor" editor. Use the selection tool or select individual faces and map them to the appropriate positions.

    When you have finished all of the UV mapping, you can export your mesh in Blender. In the export options, select the appropriate format and make sure that the UV map is included in the export options.
    Follow up or fix fails
     

    Attached Files:

  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    I don't have any device with this GPU so it's hard to say. Can you try different Graphics APIs like Vulkan, OpenGLES 3, etc, and see if it changes anything?


    I'm not a blender expert so I don't know. The result there maybe looks ok though. If you're using the seam fixed mesh, then make sure you go back to the seam fixer and click Generate again to update it.
     
    Tu-Le likes this.
  13. kMasakiK

    kMasakiK

    Joined:
    Aug 11, 2018
    Posts:
    7
    Can I paint on animated objects using the skinned mesh renderer? The zombie decal sample seems to do it, but my 8-legged creature doesn't. Is there a solution?
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    If you can paint the zombie then of course. The issue with your object could be many things though. Does it work if you put your creature in the zombie demo scene? If you click Analyze Mesh, is your mesh UV mapped properly?
     
  15. kMasakiK

    kMasakiK

    Joined:
    Aug 11, 2018
    Posts:
    7
    In Mesh Analysis, Overlap is 0% on UV1 but I can't paint well, I am using a second UV in Generate Light Map UV.
    Can you give me a sample with a simple skinned mesh like the 01 Basic Setup sample?
     
  16. kMasakiK

    kMasakiK

    Joined:
    Aug 11, 2018
    Posts:
    7
    I emailed you because it is difficult to determine the cause of the problem.
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    The "Zombie Blood" demo scene shows you how a skinned mesh can be painted. Although this uses the first UV channel, it would basically be the same if you used the second UV.
     
  18. InnFillGame

    InnFillGame

    Joined:
    Oct 28, 2021
    Posts:
    1
    upload_2023-4-25_19-14-26.png
    I use this way of painting and I want to create particles in that place that I am painting. Can I take the point where I am currently drawing?
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    Take a look at the code for the P3dPaintDebug component. This shows you how to detect hit points, lines, triangles, and quads.
     
  20. linenum

    linenum

    Joined:
    Nov 16, 2020
    Posts:
    56
    Hi, I have a shader using Shader Graph that has two color parameters to make random colored clothing and skin. I want Paint in 3D to modify it in MainTex for blood.

    If I use a CustomRenderTexture then the shader can be put into the MainTex.
    Code (CSharp):
    1. public class CubeTex : MonoBehaviour
    2. {
    3.     public Shader shader;
    4.     void Awake()
    5.     {
    6.         Material mat = new Material(shader);
    7.         Color randomColor1 = Random.ColorHSV();
    8.         Color randomColor2 = Random.ColorHSV();
    9.         mat.SetColor("_Color1", randomColor1);
    10.         mat.SetColor("_Color2", randomColor2);
    11.  
    12.         CustomRenderTexture crt = new CustomRenderTexture(16, 16);
    13.         crt.initializationMaterial = mat;
    14.         crt.initializationSource = CustomRenderTextureInitializationSource.Material;
    15.         crt.initializationMode = CustomRenderTextureUpdateMode.OnLoad;
    16.         crt.material = mat;
    17.  
    18.         GetComponent<Renderer>().material.SetTexture("_MainTex", crt);
    19.     }
    20. }
    But when I add P3dPaintable, etc, it results in a black RenderTexture in the MainTex though it is paintable.
    Code (CSharp):
    1.         GetComponent<Renderer>().material.SetTexture("_MainTex", crt);
    2.         gameObject.AddComponent<P3dPaintable>();
    3.         P3dPaintableTexture paintableTexture = gameObject.AddComponent<P3dPaintableTexture>();
    4.         gameObject.AddComponent<P3dMaterialCloner>();
    5.         paintableTexture.Filter = P3dPaintableTexture.FilterType.Point;
    When I've attempted to convert the CustomRenderTexture to Texture2D it has also resulted in black textures. Any thoughts?
    BTW this talks about CustomRenderTextures and making new textures:
    https://forum.unity.com/threads/customrendertexture-shortcomings-for-making-new-texture.987432/
     
    Last edited: Apr 28, 2023
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    I've never used CustomRenderTextures so I can't say, perhaps hey don't work in this scenario. You should be able to use a normal RenderTexture and initialize it with your material using the Graphics.Blit method.
     
  22. linenum

    linenum

    Joined:
    Nov 16, 2020
    Posts:
    56
    The link I mentioned said CustomRenderTexture "waits until the beginning of a frame to update, even when Update() is called on it in script"

    So I tried this:
    Code (CSharp):
    1.     public Shader shader;
    2.     void Start()
    3.     {
    4.         GameObject[] cubes = GameObject.FindGameObjectsWithTag("cube");
    5.         foreach (var cube in cubes)
    6.         {
    7.             StartCoroutine(SetupMainTex(cube));
    8.         }
    9.     }
    10.     IEnumerator SetupMainTex(GameObject cube)
    11.     {
    12.         Material mat = new Material(shader);
    13.         mat.SetColor("_Color1", Random.ColorHSV());
    14.         mat.SetColor("_Color2", Random.ColorHSV());
    15.         CustomRenderTexture crt = new CustomRenderTexture(16, 16);
    16.         crt.initializationMaterial = mat;
    17.         crt.initializationSource = CustomRenderTextureInitializationSource.Material;
    18.         crt.initializationMode = CustomRenderTextureUpdateMode.OnLoad;
    19.         yield return null; // wait until next frame
    20.         RenderTexture rendTex = new RenderTexture(16, 16, 0);
    21.         Graphics.Blit(crt, rendTex);
    22.         rendTex.filterMode = FilterMode.Point; // pixelated
    23.         cube.GetComponent<Renderer>().material.SetTexture("_MainTex", rendTex);
    24.     }
    And it seems to work...
     
    Last edited: Apr 30, 2023
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    Blit has many overloads, at least one of which takes a Material. You can also.pass null for the Texture.
     
    linenum likes this.
  24. Korimaru88

    Korimaru88

    Joined:
    Jul 24, 2015
    Posts:
    17
    Hi, is it possible to replicate a "max" blend mode for P3DPaintDecal? I need to replace pixels darker than my draw color while leaving the brighter pixels as they were.
     
  25. zullo91

    zullo91

    Joined:
    Nov 1, 2013
    Posts:
    14
    Hello,
    I know the application is called Paint 3d and its main purpose is for the 3d world.
    But I was thinking if it was possible with this package, to be able to create a 2d coloring book application.
    The essential feature would be to be able to color the selected part without coloring the others, so that it would help to color the parts of the drawing. This is to make coloring in the drawing easier.
    Do you think this is possible ?
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    There's no feature like this yet, but I can add it in the next version. I'll see if I can send you an early build later today.


    Paint in 3D can (currently) only paint 3D Skinned/MeshRenderer. Therefore, to paint a 2D coloring book you would have to make it in 3D. Depending on how you want the book to work, this can be very easy to do though, because 2D sprites in Unity are basically just 3D objects.
     
    Korimaru88 likes this.
  27. zullo91

    zullo91

    Joined:
    Nov 1, 2013
    Posts:
    14
    Yes. I saw your mask demo scene, where i can draw texture color only inside a shaped mask. I think are you not using SpriteRender. Is it possible to have a simple 2D draft scene where you draw texture inside the border of a sprite ? I really appreciate if you could show me.
    But yes it think that the coloring book app could be developed with your package.
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    As I said, there is no way to paint SpriteRenderers right now. You can only paint MeshRenderers. Luckily, they're more or less the same and all 3D, so you can convert your book into MeshRenderers (e.g. using the quad mesh), and you will be able to paint it.
     
  29. nanana099

    nanana099

    Joined:
    Feb 28, 2023
    Posts:
    5
    Hey, this asset is really nice. I want to make the painting function to work in VR. But when I test the VR Pen Scene and VR HVLP Scene, it does not work on my Oculus. It does not work as a 3D object on my Oculus VR, it is just the 2D object like a picture that can move along with the camera. Please help me
     
  30. SolarisGameStudios

    SolarisGameStudios

    Joined:
    Dec 17, 2021
    Posts:
    1
    Hey there, is there a way to scale up decal/paint sphere over time?
    What I'm trying to achieve is this effect (01:31)
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    The example VR controls were designed for Unity's old XR system. I recommend using a different system, like some kind of proper VR asset. You just need to replace the P3dVrTool components with the components from another system, and you can see the P3dVrTool events to see what you need to enable/disable for the tool to paint the scene. In the future I will look into updating them to the new XR system.


    To make an effect like this you could paint a texture with a soft alpha, and then over time increase the alpha (requires a custom shader + Graphics.Blit over time) so it bleeds out when rendered with a cutout shader. Alternatively you could store the paint hit points, and re-apply the hit with increasing radius for some limited time.
     
  32. dzungchaos

    dzungchaos

    Joined:
    Apr 13, 2021
    Posts:
    7
    Anyone know how change the brush to a rectangle instead of a circle (sphere) as default? And how to detect the percentage of the painted area compare to the initial state of the mesh?
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    The P3dPaintDecal component can be used without a shape/texture, and it will be a box. You can use the Size setting to adjust its size.

    The P3dChangeCounter ("55 Change Counter" demo scene) can be used to detect how many pixels you modify compared to a texture state you specify.
     
    dzungchaos likes this.
  34. jesseclark

    jesseclark

    Joined:
    May 28, 2023
    Posts:
    2
    Hello. I bought the toolkit and love it. I am wondering if I can paint with materials other than the matte colors that are standard with the toolkit. Can I paint using alternative materials through the P3D Paint Sphere component? Whenever I try and change the 'Group' properties the drawing doesn't appear on the model at all. Is there a way to achieve other finishes? Thank you so much for any help.

    -Jesse C.
     
  35. dzungchaos

    dzungchaos

    Joined:
    Apr 13, 2021
    Posts:
    7
    Thanks for you quick reply.

    I'm now creating a game that does not use mouse or touch to paint on the model. Instead, the player has to control a character to paint the plane underneath him. Does the package support this or do you have any idea to solve this problem? Thanks in advance.
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    To paint a 'material' you must paint multiple textures at the same time, like albedo + normal + specular. This requires you to set up multiple P3dPaintableTexture components with unique groups, and multiple P3dPaintSphere/Decal components with matching groups. The "PBR Painting" demo scene shows you how to do this with the provided Solid shader.


    The P3dHitScreen component uses the mouse/fingers, but P3dHitNearby, P3dHitBetween etc don't, so depending on your game you can use a different hit component. There are demo scenes for all of these (e.g. "32 Between Painting").
     
    dzungchaos likes this.
  37. dzungchaos

    dzungchaos

    Joined:
    Apr 13, 2021
    Posts:
    7
    Many thanks!

    About the "P3dChangeCounter", I set up a plane with that Component like this (Fig 1). But when I play and clean some of the dust on the plane like Fig 2, the Parameter "Count" remains the same and does not change a bit. Could you pls help me figure this out?
     

    Attached Files:

  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    What if you set this 'dust' texture in your P3dChangeCounter's Texture slot? You're currently comparing it to pure white.
     
    dzungchaos likes this.
  39. dzungchaos

    dzungchaos

    Joined:
    Apr 13, 2021
    Posts:
    7
    Thanks! You've really saved my day! :D
     
    Darkcoder likes this.
  40. jesseclark

    jesseclark

    Joined:
    May 28, 2023
    Posts:
    2
    Thank you so much for answering my question. It was so helpful. I have one more question:
    Now that I am able to draw with more than one material... I can't get the eraser tool (aka replace original) to erase both materials. It only erases the first material, leaving the second material unchanged. How can the replace original tool used to edit both materials at once? Thank you! <3
     
  41. Pentacles

    Pentacles

    Joined:
    Nov 6, 2021
    Posts:
    2
    Hello !
    I use your asset and it's... actually really incredible ! Love it so far (at least, I love it)
    Unfortunatly, my girlfriend (aka the artist of my project) really want to make a smoothing effect like in photoshop :
    The mouse movement were very similar, it's just the smoothing parameter of photo who modified the line

    I did have take a look at your scripts, but I admit I'm a little lost.
    I use P3D Paint Sphere to paint, so should I look over it to make a smooth effect ? Or maybe P3D Pointer Mouse ?
    I guess it should be somewhere HandleHitCommon ?
    Hopping you can help me, at least giving me the direction to look ...

    Thank you already for the original asset trough ! (And sorry for my bad english)
     
  42. unity_35LXbGadtojGAA

    unity_35LXbGadtojGAA

    Joined:
    Feb 15, 2022
    Posts:
    2
    I have a query regarding a particular scene in '12 Connect Hits'.
    When the 'Radius' attribute of 'P3D Paint Sphere' is set to its default value of 0.025, I notice that the lines are drawn seamlessly, without any gaps, which is satisfactory.
    Yet, when I decrease the 'Radius' (for example, to 0.0025), the output seems to resemble a series of dots instead of a continuous line, thus creating undesired gaps.
    I aim to draw thin, uninterrupted lines. Could you kindly provide some guidance on how I might achieve this?
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    Sorry for the late replies!


    The P3dPaintSphere/Decal component can only paint one paint group at a time that you specify. If your material uses multiple paintable textures each with their own group then you need to configure one P3dPaintSphere/Decal per group, and set the groups to match up.


    To implement a 'smoothing' setting like this you must modify the mouse/finger input code. In the latest version of Paint in 3D this is implemented in the P3dPointer components, specially P3dPointerMouse and P3dPointerTouch. As you can see, these components just directly send the mouse/finger position data in Update, so there is no smoothing. So you would have to record a history of positions, and apply some type of smoothing before you send the data.



    This is because when you use a value of 0.0025, the line becomes thinner than each texel/pixel on the object. If you increase the resolution of the spaceship's texture to 4096 then the lines draw as expected again.
     
    unity_35LXbGadtojGAA likes this.
  44. unity_35LXbGadtojGAA

    unity_35LXbGadtojGAA

    Joined:
    Feb 15, 2022
    Posts:
    2
    I solved the problem by setting the Size of the P3D Paintable Texture to a higher resolution!
    Thank you very much!
     
    Darkcoder likes this.
  45. HM201

    HM201

    Joined:
    Jan 4, 2022
    Posts:
    3
    Hello, I hope all is well.

    I would like to ask a few questions about the asset to ensure it fits my project correctly. I am creating a VR multiplayer game and I thought I would use some blood textures and paint them on some skinned mesh renderer networked enemies that the players can shoot at and see the blood painted etc...
    My question is: is this asset a right fit for what I aim for? I mean painting the enemy character with every bullet any player fires or would it be to performance intensive? will networking all this be fine as well?

    All the best.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    This is a texture painting asset, so there is overhead to applying paint, but there is no added overhead to painting many times. Conversely, a traditional decal system has little overhead to applying paint, but the performance degrades based on the amount of decals in view. Therefore, it sounds like it may be suitable for your game.

    There is no networking built into Paint in 3D, but assuming your shooting mechanics are networked then it shouldn't be an issue to apply blood decal painting to your bullets. However, making the blood match exactly on each client would be difficult and require a lot more effort to sync the painted textures, etc.
     
  47. unity_PzcQaN0SoqgUZg

    unity_PzcQaN0SoqgUZg

    Joined:
    Jan 4, 2019
    Posts:
    2
    Hello, thank you so much for your amazing asset!
    In one of your examples (Chalk Board) I saw that it is possible to show a paint preview of the brush radius when hovering over the chalkboard which is done by the preview attribute in P3D Hit Particles. Is it also possible to show when using touch as an input? I want to show the paint radius of the spray can (from your spray can example) when moving over my canvas. Maybe this is an adjustment in P3D Pointer Touch?
    Thank you very much in advance!
     
  48. HM201

    HM201

    Joined:
    Jan 4, 2022
    Posts:
    3
    Thank you for your swift reply, I have one more question though. I want to add detail to my decal, like adding a normal map to it for example instead of just the albedo. is there a workflow in the asset for that?
    should I just use multiple P3d paintable texture components?
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,390
    Yes, this would require modifying the P3dPointerTouch code. When designing this component I made the assumption that fingers can only touch the screen, not hover. You can see the P3dPointerMouse code for how to send preview information, which is basically just sending finger information with a finger ID of -1.


    Yes, you must configure one P3dPaintableTexture per texture type you want to be able to paint (e.g. Albedo + Normal), and then you can paint them with corresponding P3dPaintDecal components, one for each. These are linked up using the Group system, which supports any type of texture slot. The "PBR Painting" and "Rock Engraving" demo scenes show how this can be done.
     
    unity_PzcQaN0SoqgUZg likes this.
  50. shahryarsheikhwork

    shahryarsheikhwork

    Joined:
    Oct 17, 2022
    Posts:
    3
    Hello, thank you so much for your amazing asset!
    I had a question related to the asset as I am in a situation where I want to paint the pixels having alpha greater than 0.i have been looking for a way out but it is turning out hard for me to figure out it will be great if you help me out. Thankyou so much.

    for example :
    upload_2023-7-21_12-10-48.png

    this is the image and when painting i only want to paint white pixels (alpha 1) and ignore the pixels with 0 alpha (boxes)