Search Unity

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

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

  1. Nctrung2001

    Nctrung2001

    Joined:
    Jan 4, 2021
    Posts:
    4
    Help me! I want to change paint color runtime, but it not working.
    My code:

    Code (CSharp):
    1. [SerializeField] Color[] colorTrails;
    2. [SerializeField] P3dPaintDecal decal;
    3. [SerializeField] int _sNumber;
    4.  
    5.     void Update()
    6.     {
    7.             decal.Color = colorTrails[_sNumber - 1];
    8.     }
     
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    What happens?
     
  3. Nctrung2001

    Nctrung2001

    Joined:
    Jan 4, 2021
    Posts:
    4
    I have a ball, can change color by material, running in the path, I want to draw a line by the collision of the ball and the path and change the color like this:
    upload_2022-4-7_21-24-18.png
     
  4. brazzoni

    brazzoni

    Joined:
    Sep 2, 2021
    Posts:
    13
    Hey! does anyone know if the shaders in this asset work with light probes? Trying to draw on a piece of paper that will be mobile. Can't use any realtime lights.
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I mean what happens with your code? It looks fine to me.

    They should work with all standard features that other lit shaders have.
     
  6. Nctrung2001

    Nctrung2001

    Joined:
    Jan 4, 2021
    Posts:
    4
    I don't know, I use that code, it change color in inspector, but not draw anything in the scene
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Changing the color setting won't paint anything, it will only change the color of decals you paint after that.

    The color property code doesn't do anything special:

    upload_2022-4-8_10-51-15.png

    Therefore your code should work fine.
     
    Nctrung2001 likes this.
  8. Nctrung2001

    Nctrung2001

    Joined:
    Jan 4, 2021
    Posts:
    4
    Thanks for your reply! I found the problem, all colors have 0 alpha
     
    hopeful and Darkcoder like this.
  9. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
    EDIT: Please ignore me. I'm a moron. I had the tool set to 'decal' instead of 'pen'.

    Leaving this here in case there are other window lickers out there like me.

    Greetings. I am unable to paint by clicking and dragging. I can only click and apply the color and texture like stickers. What am I missing that I can't click and drag to paint? I'm using Unity 2020.3.28

    I have the following components on the GameObject:
    • P3D Paintable Texture
    • P3D Material Cloner
    • P3D Paintable
    Thank you for your help.


     
    Last edited: Apr 8, 2022
    hopeful and Darkcoder like this.
  10. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    It helps when people explain what they misunderstood. You can bet others are making the same mistake. :)
     
    Darkcoder likes this.
  11. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Hi Carlos,

    I'm considering purchasing this asset but wanted to ask a question. In my game I have a tower that will be hit by magic projectiles. Instead of decals I was considering this painting asset. The target platform is mobile iOS (iPhone 6 lowest end device).

    The idea is that each hit that is not blocked that impacts the tower would leave a mark where the hit occurred. I will split the tower into multiple sections since it is quite tall and I don't want to render the whole thing where only 1/5th of it is visible. This means multiple textures mapped to the tower sections that are combined together to form the whole tower. The hit frequency average would be pretty low (eg. if missed 1 per second).

    Do you think that performance wise this asset would be able to handle this scenario and not cut too much into h/w resource budget? Also if the hit should happen on a seam of two sections of the tower, will the respective textures for the two sections be painted correctly?

    Regards,
    Tom
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The painting performance depends entirely on the resolution of the textures being painted, and how many times you paint per frame. Based on your description this would be minimal, so there shouldn't be any performance issues. Indeed, two separate sections will be correctly painted if you hit between them.

    To super optimize this you could even paint a low resolution splat map, and then use a custom shader to replace this with some kind of destruction/damage detail texture that is high resolution.
     
  13. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thanks. Just purchased it :). I'm intrigued about your optimization suggestion. But am not sure I completely understand. So the splat map would be what get's painted by your asset and since it is low resolution it would be optimal? And the shader would then use the high resolution texture and paint it instead? Or am I completely out to lunch?
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    It's just a potential optimization should you need it, similar to how painting a terrain is painting splat maps that then get replaced with detail textures that look better. You can try painting normally at first and see how it goes.
     
  15. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Hi @Darkcoder !!

    I am interested in buying your asset. But I would like to know first if it works for HDRP 12.x as we start a new project on Unity 2021 LTS and later.

    I await your response, greetings.
     
  16. Direful

    Direful

    Joined:
    Feb 9, 2020
    Posts:
    18
    Hi @Darkcoder I just purchased your asset yesterday and it's really great!
    I do have a question i would like to ask you.
    Is there another way (more effecient way) to paint in an array of positions other than calling HandleHitPoint() in a for loop?
    I was thinking maybe doing it directly in the compute shader by passing the array of positions but i dont really know how to do it though or if it's possible.
     
  17. ryan_unity372

    ryan_unity372

    Joined:
    Jun 29, 2021
    Posts:
    8
    Hello,
    I'm interested in your flow system to create paint drips, such as used in the dripping paint example. How could I go about making the drips more pronounced and longer? Ideally, I would like to be able to pour paint onto a mesh, and have the drips appear.

    Thanks,
    Ryan
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The core painting functionality works on all pipelines and versions of unity from 2019.4+. The demo scenes use custom shaders though which may not support everything, but they do support HDRP 12.x.

    Calling HandleHitPoint in a loop is fine. The only faster way is to directly add commands to the P3dPaintableTextures, but this is more difficult. Unless performance is an issue and you've already implemented all the other strategies, I wouldn't bother.

    Pouring paint over the mesh sounds like fluid dynamic/simulation, which is far beyond the scope of what this asset is designed for. You can modify the Dripping Paint demo scene settings to make the drips longer. For example, the second P3dGraduallyFade componentshave the Speed setting, which controls how fast the flow is, or how fast the flow stops.
     
    ftejada likes this.
  19. Direful

    Direful

    Joined:
    Feb 9, 2020
    Posts:
    18
    Can you elaborate more on how to add those commands? Im planning to use quite a lot of randomly generated positions at runtime for my massive procedural levels. So far i've tested around 200 positions and it's quite heavy to do it in a normal for loop. I'm trying to get atleast around 500 positions if that's possible to achieve.
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    When you call HandleHitPoint, it searches the scene for paintable objects within range, finds the textures that will be painted, and then builds a P3dPaintCommand for each. This command contains all information about the paint. You can hook into the P3dPaintableTexture component's OnAddCommand event to see what a command looks like, or the P3dPaint___ component's HandleHitPoint code. If you build your own you can call the paintable texture's AddCommand method.
     
  21. Direful

    Direful

    Joined:
    Feb 9, 2020
    Posts:
    18
    Owh nice! Thanks so much for the explanation & fast response!
     
    shansajusaho and Darkcoder like this.
  22. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    upload_2022-4-15_20-13-1.png I am developing a painting game. I would like to know how to make 3d masks like this. I tried to put my mask game object with some holes in it as this image on top of my paintable game object. But when painting it still paints through the top game object which is used as a mask. could you suggest a solution for this please?

    please refer to this video at 1:22
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    You need to configure an actual mask (P3dMask component, "66 Mask" demo scene). In this scenario you would also need to carefully position it so it only covers the underlying object, allowing you to fully paint the 'mask' object on top.
     
  24. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    I tried, But in 66 its using a sprite to mask. in this game they are actually doing it with a 3d object sticker covering it. I would like to achieve that. also when painting with objects z scale less than 1 the paint passes through the gameobject and shoots through that game object. so The sticker case is not working here. When I paint on to of the sticker the sticker is getting painted but the paint goes through inside. I used paint between transforms, paint with particles, etc, but no use. I used points in 3d to paint. in this senario could you pelase suggest a detailed way to achieve this mask property
     
    Last edited: Apr 16, 2022
  25. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thanks I’ll investigate this.
     
  26. thorgaming_42

    thorgaming_42

    Joined:
    Sep 25, 2015
    Posts:
    13
    Hi Carlos,

    Hope you are well, I just bought your asset seems brilliant so far, with so many example use cases I wondered how you might approach this scenario.

    In my game you can slice glass shapes in real-time into tiny pieces, I was thinking of using the painting system to show the face that has been sliced on the newly created objects. I just thought you might have some advice how to create the best visual effect.

    I want the game to be quite visually stunning which is why I use the Space Graphics Toolkit also!! :D I included a picture so you can see the shader from the glass shapes. I am thinking something with transparency like the glass has been cut by a hot sword. Also is you think this might be better done in the shader itself thats fine, I wanted to get Paint in 3d for another project anyway.

    upload_2022-4-16_15-43-29.png
     
  27. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    I tried, But in 66 its using a sprite to mask. in this game they are actually doing it with a 3d object sticker covering it. I would like to achieve that. also when painting with objects z scale less than 1 the paint passes through the gameobject and shoots through that game object. so The sticker case is not working here. When I paint on to of the sticker the sticker is getting painted but the paint goes through inside. I used paint between transforms, paint with particles, etc, but no use. I used points in 3d to paint. in this senario could you pelase suggest a detailed way to achieve this mask property. Please help me to achieve this.
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    As I said, this is achieved using the P3dMask component. You must specify a mask texture, which can be done beforehand when you create this mask mesh, or at runtime using a setup similar to "91 Dynamic Mask". There's no way for the paint to directly know what your mask mesh looks like while it's painting, so your mask mesh itself is irrelevant - it's all visual tricks.


    I don't know what the 'best' visual effect is for this scenario, because there are too many possibilities. If you know where the slide edges are, then using a custom script you could call a P3dPaintSphere component's HandleHitLine method with the start and end points of the line. This could be used to paint an emission texture on your glass, so the edges glow? Maybe you could use P3dGraduallyFade to make the glow fade away?
     
  29. meatmania

    meatmania

    Joined:
    Dec 12, 2013
    Posts:
    2
    Hi. I bought this asset and am satisfied. By the way, I have a question.

    I'm trying to make something dirty and wipe off the mesh.

    Can this asset cover multiple layers of dirt? I checked that there are layers, but it feels a little different from what I wanted.

    I was wondering if it would be possible to assign multiple materials to a mesh and paint for each material.
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Yes, you can add multiple transparent materials on top of your base 'clean' opaque material. As long as you configure each layer to have its own P3dMaterialCloner and P3dPaintableTexture then it will work. Just keep in mind to paint each layer separately they will either need their own unique Group setting which you change on your paint tools to match, or you use a custom script to swap the Group setting of each P3dPaintableTexture layer based on the current layer you wish to paint.

    I experimented with this before and found that multiple transparent layers didn't work in HDRP (don't remember about URP), so I didn't include this as an example scene, but if your using BiRP then it should be fine.
     
  31. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    upload_2022-4-18_23-40-47.png
    Hello,
    I tried to paint using a mask. This is the result. I tried using png, and vector images as well. but this problem like pixelated result still persists. I need a smooth lines and outer curves. This is done using the separated cube along with paint in 3d package. also Tried using many other models.
    I think its not the problem of models because the painting works perfectly fine only the problem when using the sprites for mask.
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Use a smoother mask image? You can blur it for example.
     
  33. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    Thankyou for Replying,
    I tried all way @Darkcoder but not working. as the game is for mobile painting game. the edges need to be crisp. Can you suggest any way? I think the problem is the sprite image is having high resolution. but when I assign it to the p3Dmask script the quality is getting decreased. Hence painting a low quality image.
     
    Last edited: Apr 19, 2022
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The final paint quality depends on the resolution of your paintable texture, and the way your UV map is designed. To make a crisp edge you must either increase one of these, or use a different shader technique like cutout to make the edges crisp.
     
    shansajusaho likes this.
  35. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Hi, it must be a silly question, but how can I check (with a boolean variable or something else) if my mouse is over a paintable model ? I want to change my cursor only when the mouse is on a paintable object but I don't know how I can detect it... And another silly question, I want a allow painting when the user has found colors in the 3D world, so how can I activate or disable my painting tools ? Thank a lot if you can help me !
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    1 - You would have to perform a raycast under the mouse/finger position, then check to see if the hit collider (or its parent, etc, depending on your setup) has the P3dPaintable component.

    2 - It depends on how your game works. If you're using the tool buttons in the Paint in 3D examples, then you can activate the tool's UI button when you find it in game, or something.
     
  37. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Thank you very much !
     
    Darkcoder likes this.
  38. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Hello!
    I am struggling with Saving/Loadung my texture:(
    Here is what i am doing (simplified):
    Code (CSharp):
    1. internal sealed class Test
    2. {
    3. public P3dPaintableTexture PencilTexture;
    4.  
    5. public void SaveData()
    6. {
    7. var paintedTexture = PencilTexture.GetPngData();
    8. var data = new SaveDataClass(paintedTexture);
    9. //save file
    10. SomeClass.Save(data):
    11. }
    12. public void LoadData()
    13. {
    14. var data = SomeClass.Load<SaveDataClass>();
    15. //trying to get my saved texture
    16. PencilTexture.LoadFromData(data.paintedTexture);
    17. }
    18. }
    My problem is i can't understand how to deserialize my texture back and assign it to my object.
    Can anyone please help me?
     
  39. ryan_unity372

    ryan_unity372

    Joined:
    Jun 29, 2021
    Posts:
    8
    Thanks for this. What would be the best method to have it so that upon a particle hitting the surface, one paint source leaves a permanent splat, while the second will leave the longer drip effect?

    I've found a setting I like for the long drip length, but it fades out the further it travels, similar to the Paint Fade Away Over Time scene in the demo. Is there any way to make the trail permanent? Thanks again for your help.
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Looks fine, assuming 'SomeClass' and 'SaveDataClass' are implemented properly. If not, I can't really help you because this has nothing to do with painting.


    The "Dripping Paint" example works by making the paint 'flow' down for a time after you paint it. This 'flow' is basically smudging/blurring the paint in a specific direction, which causes the paint to look like it's fading a bit. It sounds like you basically want to eliminate this blurring effect, but that's quite difficult.

    One way to achieve something close is to set up two textures: one is the current flow texture setup, and the other is a normal albedo texture with the initial paint splat. You would then use a custom shader to combine the two textures together.

    There are other approaches like actually simulating paint thickness and making it physically flow down, but that's very difficult to implement.
     
  41. Wuna

    Wuna

    Joined:
    Nov 4, 2015
    Posts:
    7
    Hello, I've been using this PaintIn3D for a few months now. It's really helpful, thank you.

    I've got a question. I'm currently stuck in a problem right now. I'm trying make this application to paint using particle on base_map, metallic_map, and detail_map. It works fine on editor and pc build for Oculus Rift S. But the P3dChannelCounter for base_map doesn't seems to work properly for me after I build it to Oculus Quest.

    The white text counter for base_map got stuck on 100 on Oculus Quest (I don't know how to take a screenshot on quest).
    upload_2022-4-20_16-15-12.png
    The red counter for metallic_map and blue counter for detail_map seems working fine thought. I can't seems to fine the problem myself.
    Can you help me with it? Thank you very much!
     
  42. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    nevermind, i figured it out! Found your class and read it thoroughly: everything works fine now!
    for the future reference, if someone stumbles with that like me:
    you should check when you load your data accordingly to when class P3D Paintable is activated.
    I was loading my data in class constructor on class initialization, but my P3D Paintable activation was set to "Start". So my TempTexture was created after i tried to assign new values to it. Hope it will help someone:)
     
    Last edited: Apr 20, 2022
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Can you send me (via email or private message) a unitypackage containing the mesh with this issue, and a really simple demo demo scene with all the P3dPaintable components configured? Then I can test it on my end and see if I can debug & fix it.


    Aha. Yes you can use the P3dPaintable component's OnActivated event to detect when it activates. Most of the methods won't do anything unless it's been activated.
     
  44. dcwolf1991

    dcwolf1991

    Joined:
    Oct 15, 2019
    Posts:
    2
    Hello!
    I just bought the asset and my question is, there is any way to use it on unlit material?
    I want to get a similiar result as in the game called The Unfinished Swan.
     
  45. Ercova

    Ercova

    Joined:
    Oct 21, 2019
    Posts:
    4
    Hello @Darkcoder . I have a question. I try to paint some objects and count the paint ratio with p3dChangeCounter.
    I can color and get the ratio with every color except White. When the color is white the objects can be paintable but the counter not increasing. What could be the problem. Thank you so much.
    BTW i changed Threshold etc.
     
  46. dcwolf1991

    dcwolf1991

    Joined:
    Oct 15, 2019
    Posts:
    2
    Found the answer! :D Overlay.. :')
     
    Darkcoder likes this.
  47. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    Hello,
    Thanks for the replies. I would like to know how to apply smudge effect with paint in 3d.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Check out the Liquefy demo scene.
     
  49. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    Thank you for the response. Will update you
     
    Darkcoder likes this.
  50. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    Hello, Do you have a tutorial on how to use this asset for VR?
    thank you