Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. 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. MagicK47

    MagicK47

    Joined:
    Sep 5, 2017
    Posts:
    30
    Hello, the version of the plug-in I use now is 1.5.3. Unfortunately, I have modified some code of the plug-in so that I can not update to the latest version, because it is inconvenient. Now I have a problem that when I move my finger or mouse quickly, the brush will draw a little separated circle instead of a straight line. How can I fix this problem? I see that the latest version of the plug-in will not have this problem.
     
  2. MagicK47

    MagicK47

    Joined:
    Sep 5, 2017
    Posts:
    30
    Hello, the version of the plug-in I use now is 1.5.3. Unfortunately, I have modified some code of the plug-in so that I can not update to the latest version, because it is inconvenient. Now I have a problem that when I move my finger or mouse quickly, the brush will draw a little separated circle instead of a straight line. How can I fix this problem? I see that the latest version of the plug-in will not have this problem...
     

    Attached Files:

  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Version 1.5.3 of Paint in 3D still has this ability. If you're painting in-game, then the P3dDragRaycast.DragStep setting allows you to control the pixel distance between each paint when you drag the mouse/finger. If you're painting in the editor, then Painting tab > Drag Step allows you to control this.
     
  4. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    325
    @Darkcoder

    I just tested the transparency bug I was having with the replace blend mode.

    When using a paint decal component with a decal that is using a texture with its alpha source set as input from texture alpha, and the shape as the circle 50 image. Transparency is lost (filled with white) when the only group being painted on is the paintable objects _MainTex property.

    I am not sure if the white filling in where there should be transparency is from circle 50 or from the source texture. The expected behavior would be for transparency to be preserved.

    (Only seems to happen when using the MainTex, setting it to a group is important to replicate).
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Can you post a picture of your settings and textures? I don't think there's any issue with the Replace blending mode, perhaps I just didn't explain what it does clearly enough in the documentation.

    Replace will Lerp between the current surface RGBA value and the RGBA value of your paint Texture, using the Shape's alpha channel as the Lerp weight. If your paint texture is transparent, then the fully transparent pixels (A = 0) will potentially have unexpected RGB values such as white. The "Decal 3" texture for example of the duck has the "Alpha Is Transparency" setting enabled, which causes the edge of the transparency (A > 0) RGB color to be stretched to the edges of the texture, which in this case is white. This means painting this duck texture using the Replace blending mode with the "Circle 50" shape results in the transparent parts of the duck being drawn as white as expected, because those are the RGB values outside of the main duck shape.
     
  6. MagicK47

    MagicK47

    Joined:
    Sep 5, 2017
    Posts:
    30
    Hello, when I use the brush, because our need is not to use the position of the finger or mouse to spray, but to spray with the center of the screen, so we call the paintat method in update, when the unit camera moves too fast, there will be intermittent points, can not be connected into a straight line, I set dragstep to 0, so how to solve it?

    Hello, I found a problem, that is, to keep the logic of spraying with the mouse or finger, and then move the camera while spraying, there will be intermittent situation. If you don't go to the mobile camera, you won't have this problem. Is there any way to paint while moving the camera?
     

    Attached Files:

    Last edited: Dec 29, 2018
  7. Jacky_Boy

    Jacky_Boy

    Joined:
    Dec 8, 2013
    Posts:
    95
    I'm ready to buy this! One question though for the developer ( @Darkcoder), or someone who knows if this is possible, but I definitely want the developer's response as well: Can you create a trigger event once someone paints within a certain boundary on the surface mesh? For example, lets say I made a game where I make the user paint on a mesh, but once they paint in an area that I've made into trigger area, then the paint changes color, or an object spawns. Can I do this using this Paint in 3D app?
     
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Sorry for the incredibly late reply!

    There's currently no feature in Paint in 3D to fix the painting gaps in your scenario. I plan to include a new painting method that paints between two points without any gaps, and this could be used in your scenario to fix the issue. Implementing this is a little tricky though, so I will have to experiment a little before I can release it.


    There's currently no feature like this, and it sounds like something very game specific so I'm not sure if there ever will be. However, you could implement it quite easily using the P3dSpawner component and a little bit of code. P3dSpawner works like P3dPaintDecal and other painting components, except instead of painting it spawns a prefab at the hit/paint location. For this prefab you could use a kinematic rigidbody that is set up to only trigger your triggers, and then you run your special code when you detect this trigger entry.

    If you can describe a scenario where this would happen and other users might find it useful in a demo scene then I could make it though.
     
  9. wesley_unity341

    wesley_unity341

    Joined:
    Dec 14, 2018
    Posts:
    9
    Congrats on a really nice, clean implementation that does almost everything it claims. I have a question: Once I have painted a texture, if there a simple way to clean it? I.e paint to the same UV-coords with say completely transparent? I don't appear to have been able to get this to work so far. Thanks

    A few more details: Using the spray paint test scene for setup. I have a Skinnable Mesh that I am painting. This mesh has UVs for the standard albedo texture in the mesh. I just generated the skinned mesh collider every frame for testing. Object has 3d Paintable Texture, 3d Paintable and Material cloner on it. I am using UV 0, group 0, ARGB32 texture for painting.

    Second thoughts: How about just a secondary, pre-made overlay texture for the current model that can be alpha'ed out to reveal the primary diffuse texture?
     
    Last edited: Jan 25, 2019
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Thanks.

    1 - To clear a texture you can call the Clear( ... ) method on the specified P3dPaintableTexture. It would probably make sense to add an additional component that can store this initial texture + color state, and clear it when requested. This way there would be no code required.

    2 - This sounds similar to the "Overlay" and "Overlay Cutout" materials that are in Examples/Materials, and are used in some of the demo scenes. Simply add these as the second material to your model, set the P3dMaterialCloner + P3dPaintableTexture to use material index/slot 1, and it should work.
     
  11. kmsjkh

    kmsjkh

    Joined:
    Jan 31, 2016
    Posts:
    14
    hello . thank you for your good asset.

    but i have some problem

    my project have a lot of objects, meshs
    they don't have uv0 data, so i have to do Coord Copier myself
    it's realy boring works
    i have to do Coord Copier, darg mesh to mesh filter one by one..

    i wanna ask you , do you have tool to do this things.
    select object and do coord copier to all of child objects
     
  12. kmsjkh

    kmsjkh

    Joined:
    Jan 31, 2016
    Posts:
    14


    i write code about this myself

    https://drive.google.com/drive/folders/11uZVeWtXOEWJmX6xe8Vm3x_qk5cOQAf_?usp=sharing

    to do this, i had to change some codes of this asset.
    this code is poor, but it works

    this codes support doing coord copier, fix seam object and childs of that.
    also moving 'worked mesh' to mesh filter is supported .
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This sounds like a good idea. I could combine both tools and allow them to convert multiple meshes, and also automatically replace references or something.
     
  14. kmsjkh

    kmsjkh

    Joined:
    Jan 31, 2016
    Posts:
    14
    thank you for replying
    maybe there is a lot of people want this tool like me
     
  15. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I just updated from 1.6.1 to 1.6.4 and ran into a problem. My pre-existing P3d scenes are now giving this error:

    "NullReferenceException: Object reference not set to an instance of an object PaintIn3D.P3dPaintableManager.UpdateAll () (at Assets/PaintIn3D/Scripts/P3dPaintableManager.cs:68)"

    There is no error when playing a loaded scene directly. This only occurs when loading the scene via
    SceneManager.LoadScene().
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This will be fixed in the next version, I'll send you an early build in a little bit.
     
    JohnnyFactor likes this.
  17. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi @Darkcoder
    Could you make multi layered system for paint decals ?
    When i select a decal layer that i was painted before, i can delete it immediately !
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I'm not sure I understand, you can already create a multi-layered painting system by using multiple materials, as long as each layered material is transparent. I don't think any of the example scenes demonstrate this though, that's something I should fix!
     
  19. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Sorry for my comment. I mean,
    Example:
    When you paint decal A to the car, decal A will save to the X list.
    When you paint decal B to the car, decal B will save to the X list.
    ....
    When you paint decal N to the car, decal N will save to the X list.

    Decal A, B,...N can show to the UI. And user can select decal B, or D to remove it from car paint texture.

    I think X list that save decal A, B, ... N like decal layer system that user can select any decal to remove it or reuse it.
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I see, this requires you to store a list of all painted decals, and to repaint the object using this list every time you make a modification. This can be tricky to implement depending on your scene setup though. I plan to make a demo scene showing how to do this, but I currently have quite of lot of other tasks to do first.
     
  21. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    While testing with different game resolutions, an issue has come up. The P3dPixelCounter values change with the screen resolution. I'm using downsampling and I'm assuming that mipmapping is also accounted for. What am I missing here?
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Game resolution should have no impact on the pixel counter, and mip maps aren't used for this. However, it may impact the way paint is applied if you use the P3dDragRaycast/Smooth component, because different resolutions will have different pixel densities and such, so the calculations will differ slightly. How much of a difference are you noticing? And in what scenario is this an issue?
     
  23. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    Yes, I'm using the P3dDragRaycast/Smooth. What's happening is my if-then code is checking pixel counts:

    Code (CSharp):
    1. if (innerFabric.GetComponent<P3dPixelCounter>().TotalR > 13000)
    2. {
    3.     fabricDone = true;
    4.     spoolCheck.GetComponent<MeshRenderer>().enabled = true;
    5. }
    On an iPhone 8 Plus it works great, but on an iPhone 5S it fails to reach the pixel count. On an iPad Pro 12.9 it triggers too soon. The difference is about 15% or 2,000 pixels in the example above.

    Edit: Sorry, just regular P3dDragRaycast, not Smooth.
     
    Last edited: Mar 9, 2019
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    That sounds like quite a difference, are you sure each object has visually been painted the same amount? What components are you using to do the painting? You can also display the final textures on screen or similar to see where the extra pixels might be coming from. You can also try painting a simpler mesh and gradually add complexity to see at what point the differences start to appear.
     
  25. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I'm using the P3d Paint Decal component and I traced this down to the "One Sided" option. Changing that to 0 brought the pixel numbers much closer together, and changing the depth from 0.1 to 100 makes them identical but I guess that's to be expected. My guess is that polygons at oblique angles to the camera cover wildly varying pixel amounts, depending on the screen rasterization. That would also explain why painting around the edges was unreliable.

    With a bit of geometry tweaking, this is now solved. Thanks for your time and help with this.
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Ah, dual sided painting can indeed easily result in unexpected pixels being painted. For the next version I have rewritten the dual sided painting implementation to make it hopefully be clearer and a bit more flexible. The main scenario where the pixel counter can fail is if you have triangles inside your model, because it's still possible to paint them depending on where you paint your model, but externally it will be impossible to see if you painted these triangles or not.
     
  27. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    If I have a bunch of unique meshes that all use the same material with their own dedicated UV place, can I get away with not having to clone the material for each object? If I have to add material cloner on all objects it wouldn't be good for performance I assume.
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    In this scenario you should set up one object with P3dPaintable + P3dMaterialCloner + P3dPaintableTexture, then in the P3dPaintable.OtherRenderers list you can drag and drop all your others in, then add the P3dModel component to all the others, and then link the P3dModel.Paintable to the first P3dPaintable.

    There are some obvious limitations to this, like the 'OtherRenderers' must exist at the time the material is cloned, otherwise you must manually copy the cloned material over after you spawn a new other renderer. Also that you can't delete the original paintable object, but you could make some kind of dummy object to handle this.

    Also keep in mind the painting performance depends on the size of your texture, so depending on your game you might get better performance by splitting the UV up for each object so they all use smaller textures.
     
  29. Ementrix

    Ementrix

    Joined:
    Aug 25, 2018
    Posts:
    1
    Hey Darkcoder, great plugin!

    It seems I have an issue where a custom texture I'm painting is blurred/resampled with every new stroke I made. The older the stroke the more it get's blurred and blurred. If I set the paint texture to unfiltered it doesn't do it so I guess it has something to do with the custom texture being reinterpolated with bilinear blurring.

    I'm using fairly small textures to paint on but it still shouldn't do that right?

    Maybe I'm just missing a setting somewhere? (I'm painting in editor/scene view btw)

    I see you posted on a similar issue a page back in the thread and found a solution for it, is that part of the latest build on the unity store?
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This shouldn't happen, but there might be scenarios where it could. I need much more information, like: what size textures are we talking about? Which exact version of Unity? Which build platform do you have set? Which paint settings are you using (like paint technique and blend mode)? What texture format are you painting?
     
  31. YoungJLee

    YoungJLee

    Joined:
    Dec 4, 2018
    Posts:
    6
    Hello! I already wrote few emails, but thought if there's anybody out there who has same problem as me, thought it'd be helpful to write in the thread instead.
    So I successfully made the painting work using the example file the plugIn provided. I want the painting function to work in VR, so I first put in FPS controller to test the painting works while the camera is moving. I get dots but no lines!
    Carlos, you mentioned that I can use P3dBetweenRaycast. I tried to replace Drag Raycast to this one, but no positive result. Is P3dBetweenRaycast a UI? How do I replace it from Drag Raycast Smooth?
    Does anybody have experience of using this function with HTC Vive controllers? What I want to do is to paint on the walls as the player walks around the scene.

    Thank you so much! PaintIn3D_screenshot.jpg PaintIn3D_screenshot02.jpg
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    P3dBetweenRaycast doesn't use the UI, it just continuously raycasts between the two Transform points you specify. These points should be attached to your controller, or a tool it is holding. Make sure you add P3dPaintSphere or another painting component to the same GameObject.
     
  33. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    151
    Lets say I have a sphere collider trigger with a rigidbody that is acting as an enemy bullet. What is the best method of adding paint 3d to this so that when it combines with a building it does damage and smoke and something similair when it hits a person.
     
  34. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hello there,

    A pre-buy questions to be sure it's fitting my requirements, I'm almost sold on your asset but I couldn't read all the forum pages in details and the documentation is clear but I might have missed things

    So it's only about runtime painting:

    I have a room with a large floor, that is normally composed of many 1x1 tiles (a simple plane that is 1x1x1). I say normally because I might change it to a single large plane depending on your answer.

    My gameplay need here is simple, if you played stardew valley you'll get it: the player character walks in front of a tile and press whatever button that will turn the 1x1 dirt tile texture to a ready to use 1x1 earth tile texture. And he can do that for any 1x1 tile around him

    As all those 1x1 planes share the same material, is it a problem? or would I be better having a large plane

    The second follow up question is: is there a way to get the texture used on a tile/position, let say I make a script that raycast down where my mouse cursor is and it will inform me that the texture at that position is dirt or earth?

    Thank you by advance, I cross my fingers that this will work out with "Paint In 3D" and will buy straight away :)
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Since triggers don't have hit points, I recommend you use normal collisions for this scenario. Then you can use the P3dOnCollision component to paint your objects based on where they hit. If you must use triggers then you can manually call the HandleHit method when you detect OnTriggerEnter, it's up to you to decide what the hit normal would be though.
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    1 - Having all the tiles share a material or texture is not a problem, since Paint in 3D will automatically duplicate it for you when painting. If you want to keep them shared then you must UV map each tile to a different area of your texture, otherwise painting one tile will also paint all other identical tiles the same way.

    2 - You would have to keep track of this yourself, since Paint in 3D has no knowledge of what is being painted. You 'could' do this with the provided components if you make one material layer per paint type, and use the P3dPixelCoutner to see which layer has been painted, but this would probably be an inefficient solution.
     
  37. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    151
    So p3doncollision on the projectile which is interacting with a paintable component on what it's hitting?
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Yes, this setup is used in quite a few of the demo scenes. For example, the "Shield Impacts" scene uses P3dOnCollision to trigger P3dDestroyer (to destroy the bullet/asteroid), P3dSpawner (to spawn the explosion effect), and P3dPaintSphere/P3dPaintDecal to actually paint the hit object.
     
  39. YoungJLee

    YoungJLee

    Joined:
    Dec 4, 2018
    Posts:
    6
    Thank you so much for your reply! So I would need to write a script similar to P3D Input Manager script, but replacing "Finger" to for example "Oculus Rift Controller (right hand/left hand)"? Is there somebody out there working with Paint in 3D with Oculus rift controllers??? I don't seem to find the right script to add to the controllers. Any help will be greatly appreciated.
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Yes that's right. How to implement this depends on the VR asset you're using. If you're using VRTK then you will need to make a new component that inherits the VRTK_InteractableObject class, and you can override the StartUsing and StopUsing methods to handle the paint trigger.
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    You use it the same way you would use any tessellation shader, simply apply it to your mesh renderer. Paint in 3D doesn't care what shader you have applied to your materials, all it cares about is the mesh position + UV data, and which textures you've set up to be painted.
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Yes, because you would be painting the texture used by the tessellation shader when rendering. Paint in 3D simply allows you to paint textures used on your materials, so it will work with any shader.
     
  43. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    I just started receiving the following error message when I stop Play mode:

    Can't remove P3dPaintable (Script) because P3dPaintableTexture (Script), P3dMaterialCloner (Script) depends on it

    It only shows up when I stop Play mode in the editor. Do you attempt to remove P3DPaintable anywhere in your code?

    Thanks
    Allan
     
  44. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Wow. You can disregard my message above. I had installed the Allegorithmic Substance plugin and was playing with some new substances. In addition to breaking something with your asset, it also broke my Unity Editor. Anything I selected in the hierarchy become deselected when I pressed Play. So basically it destroyed my ability to lock on a gameobject in scene view. I deleted the Substance plugin and all of the problems went away.
     
  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Sounds like a bad bug, perhaps that version of the plugin isn't compatible with your version of Unity. I doubt they designed it to break the scene :D
     
  46. maciejgorski

    maciejgorski

    Joined:
    Oct 7, 2015
    Posts:
    8
    Hello. Congratulations for such great asset. Nice work.
    I have one problem at the moment. I can not paint whole mesh to the edges.
    I have uploaded two screenshots with the effect I am getting.
    Each triangle here is separate mesh. I am not able to paint the edges. Texture size on each triangle is small like 50x50.
    Is there any possibility to fix this issue?
    Thank You.
    MG
     

    Attached Files:

  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    You must run your meshes through the Seam Fixer tool to remove these.
     
  48. maciejgorski

    maciejgorski

    Joined:
    Oct 7, 2015
    Posts:
    8
    Thanks, but those meshes are generated in runtime. I think I will not be able to use this tool. I am looking for some way to make Painter 3D tool just draw one pixel more. Those unpainted pixels are rendered, so there should be some way to alter them.
     
    Last edited: Apr 13, 2019
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    In this scenario you can procedurally generate the meshes to include the UV skirts that the Seam Fixer generates. This one pixel border can indeed be generated using a texture pass to 'smudge' the pixels over the UV islands, but this is also slow and will at minimum double the cost of each painting operation, so fixing this in the mesh is a much more efficient solution.
     
  50. maciejgorski

    maciejgorski

    Joined:
    Oct 7, 2015
    Posts:
    8
    Than Yoy for reply. The second option with texture pass would be better in my case. Performance is not an issue. Can You give some hint how to use the 'smudge' technique? I guess i will have to modify PaintableTexture class as i remember the name.