Search Unity

Paint In 3D ️️✏️ In Game & In Editor & Skinned Mesh Painting

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

  1. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11
    Hi! I wanna couple of question of Paint in 3d Shader.

    Is it possible to using Paint in 3d asset another Shader? (Mobile diffuse or Legacy)
    and I want to edit Paint in 3D Shader[P3D Solid],
    How to add specular edit slot in P3D Solid?

    Thank you.
     
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Yes, any shader can be used as long as it uses the mesh UV data.

    The P3D Solid shader implements the metallic workflow (SurfaceOutputStandard), which has no specular setting. You must implement the specular workflow to get it. I didn't do this because metallic is the default, most people use it, and I don't want to write and support two versions of the same shader. You will have to modify the shader to use SurfaceOutputStandardSpecular, and change the metallic settings to specular.
     
    ejj8048 likes this.
  3. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11
    Thanks to reply!
    I'll checking on my project

    have a nice day:)
     
    Darkcoder likes this.
  4. hage02

    hage02

    Joined:
    Jul 16, 2019
    Posts:
    2
    Do you have an example of this package working with SteamVR? The VR example "VR HVLP" I cannot get working on the Vive Pro.
     
  5. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11
    It's worked! Thanks!
    But one more question, Is it possible Using Mask Component to Skinned mesh modeling?
     
  6. maulikhack

    maulikhack

    Joined:
    Oct 3, 2018
    Posts:
    10
    Hi! Is there a way I could invert this alpha mask? the goal is to fade out the colors outside of this mask. upload_2021-1-29_12-24-36.png
     
    Last edited: Jan 29, 2021
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    The VR examples are for Unity's built-in XR system only, using my own wrapper. To make it work with another system you must look at the P3dVrTool components I set up, and replicate the event calls yourself. Here's the VR Pen setup:

    upload_2021-1-29_19-16-44.png

    As you can see, all you need to do is find equivalent Grab and Drop events from your VR system, and make them perform these two actions, and it will work.


    Yes, all the masking features work the same for skinned meshes too.


    There's currently no option to invert a mask. If you don't mind it being global you can modify "PaintIn3D/Shared/Resources/Masking.cginc" line 24 to be: return 1-dot(....
     
    ejj8048 and maulikhack like this.
  8. atul20032006

    atul20032006

    Joined:
    Jan 6, 2019
    Posts:
    3
    @Darkcoder first of all, it's the best asset I had ever purchased from the asset store :). A question I had got, is there any way to do thread paint simulation ? , Such as : drawing lines with varying thickness based on time, using colliders as a mask ?
     
    Last edited: Feb 1, 2021
  9. Sapien_

    Sapien_

    Joined:
    Mar 5, 2018
    Posts:
    69
    Hey the documentation and online tutorial don't match the new interface. How am I supposed use this? I have 1.9.14 I want to put a decal on a skinned mesh T-shirt (not in gameplay but editor).
     
    Last edited: Feb 1, 2021
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Not sure what 'thread paint' is. You can adjust the P3dPaintSphere/Decal component settings over time using a custom script easily enough. There's no built in way to do this except for finger pressure using the paint modifiers, but that's a bit different.


    I'll send you a new build in a bit.
     
  11. Sapien_

    Sapien_

    Joined:
    Mar 5, 2018
    Posts:
    69
    Hey this might have been a mistake on my end but I got this error

    Copying assembly from 'Temp/com.unity.multiplayer-hlapi.Runtime.dll' to 'Library/ScriptAssemblies/com.unity.multiplayer-hlapi.Runtime.dll' failed

    Okay I can paint but when I add a custom texture it doesn't use it to paint. Its invisible.
     
    Last edited: Feb 1, 2021
  12. dannyoakley

    dannyoakley

    Joined:
    Jun 18, 2016
    Posts:
    11
    Hey @Darkcoder I currently have a VR setup where a user can place a decal on a surface. Now I'm trying to sync the decal placement across multiplayer. I looked at the multiplayer example and the paint from code example. Basically, I'm trying to sync the properties in the HandleHitPoint function. I'm using P3DHitBetween for my raycast and can't figure out how to get the vector3 position and the quaternion rotation from P3DHitBetween to supply to HandleHitPoint. Am I going about this the wrong way? Any help would be appreciated. I'm using Normcore for multiplayer if that makes any difference.
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Those errors are unrelated to P3D.

    As for your custom texture, I have no idea. I need more information about your setup.


    The P3dPaintMultiplayer component used in this example listens for the HandleHitPoint and HandleHitLine events, which give you the position, rotation, etc. You must then transmit this data over the network so you can manually call the HandleHitPoint/Line methods when you receive this data. Take a look at this example component code to see how it works.
     
  14. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    103
    Hello, Can you tell me how can I change p3dblendmode from script ? I tried following

    Code (CSharp):
    1.             P3dBlendMode dBlendMode = new P3dBlendMode();
    2.             dBlendMode.Index = 9;
    3.             p3D.BlendMode = dBlendMode;
    But after that Im not able to paint anything
     
  15. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    103
    Nevermind I figured it out I forgot to set channel.
     
  16. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11
    Well, I tested my skinned meshes modeling, It's doesn't work:(
    More infomation please?? follow the example(It's 61,62 right?), Doesn't help from me:(
     
  17. melksnis

    melksnis

    Joined:
    Sep 30, 2020
    Posts:
    8
    Hey there! I am considering buying this asset and the question is will it work for me. I am making a car fixing and tuning game and I want to add ability to paint the car , I know that I can make simple script to change color of car part but that is boring, SO will I be able to paint in runtime like in that wheel painting clip. I mean I have open world and I stumble upon a spray paint can , take it and paint my car or anything I see ( or there are drawbacks like heavy on hardware or I need special materials applied to object before? )
     
  18. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    103
    Yes you can
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    You can also use the camel cased methods like: P3dBlendMode.NormalBlend(Vector4.one);


    Examples 61 and 62 work fine for me? Even if I add a skinned mesh into that scene. Maybe your skinned mesh doesn't have colliders that line up with the mesh? Maybe your mask isn't the right size? I need more information.


    Yes this can be done exactly as you describe with minimal overhead (just the extra texture memory required for the uniquely painted object, and draw call for the uniquely different material). You will of course have to write the code to combine your existing game with some kind of special car painting mode, but the examples that come with the asset should make this quite easy.
     
  20. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11


    Sorry My english so awful.
    Anyway, I want editing only face my skinned mesh. add mask componant into face mesh, and alpha(png) texture into texture slot and play -> [ Nothing happened ]

    Was I something missing?
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Can you show me screenshots of what you currently see, what you expect to see, and your current component setup with settings?
     
    ejj8048 likes this.
  22. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11

    hierarchy.PNG

    View attachment 789449

    Thanks! Here's images
    I added to face mesh using mask, Is it right?
     
    Last edited: Feb 5, 2021
  23. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    What does the girl_mask texture look like? And is the mask data stored in the alpha channel?

    You should also place the mask on its own GameObject, so you can rotate and scale it without changing your skinned mesh.
     
    ejj8048 likes this.
  25. Rav_2511

    Rav_2511

    Joined:
    Feb 5, 2021
    Posts:
    1
    Hi Darkcoder,

    This asset looks awesome and amazing that we would like to buy and implement into our application for webgl but we are unsure if it will work. will this plugin be able to extract and save the decal position, rotation, scale in runtime for database purposes and if it's URP/HDRP Compatible.
     
  26. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11

    View attachment 790085
    [girl_mask] Texture data like this! (mask texture, uv based) and yes! It's stored alpha channel!
    Before to using mask editing, add component from parent hierarchy and child( [mask]Face_Girl )?
     
    Last edited: Feb 8, 2021
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Yes all pipelines are supported. The "67 Simulated Multiplayer" demo scene shows you how to intercept and send hit position/rotation/etc information. This same idea can be used to record and restore paint in a multiplayer scenario.

    If you want this mask to be in world space, then you should use the P3dMask component on a new separate GameObject. You can scale+position it and see the size in the Scene window. I recommend you modify the "62 Stretch" demo scene with your mask so you can see it working.

    If this is a texture mask that matches your UV map then you can use the LocalMask feature:

    upload_2021-2-6_21-54-41.png

    See the "73 Local Mask" demo scene for an example.
     
    ejj8048 likes this.
  28. ejj8048

    ejj8048

    Joined:
    Oct 16, 2018
    Posts:
    11
    Thanks!! I'll test it and let you know
     
    Darkcoder likes this.
  29. wiganda

    wiganda

    Joined:
    Feb 24, 2018
    Posts:
    14
    Cool asset so far based on all the samples, but I was wondering, I'm now making a unity game in 2D mode. Can paint 3d be used when unity is in 2d mode? I need to draw blood splatter decals onto a flat 2d background texture and have them become a single texture so I don't end up with 1000s of separate decals all over the background eating up memory (ie; I want to paint/merge all the decals onto the background texture so in memory only a single texture remains, as every frame or couple of frames I will deactivate the used decals and then later reuse them using a pool manager). If possible in 2D also, then which demo sample should I use as reference?
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Unity's 2D mode is basically just 3D mode, but with an orthographic camera, and usually using SpriteRenderers. While Paint in 3D doesn't support painting SpriteRenderers, you can still combine normal 3D objects in your scene with SpriteRenderers, and have it work fine. Therefore, to get this to work you just need to add some flat 3D objects (e.g. using Unity's built-in Quad mesh), and you can set this up to paint as you normally would. Perhaps I should make a demo scene for this :D
     
  31. wiganda

    wiganda

    Joined:
    Feb 24, 2018
    Posts:
    14
    Thanks for the reply. Would be great if you could make a demo scene of this, especially if it contains a sample of which method to use to paint unlimited decals (then reuse them) onto a single texture so memory usage does not increase :) As I'm still not sure how to basically 'snapshot' a number of decals onto a texture during runtime, as I then want to disable those decals for reapplying to the texture in other positions again later. I'm assuming this is what paint 3d is doing (minus the decal pooling).
     
  32. melksnis

    melksnis

    Joined:
    Sep 30, 2020
    Posts:
    8
    Hello! just bought the asset. I will use it on my car game to pain complex cars. The problem is I have for example a dark or black car I want to paint yellow or other colour and it turns out dark or is not possible at all. The solution I found was to use a transparent material in front of original one. Is there a way to really change the colour of my original paint?
     
  33. Andefob

    Andefob

    Joined:
    Sep 17, 2018
    Posts:
    42
    Hi! I quick comment about blend modes...

    Currently additive and subtractive modes add all components and otherwise ignore alpha. For my use, I would like alpha to matter for other components, too. So I made the mofifications to BlendModes.cginc as below (adding color.a to everthing). I guess there was no out-of-the-box way to achieve the same effect?

    Code (csharp):
    1.  
    2. #elif BLEND_MODE_INDEX == 3 // ADDITIVE
    3.     current += color * strength * color.a;
    4. #elif BLEND_MODE_INDEX == 4 // ADDITIVE_SOFT
    5.     current += color * strength * (1.0f - current) * color.a;
    6. #elif BLEND_MODE_INDEX == 5 // SUBTRACTIVE
    7.     current -= color * strength * color.a;
    8. #elif BLEND_MODE_INDEX == 6 // SUBTRACTIVE_SOFT
    9.     current -= color * strength * current * color.a;
    10.  
     
  34. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    249
    Hello, I just notice the texture quality of the paintable texture is a lot lower than the original texture, even tho the paintable texture size is set at the same resolution, once it is activated the texture will be replaced by one at lower resolution.

    Do you know what is the problem here?
    Thank you
     
    Last edited: Feb 26, 2021
  35. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,662
    I've made a spray painter with the HitBetween and PaintSphere components. It works pretty well, except for one thing: when I spray near an edge of the model, it paints the triangles facing me, and the triangles which are facing away.

    Is there any way to make it exclude the triangles which are facing away? I would think something like a normal test: if the triangle normal is more than 90° away from the HitBetween line, don't apply paint.

    This would make it so that you can spray one face of a box, without paint leaking over to the neighboring face (as long as it is facing away from the spray can).
     
  36. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    112
    I believe you'll need to call the Resize method which is pretty straight forward.
     
  37. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    249
    Hi, thanks. Which resize method?
     
  38. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    112
    Hi there. Resize() is a method of the component P3DpaintableTexuture.
    For example:

    Code (CSharp):
    1.             P3dPaintableTexture paintScript = GetComponent<P3dPaintableTexture>();
    2.             paintScript.Resize(4096, 4096, true);
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Sorry for the late replies!

    Yes, you must make your car's material white, and instead make the default color of the texture black/red/etc. This is how the car windows work in the "Car Decals" demo scene. You can select the "Chassis" GameObject and change the P3dPaintableTexture component's Color setting to Red or something to see it work like you want.


    The design is for you to adjust the Opacity value in the P3dPaintDecal/etc components. The problem with your approach is that it's no longer possible to add or subtract alpha values as expected, and some blending modes like normal painting use the alpha for the data itself, which is why I made this separate opacity value.


    Does this issue also occur with the latest version if you set all the advanced settings to auto?


    You can use the P3dPaintDecal component for this with the Normal settings. If you set a circle shape and set Wrapping to 1 then it will look like P3dPaintSphere, but with more options.
     
    JoeStrout likes this.
  40. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,662
    @Darkcoder can you explain how "Hit Spacing" works on the HitBetween component? I expected that when I apply the brush (i.e. switch Preview off), it would immediately hit wherever the brush is, and then not hit again until the hit point moved at least that distance.

    But what I'm observing instead is: when I apply the brush, usually no paint at all is applied. Only after I move some distance do I get a hit at the new location.

    Have I misunderstood how it's supposed to work? Is there any way I can reset the internal spacing data when I apply the brush, so that I'm guaranteed to get a hit right away?
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    It's possible I made a mistake and so it doesn't paint on the first frame your finger/mouse goes down, when it should.

    I'm currently rewriting the way P3dHitScreen and the hit connection stuff works to more easily allow for more advanced tools. If it still doesn't work in the next update please let me know!
     
    JoeStrout likes this.
  42. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,662
    OK. To be clear, I'm using P3dHitBetween, not P3dHitScreen (this is a VR app). And I'm applying the brush by changing Preview from true to false — I wonder if that's not the correct way to do it.

    Also, since you're rewriting the hit system: another thing I want to do is make animated brushes, where each hit applies a decal chosen randomly from a set of textures. Perhaps I could get a UnityEvent when the HitBetween is about to apply a hit, giving me a chance to quickly change the shape? This would also enable me to provide audio or haptic feedback as paint is applied.
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    I see, I'll check it out.

    Regarding random textures, you can use the modifier system on each P3dPaint___ component for this, the Texture/Random one should do it.

    upload_2021-3-4_23-37-6.png
     
    JoeStrout likes this.
  44. DreamGameBD

    DreamGameBD

    Joined:
    Aug 15, 2018
    Posts:
    3
  45. DreamGameBD

    DreamGameBD

    Joined:
    Aug 15, 2018
    Posts:
    3
    How to paint textures onto objects (2D or 3D) and calculate percentage covered?
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    The "47 Channel Counter" and "48 Percentage" and "50 Change Counter" demo scenes show you how to do this depending on your setup!
     
    JoeStrout likes this.
  47. melksnis

    melksnis

    Joined:
    Sep 30, 2020
    Posts:
    8
    Hello! I have one more question, (tried to figure out but maybe there is already a simple solution) I want to know if my raycast hits paintable material - I have to repair deformed mesh and it has 3 materials, one of them is paintable, I want to affect mesh part that is not paintable in raycast hit point. Should be something -- if (hit point texture== paintable )
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    You can call .GetComponent<P3dPaintable>() on your hit collider to see if it's paintable. If your object is split up like an atlas then you can check for P3dModel, and then read its Paintable. If you want to know if a specific texture is paintable then you can read the P3dPaintable's PaintableTextures property.
     
    JoeStrout likes this.
  49. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    105
    Hello,

    I wanted to let you know that using the latest 2019.4.21 LTS Unity version, and HDRP (after trying in another project, it seems that it also happens with built-in renderer), Paint in 3D seems to cause quite a few crashes, when using it to paint in-editor. For example when clicking on the material button of the paint in 3D window, or when clicking on the +Preset button. Because I'm on a fairly large project, restarting Unity every time is SUPER frustrating as it takes a long time, I think I have lost 30-40mn, maybe even an hour, just restarting Unity today. Hopefully you can fix that...
    Because of all of these, I can't seem to get anything painted in Editor.

    Thank you !
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    2,711
    Can you check your editor log (Unity - Manual: Log Files (unity3d.com)) and see if it tells you what's going on? The +Preset button searches the project for presets, and this might be causing your system to run out of memory if your project is big. If this is the issue then I may be able to create an alternative search method that doesn't use as much memory.
     
unityunity