Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

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

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

  1. ohooooo

    ohooooo

    Joined:
    Jun 29, 2019
    Posts:
    1
    I encountered an issue with CoordCopiers and found a solution for it.
    When using CoordCopiers, the generated mesh was broken.

    The issue seemed to be related to the mesh size, where the vertices count exceeded 65535.
    Additionally, CoordCopiers did not handle the mesh.indexFormat correctly.

    To resolve this, I made a temporary patch by adding the following line to "P3dCoordCopiers.cs" at line 95:

    Code (CSharp):
    1. mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
    This change worked well and fixed the issue.

    However, I believe this is more of a patching solution.
    Ideally, it would be best to check the original mesh's indexFormat and ensure that the copying process handles it correctly.

    Thank you for your attention to this matter.
     
  2. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    Hi,
    Can't paint on clothes,Unity presets URP and URPtoon Shader to be able to draw, but I can't draw with liltoon Shader now, which P3D component I want to check has the parameter to capture liltoon Shader?

     
    Last edited: Jul 23, 2023
  3. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    I found the problem myself. It turned out that the shader was opened to capture different Texture parameters.

    P3D Paintable Texture的Slot-parameter
    URP and URPtoon Shader -> _BaseMap
    liltoon Shader->_MainTex
     

    Attached Files:

    Darkcoder likes this.
  4. unity_PzcQaN0SoqgUZg

    unity_PzcQaN0SoqgUZg

    Joined:
    Jan 4, 2019
    Posts:
    2
    Hey there, thanks for your amazing support! I wondered if it is possible to make a AR plane paintable? When following the steps on your "Getting started" it didn't work out.
     
  5. dynamicvoltagegames

    dynamicvoltagegames

    Joined:
    Apr 15, 2019
    Posts:
    23
    Well the biggest problem with this package is that it uses assemblies, which means good luck trying to add any coding to get any functionality that's missing. You can't do it. I'm not sure how useful something like this is if you can't do any scripting to add any functionality.
     
  6. linenum

    linenum

    Joined:
    Nov 16, 2020
    Posts:
    57
    Hi I'm using P3D Hit Particles. The particle system is emitting out of the secondary material. It also is using gravity. When surfaces such as a quad or a cube are vertical it doesn't seem to paint the surface. But when it is tilted back at 1 degree or more it works. When tilted at 0.7 degrees it paints it lightly.
    When I'm using a quad tilted to at least 1 degree it seems to be able to paint from the back even when it is one-sided (and invisible from the back).
    I've also got an FBX that is made up of 2 intersecting quads (like grass) but the particle system won't paint the mesh unless I slightly rotate it (to -1 degrees X and Z - they're negative probably based on the way I rotated the quads in Blender)

    I was wondering if there is a way for those examples to work with P3D Hit Particles when vertical, etc.
     
    Last edited: Jul 31, 2023
  7. simpa975

    simpa975

    Joined:
    Feb 15, 2019
    Posts:
    9
    Is there a way to blend painted pixels with painted pixels? Let's say I'd paint green over red, instead of replacing the red painted pixels, I'd like the green to mix with the red, and create yellow.
     
  8. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
  9. erenjeagerot

    erenjeagerot

    Joined:
    Mar 18, 2020
    Posts:
    8
    Hi. I love this asset. So thank you for making this asset. I want to do dirt remove mechanics with this asset.

    That is, the object will have an original texture and a transparent dirt texture. The object will initially appear with the dirt texture over the original texture and overlaid with the dirt texture. later, when I delete the object with the mouse, the dirt texture on the part I deleted will be deleted.

    do you have a demo scene for this? I looked but couldn't find it. Please help :(
     
  10. HM201

    HM201

    Joined:
    Jan 4, 2022
    Posts:
    3
    Thank you for the fantastic asset and swift support. I have one more question though, I plan to make the whole map using the same material and texture. I want to paint some parts of the map at runtime, would having a very large texture to paint impact the performance? I hope you can give me any insight on this.
    Thank you
     
  11. Pentacles

    Pentacles

    Joined:
    Nov 6, 2021
    Posts:
    2
    Hello again!

    I continue to use your asset in Unity, and my opinion remains the same: it's outstanding. However, I've encountered a persistent issue that I'm unable to resolve.

    This bug is consistently reproducible. It even appears on a fresh project when I attempt to paint using the asset on the map.

    When drawing with the mouse, there are areas where the drawing doesn't show up (or seems to vanish). What's intriguing is that there's nothing particularly distinct about these areas, and they change based on the map's inclination.

    There are no error messages or logs associated with this issue, as in fact it does work but do something strage.
    To describe the problem more vividly, when I draw with the mouse, certain spots don't capture the drawing as they should. I've provided images and the FBX files of the maps I created in the archive attached for your reference.

    Despite multiple attempts, including recreating these maps several times, the problem persists across all maps.
    Initially, I suspected issues with the UV mapping, but after refining it, the UV map seems perfect, with no overlaps or boundaries issues, as confirmed by your mesh analyzer.
    Even when using the auto-seam thing it appear (at the same spot)

    Interestingly, when I rotate the map, the affected areas change, as illustrated in the provided pictures.

    I've exhausted all troubleshooting methods and I'm hoping you might be able to provide some insight. Could you possibly test this on your end and let me know if there's a resolution?





    EDIT :
    Well, of course !
    I've been struggling with this for like one month, but OF COURSE I founded the solution the next day I ask for help !
    So, it probably isn't a "solution", but I founded that if I put Tile Transition to 160 on my painter, it work. I don't know why, nor I know what is exactly Tile Transition ... But it work so ... :)
     
    Last edited: Aug 12, 2023
    Darkcoder likes this.
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    To ignore the 0 alpha pixels you must use a mask (e.g. P3dPaintableTexture/Advanced/Local Mask). Depending on your scenario you could also set your P3dPaint___ component's Blend Mode / Channels setting to W = 0 (alpha = 0), this will still paint all the RGB pixels, but it will leave the transparent areas transparent.


    Thanks for pointing this out. Since the coord copier doesn't add any vertices it should be enough to just add "mesh.indexFormat = source.indexFormat;". I'll add this to the next version.


    I recommend setting up a scene with painting that doesn't use AR first, and then you add AR later, then it's easier to see where the issue is. You can also compare or just copy+paste the GameObjects from the "01 Basic Setup" demo scene which should work. There should be nothing special about AR that causes the painting to change.


    Why would assemblies change how you modify the code? You can double click any source file inside Paint in 3D, edit it, click save, and Unity will recompile it just fine? This is how most assets with code (should) be implemented. The only difference is that you can't do a circular reference, which you shouldn't be doing anyway. Also, if you hate assemblies then you can just delete them.



    The P3dHitParticles component's Normal setting can be used to change how the paint's 'forward' direction is calculated. If this forward direction and the actual surface normal are too steep then decal paint can fade out, as shown in the "22 Normal" demo scene. You can adjust the paint's Advanced / Normal/Front/Back/Fade settings though.


    No, there is no paint pigment mixing simulation.


    There is a paint flow feature, but it requires you to create the 'flow' direction texture yourself.

    This can be done with the Replace Original blending mode, as shown in the "57 Replace Original" demo scene. This will require your P3dPaintableTexture component's Texture setting to begin with the 'dirty' texture, and then for you to swap to the 'clean' texture in game before you paint. This can be done with a custom script, or the P3dPaintable component's OnActivated event -> P3dPaintableTexture.Texture.


    Answered you via PM!
     
  13. linenum

    linenum

    Joined:
    Nov 16, 2020
    Posts:
    57
    Hi the vertical quads seem to paint properly when I change the P3dPaintDecal Advanced/Normal Front from 1 to 1.1. Though only areas of the quads that are near the ground seem to paint even when I try putting the particle systems higher up....
    I tried changing Normal in P3dHitParticles to Collision Normal but that doesn't seem to make any difference.
     
  14. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165

    For some reason the projectHash is different on every single instance of the project. Is there any reason the project hash is even stored at all? This is really, really annoying and we keep having to discard those changes.
     
  15. AaronAteo

    AaronAteo

    Joined:
    Sep 11, 2019
    Posts:
    7
    Hi :)
    P3dPaintableTextureMonitor.HandleModified() marks the P3dReader as dirty, when the paintable texture has been modified, allowing currentReader.Request() to be called in Update() (if the texture monitor is not on cooldown).
    Is there a reason why the dirty state of P3dReaders never gets reset? It would be nice if the texture monitor only updates if the paintable texture has been modified again.
    (im on Version 2.0.3)
     
  16. kragil

    kragil

    Joined:
    Mar 5, 2015
    Posts:
    7
    Hello,

    can this asset be used to make a simple _fast_ 2D Painting app with Undo/Redo, different brushes and colours and stuff?
    Is there an example for something like that somewhere?

    The VR example is similar, but it is really slow. The pen is always far ahead of the line.
     
  17. Kodo

    Kodo

    Joined:
    Sep 6, 2014
    Posts:
    18
    Hello, we have problem with normal map painting in our project. After few test i found dependency between unity version.
    How I test:
    - create empty 3d project, import plugin, start(or build for android) scene "68 Normal Painting"
    you can see defference on attached screenshots.
    - in 2020.3 both okay
    - in 2021.3 - in Editor all right but in device normal is broken.
    - in 2022.3 - both broken.
    Paint3DTests.jpg
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It's hard to say without a video or something. If the particle hits the object and paints at 90 degrees from the surface, then you must set NormalFront to over 1.0 for the paint to appear, otherwise it will get clipped so it sounds like that's what's happening. You can also add the P3dPaintDebug component alongside your other paint components to see where and what orientation the paint is being applied.


    It sounds like you're using an older version. Quite a while back the ProjectHash value (CwShaderBundle.cs:86) was changed to be return Application.productName.GetHashCode();, which should be consistent across all instances of your project.



    Yeah that's a bug, I'll fix it in the next version. Thanks!


    This asset can only paint 3D objects, but you can make flat 3D objects like the Quad mesh to make it look like 2D.

    Not sure what you mean about the pen always being ahead of the paint. The paint should apply at the end of each frame and match the pen, but perhaps there's some order of operations issue you can fix by adjusting the Script Execution Order. I see this right now:

    upload_2023-8-21_14-56-28.png


    Thanks, I think I've seen something like this before. I'll check it out.
     
  19. linenum

    linenum

    Joined:
    Nov 16, 2020
    Posts:
    57
    Actually it's all working now, even with it set below 1.0. The main problem was that I didn't have the layers set right in ParticleSystem/Collision/CollidesWith, P3dHitParticles and P3dPaintDecal. What confused me was that the painting of the quads would still kind of work (near the horizontal grid planes) even though I had disabled the collider on the quads (so that you could walk through them - but I can just set ExcludeLayers to the Player layer)
    ground7.JPG
    So the quads without colliders were still being (partially) painted because of nearby collisions on the horizontal planes...
     
    Last edited: Aug 23, 2023
    Darkcoder likes this.
  20. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    I have a question...
    Does exist some method to avoid this?



    If I act on the Normal Front or Scale Z parameters, I would lose the distance drawing.

    I also speculated on using a non-paintable layer plane ( Mask ) to prevent the projector from going through:

    Paint_in_3d_mask.png
     
  21. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    128
    upload_2023-8-24_18-5-57.png
    Is there any way to fix this issue when using Unity 2023.1 HDRP render pipeline? All objects that use the Painting3D/Solid shader appear dark.
     
  22. erenjeagerot

    erenjeagerot

    Joined:
    Mar 18, 2020
    Posts:
    8
    Thanks to you, I was able to do the cleaning mechanic. But I would like to assign the normal texture of the dirt texture as well. is it possible to do this?

    2.
    Where can I see what % of the object has been cleared? (Where can I see what % of the object has converted to the original texture?)
     
    Last edited: Aug 25, 2023
  23. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I'm getting "Assets\Plugins\CW\PaintInEditor\Required\Scripts\P3dSceneTool.cs(72,4): error CS0103: The name 'ToolManager' does not exist in the current context" error when I import the asset into the project. I'm on 2019.4
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You could use a mask, but why can't you reduce the Scale.z setting?

    upload_2023-8-28_13-7-30.png

    It works for me. This screenshot is from a new Unity 2023.1.0f1 HDRP project with Paint in 3D 3.0.2.


    Sure, you can configure multiple P3dPaintableTextures for different texture types. For example, the "Rock Engraving" and "PBR Painting" demo scenes use multiple textures using the Group setting on each P3dPaintableTexture + P3dPaintSphere/Decal.


    The P3dChangeCounter ("55 Change Counter" demo scene) shows you how to detect the amount of pixels you have painted.


    Paint in 3D is currently designed for Unity 2020.3.0f1 and beyond. This version change took place in June 2022. So either update your project, or I could send you an older version that should work, but it probably lacks many newer features.
     
  25. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Since the model has different volumes when I reduce scala.z it doesn't paint in the deepest areas so I have to leave it at a good distance.
    In my case, a positionable plane not to be exceeded (which blocks the projection) would be more needed.
     
  26. dzungchaos

    dzungchaos

    Joined:
    Apr 13, 2021
    Posts:
    7
    Hi!

    I'm having a performance problem with the script P3dChangeCounter.

    If I run the game on the editor, the performance is pretty good because my PC's GPU supports AsyncGPUReadback so the run time of this operation on CPU is only 0.5ms.

    But when I run the game on the mobile devices, they do not support AsyncGPUReadback so the code must invoke the CompleteDirectly() method which costs around 40 - 60ms to operate.

    So does this package have another way to support mobile platform? Or could you please give me some suggests for this problem? Thanks in advance.
     
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I see, in that case you can add the P3dMask component to an empty GameObject. This will block all paint in the specified box volume you can see in the Scene view.


    Sure, you can increase the Interval setting, or increase the Downsample Steps setting. At the end of the day the data needs to be copied from the GPU to CPU, and if the current device doesn't support async texture reading then it will take some time.

    If this isn't good enough then you can always not use P3dChangeCounter, and instead make some CPU side invisible painting grid, and when you apply paint you also mark the nearby areas of this grid as painted. This should give you a rough idea of how much was painted and would be very fast.
     
  28. erenjeagerot

    erenjeagerot

    Joined:
    Mar 18, 2020
    Posts:
    8
    Thanks for answer my friend. I tried to do what you said but I couldn't get the result I wanted. (When I paint, I want to paint with a normal map. and I want the object to look textured when painted. I want some height in the painted area.) Attached is a video showing how I did it.


    Also it doesn't work properly in scripts showing how many % of the texture has changed. I have attached the video about it.

     
  29. Rewaken

    Rewaken

    Joined:
    Mar 24, 2015
    Posts:
    128
    Can you please try it in 2023.1.9f1 because almost all scenes are unplayable in it. Is there any setting which I'm missing in HDRP?
    Edit: I'm using hdrp 15x
     
  30. gas777

    gas777

    Joined:
    Jun 25, 2014
    Posts:
    11
    Hello. Please tell me how to paint Decal in editor. I tried that, but always image is shaped by shape function. So always circle image is painted. 59 Dynamic Decal demo is same.
     
  31. ehsan_ak

    ehsan_ak

    Joined:
    Aug 6, 2019
    Posts:
    4
    Hello everyone, I want to use replace original for a texture, but when I add texture and configure setting, texture doesn't disappears? anyone has idea?

    upload_2023-9-7_23-25-34.png
     
  32. Kodo

    Kodo

    Joined:
    Sep 6, 2014
    Posts:
    18
    As variant, problem in normal encoding option
    upload_2023-9-14_22-59-18.png
     
  33. Stupeflip

    Stupeflip

    Joined:
    Mar 20, 2016
    Posts:
    10
    Hello,

    First all of all it's a very good asset.

    I just have a question, for a mesh to be painted what is the maximum number of face possible ?


    Thanks!
     
  34. dzungchaos

    dzungchaos

    Joined:
    Apr 13, 2021
    Posts:
    7
    Hi!

    I have a question about saving the game. Assume that I painted a lot in the surface, how do I do to save the current progress of the panting?

    Thanks in advance!
     
  35. magglemitch

    magglemitch

    Joined:
    Dec 8, 2013
    Posts:
    112
    What would be the best way to go about using a fill to color in different parts of a single mesh? For instance, if it was a clothed person (all one mesh/model) - Id like to be able to tap and color the pants blue, the shirt red, the hair brown etc. Currently, I figured it was easiest to just split the models up to treat them separately but with more complex models it becomes a bit trickier when the detail is in the texture map. I thought local masks would work but I'm not quite sure how to swap out the mask depending on where you've tapped on the model.
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Hey everyone,

    Version 3.0.3 of Paint in 3D is now out!
    • Moved main build to Unity 2021.3.0f1.
    • Updated shaders to latest version.
    • Fixed P3dCloneMirror component when the Flip setting is enabled.
    • Fixed P3dCoordCopier index counts.
    • Fixed P3d___Counter components updating when not necessary.
    • Added P3dRenderDepth component.
    • Added Advanced/DepthMask setting to P3dPaintSphere component.
    • Added Advanced/DepthMask setting to P3dPaintDecal component.
    • Added Depth Mask demo scene.


    Can you send me this demo scene so I can test it myself?


    You can try the latest version which contains an update for HRDP 14. Keep in mind that the shader compiler I use (Better Shaders) only officially supports LTS versions of Unity, which right now is 2022.3.x.


    The 59 demo scene is part of the 'In Game' features. The 'In Editor' demo scenes like "PaintInEditor/Examples/01 Basic Setup", you can choose a Shape that isn't a circle, like the "Square A" shape.


    I don't understand the question. The Replace Original blending mode will paint your P3dPaintableTexture using the texture you set in the P3dPaintableTexture component's Texture setting. In your scene this is the 'border' texture, is this what you expect?


    Aha, thanks for tracking it down.

    [Edit] I have now fixed this. This fix will appear in the next version.


    I don't think there's any limit.


    See the "39 Auto Save Load" demo scene.


    In terms of using Paint in 3D, the easiest solution is to split your mesh up. This allows you to use 'Fill' painting, as seen in the "47 Fill Painting" demo scene.

    The only other alternative as you've discovered is local masks. Finding which object the mouse/finger is under requires custom code. If it's just the mouse then you can read Input.mousePosition, raycast below it, and swap the local mask as needed. For fingers (and mouse) you can hook into the CW.Common.CwInputManager.OnFingerUpdate event, and then raycast below each finger, etc.
     
    Last edited: Oct 4, 2023
  37. erenjeagerot

    erenjeagerot

    Joined:
    Mar 18, 2020
    Posts:
    8
    I sent the scene and project to you in conversation.
     
    Last edited: Oct 8, 2023
    Darkcoder likes this.
  38. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    138
    Does this asset work with objects with tiling uvs or trim sheet textures? It seems like it would have a problem with a lot of modular assets right?
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    This is a texture/pixel painting asset, therefore if you paint one pixel that is shared by many triangles, then that painted pixel will be shared across all triangles that share the same pixel. To avoid this you must split your mesh up to remove duplicates, or add an additional UV channel that doesn't share anything (e.g. Lightmap UVs).

    For example, my other 'CW Spaceships' asset is a modular spaceship parts builder that has texture damage. The spaceships in this asset are fully atlased together with trim sheets, but you can still damage (paint) each individual part, because the whole ship is later given a secondary UV map which is what the damage texture uses.

    Paint in 3D comes with a custom 'Solid' shader that works similarly to Unity's default material, but it also has optional albedo/opacity/normal/etc override textures you can paint, and you can also specify which UV channel these textures use, so you can achieve similar.
     
  40. Unity3dCraft

    Unity3dCraft

    Joined:
    Sep 23, 2014
    Posts:
    2
    Is there a way to draw a screen space image to any rotating grid, just a screen space projection? The decal artist always lies on the surface of the grid, and I want the effect to be like a painting pasted on the screen without any distortion
     
  41. RedGiantGames

    RedGiantGames

    Joined:
    Aug 3, 2016
    Posts:
    1
    Hey, is there a way to use another gameobject like a brush and draw at that point. The brush will be controlled by mouse or touch.TIA!
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    There's no feature like this yet. I haven't looked into it in detail, but I think it requires writing a new component like P3dPaintDecal that paints using the camera matrix rather than sending the paint location. When I have more time I'll look into it.

    The P3dHitNearby component can be added to a GameObject and it will send the current Transform position to any attached P3dPaint___ components.
     
  43. Unity3dCraft

    Unity3dCraft

    Joined:
    Sep 23, 2014
    Posts:
    2
    Thanks! I expect the screen space decal or screen space mask feature!
     
  44. Xwad

    Xwad

    Joined:
    May 14, 2020
    Posts:
    40
  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
  46. nhannguyen2gl

    nhannguyen2gl

    Joined:
    Mar 8, 2018
    Posts:
    3
    Hi, is there any plan to support Unity 2022.3.x LTS? We upgraded our project to 2022.3 and found some issues with P3D which were fine with 2021.3
     
  47. Xwad

    Xwad

    Joined:
    May 14, 2020
    Posts:
    40
    Thanks! And how can achieve this glowing effect? I choosed Group Emissive both for the paint sphere and the paintable texture.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Can you be more specific about what these issues are?


    You must set the paintable texture's Slot setting to target the emission texture, assuming the shader you're using has one.
     
  49. Xwad

    Xwad

    Joined:
    May 14, 2020
    Posts:
    40
    I selected the _EmissionMap in the slot, but still there is no glowing effect. Also not sure where i could add my own shader.
     
    Last edited: Nov 11, 2023
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Hey everyone,

    I recoded a quick video of my new Coloring Book asset:



    The new release sale will end in 2 days!




    The Paint In 3D/Solid shader also requires you to set the material's Emission color to white. If you change that then it should work. Not sure what I was thinking there, maybe I'll change that.

    You can change the Material's shader at the top of the inspector with the shader dropdown list.