Search Unity

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

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

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You must use a different P3dHitScreen.Frequency and/or Advanced/HitSpacing setting to reduce the spacing between paints. This is also how Photoshop works with the 'Spacing' Brush setting, of course painting 3D objects is more expensive than 2D so you can't reduce the spacing too much or you will lose performance.

    I added the Advanced/ConnectHits setting to make a bit of a middle ground, but this doesn't behave well with semi-transparent brushes. I plan to look into the possibility of skipping painting the overlapping areas to give a continuous paint effect even with transparent brushes, but it's quite difficult to do and I don't have the time right now.


    The way this works is components like P3dHitScreen have the StoreStates setting, which call the P3dStateManager.StoreAllStates method before you paint (e.g. when your finger first touches the screen). All paint applied between each call of this method are then treated as being part of the same stroke. More advanced behavior would require you to modify P3dHitScreen or make your own implementation.
     
  2. egem2015

    egem2015

    Joined:
    Oct 27, 2015
    Posts:
    84
    Hi Carlos

    your asset is great. you are agreat artist and developer. thanks for everything.

    can i ask a favor? can you make an 3DPaintable video tutorial from 0 with a free asset from assetstore?

    this will help to everyone who bought or think to buy.

    thanks in advance.

    King Regards.
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    As I said via email, just replace the meshes used in one of the example scenes. If it doesn't work then your mesh probably isn't UV mapped, which you can check via the Analyze Mesh button, and the documentation shows some ways to work around this.
     
  4. egem2015

    egem2015

    Joined:
    Oct 27, 2015
    Posts:
    84
    Hi Carlos again,

    I tried as you said but it did not work.I think the point is that you are very talented person and you are expecting so much from a newbie.

    please if you have a time just make any free asset from assetstore as a 3DPaintable.Just put screenshots if you dont want to take a video.screenshots will be enough.

    thanks in advance.

    King regards.
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You'll have to explain the issue and what you tried, because I can't help you if you just tell me "it did not work".

    Most of the meshes that come with Paint in 3D are from free sources (e.g. the spaceship is from Kenney.nl). Many of these meshes didn't come with UV data, so I had to generate it by hand or via the steps described in the documentation.
     
  6. egem2015

    egem2015

    Joined:
    Oct 27, 2015
    Posts:
    84
    My objects are acting weird.

    for example;

    i am following your tuts and create a 3dPaintable car .but when i try to paint the glasses of the car , the back of the car is painting at the same time and the color is seeing very slightly.

    i am in work now i will send my project to you .

    thanks in advance.

    King regards.
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    As I suspected your mesh isn't UV mapped properly. You can click Analyze Mesh and see this yourself:

    upload_2022-1-28_14-33-21.png

    The documentation and demo scenes 04-09 show this, and techniques to solve it.
     
    hopeful likes this.
  8. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    Hi @Darkcoder !

    Quick question.

    On one of my 3D model I can see that some weird behaviour happens when I paint on thin part: it leaks on the opposite side.

    For example, I paint on the interior on an ear and the painting also shows on the exterior. We double checked the UV mapping and it looks good.
    Here are some screenshots:

    I paint here (outside of the ear):


    it shows on the inside



    Here are the UV mapping:



    Do you have any idea where it could come from?

    I'll send one of the 3D model if you wanna test it out on your side.

    Thank you very much!
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You must use P3dPaintDecal, and adjust the Advanced/NormalFront setting to prevent painting of backfaces. P3dPaintSphere has no such setting.
     
    GreaterHawkeye likes this.
  10. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Hello
    I have been trying to get support by email but I'm not getting any response. I hope you can help me with this issue.

    I have been using this tool with a Humanoid Mesh and it has been great, however I recently updated the humanoid mesh to have more vertices and now I cannot get it to fix the seams.

    I have been using the Seam Fixer tool for this and even though I use the same settings as before on the new mesh it wont work.

    I pointed my project to the exact same commit when I generated the original seamless asset, hence I am using the exact same Unity Version and same PaintIn3D version, Now I am grabbing the same original fbx and I am generating the fixed asset using the exact same values I used back then.
    Yet the result is bad and it differs from the original fixed seams asset and looks as follows:

    upload_2022-1-29_13-44-27.png

    On the Left is the newly generated mesh using the Seam Fixer on the same original model
    On the right is the one that I generated back then in the same original model.

    This does not makes sense to me, how it managed to generate a good seamless model back then but now is not generating it right? Do you know if any setting on the Unity Editor would change the way the SeamFixer behaves?

    I also tried this on a newer version of Unity with same results but I get more information on the meshes and you can see they are being created differently.
    upload_2022-1-29_13-45-11.png

    Is good to note that th result is not random, it is consistently generating the same exact result every time.

    I appreciate any help you could provide, maybe something comes to your mind.

    If there is something I need on my 3D editor to help solve this I would also appreciate some direction.

    Thank you.
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Sorry for the late reply, I just replied to your email. When I have more time I will look into this.

    As I said before though, I don't recommend you paint a 53k triangle mesh directly. Even if it worked, your app performance will likely be poor. You should paint a lower resolution (e.g. lod) version of this mesh, which you said was working.
     
    Hazneliel likes this.
  12. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    PSA: Paint in 3D shaders currently does not work with URP deferred rendering in v12.

    Not sure Better Shaders support them or not (as I do not own that tool), but I would like to see a Shader Graph version of existing shaders for ease of modification.
     
  13. sctiendat

    sctiendat

    Joined:
    Mar 14, 2020
    Posts:
    22
    Hi @Darkcoder,
    I had some problems when tried to paint a car.
    1. I used Paint Commands to save/load decals, quite like your demo at scene "89.Command Serialization". After painting, I converted it to local space by using SpawnCopyLocal(), and when load again, I converted to world space by using SpawnCopyWorld(). But not working, if I moved my car, decals didn't show correctly. I tested on your demo scene and it has same error.
    I'm using version 1.11.10 because I changed some scripts so I don't want to upgrade. So upgrade newest version can help me? How can I fix that?
    2. I have 2 List<DecalCommand> of only a car prefab. My problem is when I have 2 instances of this car in my scene, and I want to paint 2 List<DecalCommand> separate to 2 car's instances. It has many errors because 2 instances have same P3DPaintable and have same Hash.
    I need to spawn 2 instances and paint them at the same time. How can I do this? Do you have any ideas for this? :(
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I'll add this to my to-do list to check.

    The whole point of using Better Shaders is so I don't have to deal with Shader Graph, which only works with SRP, so I have no plans to make anything with SG. The example shaders that come with Paint in 3D should be fairly straightward to implement elsewhere though.


    1 - Are you using version 1.11.14? See the GUIDE asset. This version fixes this bug.

    2 - You must manually change the Model and Submesh or the command.
     
    sctiendat likes this.
  15. sctiendat

    sctiendat

    Joined:
    Mar 14, 2020
    Posts:
    22
    Thanks for your reply,
    1. I'm using version 1.11.10 because I changed some scripts so I don't want to upgrade. So I think I need to upgrade to newest version.
    2. Can you describe it more clearly what do I need to manually change Model and Submesh? I don't have any idea for this :(
     
  16. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    True, but do I basically had to read the generated shader source and re-implement it myself? As I would prefer not to rely on Better Shaders, as good as it sounds.
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The command class has the .Model and .Submesh fields. You can probably leave the Submesh, so you just need to assign the model. Normally this would be your P3dPaintable component instance.

    You can read the original .surfshader code which is much easier to read.
     
    sctiendat likes this.
  18. sctiendat

    sctiendat

    Joined:
    Mar 14, 2020
    Posts:
    22
    Thank you and sorry for many questions :D
    I tried to use Model and Submesh fields but I think you aren't understanding my case. I spawn 2 car instances dynamically, so both cars have same Hash value of P3dPaintable components. Then, many errors appear about duplicate Hash of Dictionary when TryRegister().
    Code (CSharp):
    1. ArgumentException: An item with the same key has already been added. Key: 1300032826
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    4. PaintIn3D.P3dSerialization.TryRegister[T] (T obj, PaintIn3D.P3dHash hash, System.Collections.Generic.Dictionary`2[TKey,TValue] hashToObj, System.Collections.Generic.Dictionary`2[TKey,TValue] objToHash) (at Assets/Plugins/PaintIn3D/Shared/Scripts/P3dSerialization.cs:72)
    5. PaintIn3D.P3dSerialization.TryRegister (PaintIn3D.P3dModel model, PaintIn3D.P3dHash hash) (at Assets/Plugins/PaintIn3D/Shared/Scripts/P3dSerialization.cs:40)
    6. PaintIn3D.P3dModel.OnEnable () (at Assets/Plugins/PaintIn3D/InGame/Scripts/P3dModel.cs:339)
    7. PaintIn3D.P3dPaintable.OnEnable () (at Assets/Plugins/PaintIn3D/InGame/Scripts/P3dPaintable.cs:252)
    8. UnityEngine.ResourceManagement.AsyncOperations.<>c__DisplayClass57_0:<add_CompletedTypeless>b__0(AsyncOperationHandle`1)
    9. DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.18.19/Runtime/ResourceManager/Util/DelegateList.cs:69)
    10. UnityEngine.AsyncOperation:InvokeCompletionEvent()
    I need spawn 2 car instances dynamically, that have same Hash of P3dPaintable components, then paint decal to these instances dynamically at the same time. So I think change Model and Submesh fields are not my solution because the commands didn't know what exactly P3dPaintable that it is needed to apply.
    Is there a way to paint on the model without having to TryRegister it before? Like I dont' call TryRegister() and I have a List that contains all P3dPaintableTexture of a car instance. Then with a list of commands, I try to found P3dPaintableTexture that have a same Hash with each command. Then call PaintableTexture.AddCommand() and PaintableTexture.ExecuteCommands(). Is it possible?
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You can't have multiple paintable objects with the same hash, at least not unless you modify the code.

    You should give them different hashes, make 2 copies of each command, and assign the appropriate Model/Paintable to each command.
     
    sctiendat likes this.
  20. Fortunato1

    Fortunato1

    Joined:
    Jul 28, 2013
    Posts:
    26
    Hi. I have a question about the Change Counter component.

    It correctly counts the number of pixels on some materials, and incorrectly on others. This is a texture with atlas. Where one material and its part of mesh uses a certain percentage of texture.

    For example, in the photo below, a material for colored part of the car body. I've colored most of it and the Change Counter shows the correct result.
    correctresult.png
    And below is the material for bumpers and other parts. I've painted most of it, but the Change Counter shows a very low result.
    incorrectresult.png
    What can be wrong?
     
  21. Fortunato1

    Fortunato1

    Joined:
    Jul 28, 2013
    Posts:
    26
    I have an additional observation on my problem. I showed it in the picture:
    update.jpg
     
  22. Fortunato1

    Fortunato1

    Joined:
    Jul 28, 2013
    Posts:
    26
    One more observation. I tried to set id of this material to 1 on original mesh with multiple materials, and this also solved the count issue for this material. Seems to be ChangeCounter make correct counts only for first material (with id 1) of mesh. Can you fix this?
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You need to change the MaskSubmesh setting to match your material ID. In the first two screenshots both change counters are using the same submesh.
     
  24. Darkcoder

    Darkcoder

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

    Here's a sneak peak at what I've been working on for the next major version of Paint in 3D, which will come alongside some major changes to the internal code and asset structure to make it easier to update in the future.

    For anyone who's tried painting semi-transparent connected lines before, you may have noticed overlap like this:

    upload_2022-2-19_15-54-13.png

    The current 'fix' is to just not use connected hit painting for transparent paint, because they weren't designed to work together. However, in the next version you will be able to enable a new setting that produces this:

    upload_2022-2-19_15-55-41.png

    I deliberately made the line very polygonated/edged to show off the issue in those pictures, but you can of course make it look smooth:

    upload_2022-2-19_15-57-58.png

    Should be ready by the end of the month.

    Stay tuned!
     
    Lemovision and hopeful like this.
  25. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    58
    upload_2022-2-23_0-26-53.png
    How do I change the tile size of a texture.
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You must use the TileTransform setting. For example, you can make a bunch of prefabs with different scales and drop them in. If you need full control you could make a child GameObject with a custom scale and drop it in there.
     
  27. Gamer98898

    Gamer98898

    Joined:
    Nov 18, 2017
    Posts:
    12
    Hie @Darkcoder ,
    I have one question , I want to spread mine paint from hitting point in a one side instead of both sides
    for an eg
    x,y,z

    Y is on top

    X is in middle

    Z is in down side

    X is my hit point (touch point or mouse pressed position) now the problem is that I am not able to spread my paint in only one side from X position to Y ,

    I am using p3 paint sphere component and as I know it always paint in sphere shape But I made some changes in Scale property (10,1,1) After doing this painting is looking in horizontal box shape and it is fine But now I want this box painting should scale in one side instead of both sides.
    At point "X" hit position continuously I am increasing radius in p3 paint sphere.
    Now I want Paint should Only spread in X to Y or X to Z but not in both sides on a single 3D plane.
    Please help how could I achieve this output.
    Regards
     
    Last edited: Feb 25, 2022
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You should use P3dPaintDecal instead, with a sphere shape. This will behave very similarly to P3dPaintSphere, but it will give you the option of using the Advanced/Normal___ settings, which allow you to ignore backface painting, etc.
     
  29. Darkcoder

    Darkcoder

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

    Version 2.0.0 of Paint in 3D is now out!
    • NOTE  This is a massive update. To update you must first back up your project, delete the root PaintIn3D folder, then install the new version.
    • Changed folder structure to be inside Plugins/CW/PaintIn3D.
    • Updated inspector code to support third party assets that implement nested inspectors.
    • Added P3dHitNearby.PaintIn = ManuallyOnly setting.
    • Added Splat Map Painting demo scene.
    • Added Clip Connected demo scene.
    • Added Advanced / ClipConnected to most P3dHit___ components to eliminate connected line overlap.
    • Fixed texture modifiers not saving textures.

    I made some major changes to the folder structure to make my assets easier to update.

    I also added the long awaited Advanced/ClipConnected setting, which allows you to draw semi-transparent connected lines without those ugly overlap marks between each paint line/point. There are some edge cases where it doesn't work, but for most scenarios this new setting should work great!

    Let me know if you encounter any issues.

    Enjoy :)
     
    GreaterHawkeye likes this.
  30. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    256
    Hi, I'm using P3DHitNearby and P3DPaintDecal to create a dynamic decal on my model that can be dragged around, using ScreenPointToRay to figure out where the model was touched and moving the transform to that location. The issue I'm running into is that the decal doesn't update while the mouse button is down, only on mouse up. P3DHitNearby has interval set to 0, painting in update, preview mode. I'm thinking I must be missing something simple, since this isn't a restriction with standard painting, but so far I'm stumped. Thx for any help!
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    It sounds like you're not updating the transform properly, because the preview from P3dHitNearby is updated every frame so it doesn't make sense why it would appear but be in the wrong place. If you're sure this isn't the issue, can you send me a minimal test scene so I can replicate this issue?
     
  32. c_andrews

    c_andrews

    Joined:
    Jan 26, 2015
    Posts:
    106
    Hi, i'm looking into this asset and wondered how easy it is to have a scene with multiple paintable objects and being 2D sprites? Do you have a demo / video of this?
    Thanks in advance
     
  33. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    256
    Thanks for the quick reply. Transform was updating properly, but painting was being disabled by another mechanism I had running. All good!
     
    Darkcoder likes this.
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Setting up multiple objects for painting is the same as setting up one object, just multiple times. The documentation HERE describes this process.

    There's no support for painting 2D sprites. You can paint 3D quads which can be layered into 3D though, since 2D in Unity is just flat 3D.
     
  35. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Hi darkcoder, I just updated the asset, and I have a small issue; the component P3DButtonIsolate has disappeared... How can I replace it on my existing UI in the v3 version of Paint In 3D ? Thank's.
     
  36. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Ok I am sorry I have found it... No more problem ;-)
     
    Darkcoder likes this.
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Yeah P3dDemoButton was replaced with CwDemoButton, and P3dDemoButtonBuilder was replaced with CwDemoButtonBuilder.

    This allows all my assets to use the same components without me having to copy+paste the code, therefore speeding up development and reducing bugs :)
     
  38. Hassan_m_Shahzad

    Hassan_m_Shahzad

    Joined:
    Dec 2, 2018
    Posts:
    4
    Best Asset I have ever used.
    But there's one issue I'm encountering. I'm changing the color of the material and also changing the color of the paintable texture and texture just turn to black or the color of the material. Is there any way to change the color of the texture without contrasting it with the material?
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    You must change the P3dPaintableTexture component's Color setting (or paint it) to change its color. You should never modify the material's color setting because you can't un-paint that.
     
  40. Hassan_m_Shahzad

    Hassan_m_Shahzad

    Joined:
    Dec 2, 2018
    Posts:
    4
    it changes car color but only if the save type is manual and has to call activate and deactivate functions.
    And it removes any decal that is applied to it.
     
  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The easiest way to achieve this is to paint on top of a base material whose color you can control normally. The Overlay and Override demo scenes show you how this can be configured using the shaders that come with Paint in 3D.
     
  42. Ercova

    Ercova

    Joined:
    Oct 21, 2019
    Posts:
    4
    Hello @Darkcoder.
    Thanks for the great Asset.
    I try to use Counter And Percentage For my project.
    But when the Albedo (RGB) Alpha (A) Has a texture it shows me %100 percent of the Object is Painted.
    How can i again use counter or percentage even if i have a texture?
    Shader is Overlay.
    Thank You so much.
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If you use an opaque shader then the alpha channel will be ignored. This allows you set the P3dPaintableTexture component's Color alpha to 0, which allows you to use the color counter to see how much percentage you have painted.

    Alternatively you can the Override setup (one of the first demo scenes), which allows you to paint on top with a separate layer. If you need alpha then you can use the P3dChangeCounter instead.
     
  44. CastryGames

    CastryGames

    Joined:
    Oct 1, 2014
    Posts:
    77
    upload_2022-3-9_22-9-18.png

    how can i make it work on android? drawing doesn't work right now. I already did what it says in the documentation to remove the discard from the shader.cginc
     
  45. CastryGames

    CastryGames

    Joined:
    Oct 1, 2014
    Posts:
    77
    upload_2022-3-9_22-47-56.png

    it is painted but not applied in the correct location.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Does a simpler demo scene like 01 work on your device?

    Which exact device do you experience this issue with? Which render pipeline? Which exact version of Unity are you using?
     
  47. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    Hey Darkcoder!

    Awesome that you could have bring the version to 2.0 :cool:

    Few weeks ago I asked about a feature that allows to paint in a semi-transparent manner without overlapping the areas, I don't know if the new update adds that? :)

    Thanks!
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    No problem.

    Yes, the latest version adds this :)
     
    GreaterHawkeye likes this.
  49. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Hello guys! is it possible to implement paintable surface in Canvas? Something like paintable raw image. If yes, i'll be very glad for any advices on how to do it in a good way)

    Thank you!
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    There's no feature to paint on canvas elements, only MeshFilter + MeshRenderer or SkinnedMeshRenderer objects (e.g. a quad). You could manually assign the P3dPaintableTexture component's Current property to a RawImage using a custom script though to make it appear in the UI (but painting would have to be done on the standard 3D object).