Search Unity

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

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

  1. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    This does not work on face. It worked well on Quad.
     
  2. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
     
    Darkcoder likes this.
  3. GreaterHawkeye

    GreaterHawkeye

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

    I'm trying to implement the Auto Save Load functionality.
    It works well on unity editor, but when I'm using the WebGL build, paint on my object then refresh the page the painting are gone.
    Do you have any clue on how to make it work for WebGL?

    Also, when I use the fill tooln I got this warning:
    upload_2022-5-24_22-5-40.png

    Thanks!
     
    Last edited: May 24, 2022
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    This should work with all objects, as long as the P3dPaintableTexture component's Texture you set uses the same mapping as your mesh (e.g. your face).



    The auto save feature runs from the P3dPaintableTexture component's OnApplicationPause method/message. I put it there because on desktop and mobile this seems to get called when closing the app. However, WebGL might be different. You can try removing the "if (paused == true)" line and changing the method to the "OnApplicationQuit()" message, which might get called on WebGL.
     
  5. meatmania

    meatmania

    Joined:
    Dec 12, 2013
    Posts:
    2
    hello. As I said before, I want to implement erasing the dirt, and for that, I want to save the dirty state.

    The problem is that the result of saving in Paint3d is a painted texture.

    I want to save and load the drawn state other than this, but I don't know how. (Because the goal is to load and delete the drawn state)
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    And as I said before, you can configure multiple layers (e.g. multiple materials, or multiple textures combined with a custom shader) and then have the P3dPaintableTexture save/load the layer on top.

    If this isn't what you want then you'll need to explain the issue more clearly.
     
  7. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    Is there a transparent option in overlay shader in paint in 3d?
     
  8. natoy7000

    natoy7000

    Joined:
    Oct 6, 2020
    Posts:
    3
    Hello, can you tell me how to mix colors?
    example (yellow + blue) = green.
    If you can give a detailed instruction, since I've been using your asset recently
     
    Last edited: Jun 1, 2022
  9. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    I found that P3dPaintableTexture.Replace can be used to replace the base texture, but at this time, the data painted before the replacement will also be lost.
    I want to change the base texture while keeping the paint data, is it possible?
     
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    What do you mean? The overlay shader is transparent using alpha blending.

    All painting modes use additive color theory (RGB).


    By default there is no 'paint data', the texture itself is modified, this is why you can't change the background.

    The easiest way to do this is to use two layers (e.g. overlay material on top of your base material, or a custom shader that combines two textures), and you just paint the second layer. This allows you to change the base material as you wish.

    If you must use one layer then you need to set the P3dPaintableTexture's UndoRedo setting to LocalCommandCopy, change the Texture setting as you wish, and then call the RebuildFromCommands() method to repaint it from scratch. This of course has some performance penalty, and won't work well if your object is animated, so I recommend using two layers.
     
  11. shansajusaho

    shansajusaho

    Joined:
    Sep 1, 2020
    Posts:
    13
    I figured it out.
     
    Darkcoder likes this.
  12. villaman

    villaman

    Joined:
    Apr 21, 2021
    Posts:
    69
    Hello, I am trying to paint a "FlowMap". I've attached an example below.

    upload_2022-6-5_10-48-45.png
    In case you are not familiar with a FlowMap, it is used to make things like Lava etc. flow in a particular direction. This is done by plugging the resulting FlowMap texture into the appropriate slot in a "FlowMap Shader".

    A flow map can be interactively painted by painting "strokes" that represent the flow direction. This is of course doable in PaintIn3D. However, the additional characteristic of a FlowMap is that the direction of the flow is represented by a color.

    So, fundamentally, I need to change the color of the paint based on the direction of the stroke.

    So, if I have points P1, P2, P3 etc. representing my paint strokes.

    Then on point P1, I can't draw yet, as there is no direction. However when I paint P2, I can get the direction (P2-P1) and use that to set the color between P1 and P2. In general color-of-stroke-n = f(Pn - Pn-1).

    How would one do this in PaintIn3d?

    My initial thought was to do this in P3dPaintSphere (maybe a copied P3DPaintSphere2) in the HandleHitLine. (Note that I am actually painting on a Quad.) So the idea would be to somehow convert those 3d hitpoints onto 2d quad hitpoints and then calculate the angle and based on that calculate the color and set the color property on the P3DCommandSphere.

    But I couldn't figure out how to take this any further at the code level. Any thoughts on how to do this? Maybe, some completely different approach?

    thanks,
     
  13. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I purchased this last week, started playing around with it, pretty amazing! I'm using it to paint a splatmap, using an existing splatmap and then painting/modifying it. Two questions:

    1) I would like to be able to keep editing the splatmap in photoshop. When I export the splatmap after painting in Paint in 3D, it's in that premultiplied alpha format, which is hard to edit in Photoshop. Is there a way to make it use TGA format so the image is easily editable in PSD?

    2) I'd really really like some other brush options for painting the splatmap, like more organic/splatter shapes. I tried selecting the options in the Paint in 3D> Paint inspector, but those don't seem to work at all on splatmap painting. Is there a way to do custom brushes?

    thanks
    Dave
     
  14. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    hello everybody, I need to paint on a big object, like a cave, there will be a tileable stone texture. how can i paint without having a pattern repeat, on another transparent texture with another uv set? maybe I missed an example in the asset?
    Thank’ s a lot if you can help me .
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    A flow map is effectively a normal map without the Z, so you might be able to use the NormalBlend/Replace blending modes. If you just want to change the color based on draw angle then take a look at P3dHitScreenBase.cs. The CalcHitData method calculates the position/rotation of a hit based on the component settings, and if you use RotateTo=Normal with RotateTo/RelativeTo=DrawAngle, then the paint hit will be rotated to the draw angle, so you could insert some custom code there to instead change your paint color.

    Take a look at the "Splat Map Painting" demo scene.
     
  16. ChrisVMC

    ChrisVMC

    Joined:
    Jun 22, 2020
    Posts:
    16
    I'm trying to get the delayed appearance demo to work with decals rather than paint. It sort of works, but the decals fade in as black then fade to the colour of the decal (red). Where as if I use a red paint sphere the fade in works as expected. The zip file has a very short video. These images are the settings for paint sphere and decals. Is this solvable or a limitation of using decals? paintDecal.png paintspehere.png
     

    Attached Files:

  17. Realgar

    Realgar

    Joined:
    Sep 30, 2012
    Posts:
    52
    Thank you very much !
     
  18. Deiran

    Deiran

    Joined:
    Aug 6, 2014
    Posts:
    6
    Hey!
    Can I somehow force a P3dChangeCounter to update its counters? Here's my code:
    Code (CSharp):
    1. foreach (P3dChangeCounter changeCounter in m_changeCounters) {
    2.             changeCounter.PaintableTexture = changeCounter.gameObject.GetComponent<P3dPaintableTexture>();
    3.             changeCounter.Color = colors.transform.Find(changeCounter.gameObject.name).gameObject.GetComponent<P3dColor>().Color;
    4.             changeCounter.MaskMesh = changeCounter.gameObject.GetComponent<MeshCollider>().sharedMesh;
    5.             changeCounter.MarkChangeReaderAsDirty();
    6. }
    It works and sets every property nicely, but it seems that the ChangeCounter doesn't update the values on the "backend" and the Ratio remains 0. Can I somehow force it to update?
    Thanks!
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    It looks like I made a mistake with the gradually fade blending code. I'll send you a new build shortly.




    Calling MarkChangeReaderAsDirty should work as long as the change counter's Update method has run at least once. If not, it should auto update when it does. Keep in mind this only updates the specified Texture and Color settings against the previously registered mask & paintable texture. You probably want to update the registered paintable texture state, which requires you to call: MarkCurrentReaderAsDirty();
     
    ChrisVMC and Deiran like this.
  20. Deiran

    Deiran

    Joined:
    Aug 6, 2014
    Posts:
    6
    Thanks! Worked great!
     
    Darkcoder likes this.
  21. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I purchased this last week, started playing around with it, pretty amazing! I'm using it to paint a splatmap, using an existing splatmap and then painting/modifying it. Two questions:

    1) I would like to be able to keep editing the splatmap in photoshop. When I export the splatmap after painting in Paint in 3D, it's in that premultiplied alpha format, which is hard to edit in Photoshop. Is there a way to make it use TGA format so the image is easily editable in PSD?

    2) I'd really really like some other brush options for painting the splatmap, like more organic/splatter shapes. I tried selecting the options in the Paint in 3D> Paint inspector, but those don't seem to work at all on splatmap painting. Is there a way to do custom brushes?

    thanks
    Dave
     
  22. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Hello there!
    Once again i am here with questions:) I am currently using a spraycan way to paint in one of my scenes. Everything works fine, except for few things.
    1. When i paint on material, it makes these weird white lines on the edge of painted area. Is there a way to remove them?
    Снимок экрана (400)_LI.jpg
    2. When i paint my mesh it has some weird white seams (i assume), but i can't understand why. Here are some screenshots
    P.s.: sorry i am not a designer/artist in any way, just a coder in a small indi studio Снимок экрана (397).png Снимок экрана (399).png
     
  23. ChrisVMC

    ChrisVMC

    Joined:
    Jun 22, 2020
    Posts:
    16
    Thanks :)

    Next question. The decal scale seems to effect the alpha of the whole decal when blending (under a certain scale the whole decal become partially transparent). Is this a limitation of how the blending works or a bug of some sort? Example images below. No changes between the setup for each illustration other than the scale modifier.

    I've tried enabling disabling mipmaps on the decal in question and that had no effect. I've also tried different texture sizes both for the decal and the paint texture. Neither make a difference to this issue.
     

    Attached Files:

    Last edited: Jun 7, 2022
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    1 - In the next version I will add the option to export TGA.

    2 - Are you talking about the in-editor painting features (i.e. using only the Paint in 3D window to paint in the Scene view), or the in-game painting features (i.e. using a manually configured Paint GameObject in the scene with P3dHitScreen + P3dPaintSphere/etc you paint in the Game view)? The former creates its own painting tool, and it does not modify any of the painting components in your scene. The latter requires you to edit the paint component settings in the inspector.


    Check out demo scene "02 Seam Fixer" or the documentation HERE.

    Keep in mind your mesh is very poorly UV mapped (97% wasted UV area/pixels), so you may want to redo your UV map for better paint quality and performance.


    Decals fade out based on the difference between the paint surface direction and the decal direction, which you can control with the Advanced / Normal settings. Decals also fade out based on the distance between the paint surface and the decal surface, which you can control with the Scale.z, Radius, and Hardness settings. If you set Wrapping to 1 then the decal scale also changes based on this distance.
     
    gecko and ChrisVMC like this.
  25. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Okay, will do, thanks!
    Any ideas about this though?
    Снимок экрана (400)_LI.jpg
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    "Check out demo scene "02 Seam Fixer" or the documentation HERE."
     
  27. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Yeah, i know, i did it. Nothing changed:( 2022-06-09 135114.png 2022-06-09 135424.png 2022-06-09 135455.png 2022-06-09 135239.png
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
  29. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    55
    Hi there and thank you for this asset.

    May I ask please, I'm thinking of using this as a kind of image pixel editor with the brush being 1 cell in size. If I had say a 1000 x 1000 texture, could this potentially be used to "paint" a 1x1 cell at a time?

    Many thanks and best wishes

    John
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    If you set the brush to be one texel in size then you can paint one pixel at a time. However, since the paint is applied in the 3D the paint hit points would need to be aligned to each texel, otherwise it wouldn't always apply anything. This kind of alignment isn't possible for all surfaces on all meshes.

    To make pixel perfect painting it's easiest to just raycast your mesh, get the hit UV, and set the pixel color there.
     
  31. abdulkadirsemiz

    abdulkadirsemiz

    Joined:
    Mar 2, 2021
    Posts:
    1
    image.png Greetings, I tried to change the gray color of the object in the figure to these colors using replace custom, but I could not paint the white lines in the images. The same thing happened when I did the process in reverse. How can I paint these edges?
     
  32. Deiran

    Deiran

    Joined:
    Aug 6, 2014
    Posts:
    6
    Hello!
    Would it be somehow possible to have multiple TargetModels for a P3dPaintSphere/P3dPaintDecal? I know you can restrict it to a single layer, but I would need far more different layers than it is possible to create in Unity. Using Atlases also wouldn't work, as I need multiple copies of the same object. Restricting it somehow to a certain Tag would probably work, as you can have a ton of different tags, but multiple TargetModels would be the easiest one to use.
    Cheers!

    EDIT:
    I've figured it out by just using Physics.OverlapSphere and then iterating over every model overlapping and using CheckCollision on them.
     
    Last edited: Jun 17, 2022
    Darkcoder likes this.
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    See HERE.


    To keep the code and inspectors simple I only allow one target model/texture to be set. To support multiple you can look at the HandleHitPoint/etc methods from P3dPaintSphere/Decal/etc and create a new P3dPaintableManager.SubmitAll method that accepts a list, or call this once for each model/texture.
     
  34. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Hi! Is there a way to paint transparency with your asset?
    I mean: i have an object (paper) i want to spray water on it and make it more transparent in places, where water drops touched the paper suface. Is it possible to make it with your asset?
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Sure, you can use the Replace blending mode with the channels set to 0,0,0,1, so it only changes the alpha/opacity, then set your paint color's opacity to 0.5 or something. As long as your object's material uses a transparent shader this should work.
     
  36. natoy7000

    natoy7000

    Joined:
    Oct 6, 2020
    Posts:
    3
    Hi, this problem appears with some colors. And when you draw up and down.
    With the usual colors (blue, green, red, etc.) everything is fine.
    Maybe someone knows how to solve the problem? If possible, describe the solution in more detail.
     

    Attached Files:

  37. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    Hi, I used ChanelCounter
    And I made an event After some has been painted,
    in the event I want the whole object to be filled with the same color,
    How do you do that?
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Can you send modify one of the demo scenes that comes with Paint in 3D so that this issue appears, and then send it to me?


    The P3dPaintableTexture component has the SetColor method, which accepts an HTML color string like: #FF0055

    You can then call the Clear method which will replace all the pixels.

    You can call these methods from your event in this order.
     
  39. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    Thank you! This is exactly what I tried to do, but it changed my color in the P3dPaintableTexture component,
    And does not affect the object itself.
    upload_2022-6-21_8-52-20.png
    upload_2022-6-21_8-52-46.png
     
  40. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    I found the problem, thanks
     
    Darkcoder likes this.
  41. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    16
    In a game with Goystick I made a player that draws,
    How can i make it paint just by pressing another button in the Goystick?
    I tried to change the radius from my script but it did not work well.
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    The P3dHitNearby component ("37 Nearby Painting" demo scene) can be used to paint at a GameObject position. You can connect your button to enable/disable this component. You can also connect your joystick to move it.

    The Radius value of P3dPaintSphere/Decal is a normal property, so there should be no problem modifying it in-game. Keep in mind this (and all other paint settings) only change future paint you apply. Previously painted paint is baked in and can't be changed unless you modify the paint commands and repaint it (advanced).
     
  43. Freemort

    Freemort

    Joined:
    Sep 13, 2017
    Posts:
    4
    Is it possible to draw with a cube by existing components, as with a sphere like in "P3dPaintSphere"?
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    P3dPaintDecal is a cube shape if you have no texture/shape, set Wrapping to 0, and set Advanced/NormalFront to 0. This is shown in the "84 Primitive Painting" demo scene.
     
  45. drbatuira

    drbatuira

    Joined:
    May 4, 2020
    Posts:
    23
    Hello @Darkcoder .

    First of all, thank you very much, it's the perfect asset for my project.

    Assuming I don't want any sample files, I just and exclusively want the core, which files can I safely delete?

    Deleting "Examples" folders causes errors ( CwInputManager ).
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    The CwInputManager class has been moved in CW/Shared/Common/Extras instead of /Examples. This should fix this issue in the next version. For now you can maually move it across before deleting /Examples.
     
  47. ppd-enrique

    ppd-enrique

    Joined:
    Jun 16, 2022
    Posts:
    4
    Hello @Darkcoder

    Excellent asset! It's very high quality and quite customizable.

    I'm running into some trouble using it in a project and wanted to ask for your help.

    I'm using low-poly models that have white as their base color, with several details drawn in the texture in black and dark gray. (Image 1)
    Based on this, creating color variations of the model by changing the material albedo has worked pretty well so far. (Img 2)

    I would like to add a feature where the player can paint in colors, but I'm running into a problem: when I paint color by using your plugin, the texture is completely overwritten, so the penciled-in-black details are erased. (Img 3)

    I know this problem could be potentially sidestepped by moving the details into a different material, but this would require a lot of minute manual editing of the models so it would be quite impractical.

    I wanted to see if it would be possible to configure or edit the source of the plugin so it works closer to our current approach. For example:

    1) Have it not overwrite the color in the texture, but "add" to the currently existing color. (Or maybe "subtract" or "multiply" is more correct? In any way, make it produce similar results to changing the albedo of the material in Unity.)

    2) Have it not edit the texture, but modify the stored albedo of the vertices. (I don't think Unity 2021 does anything with the stored vertex albedo by default, but I think that if I add a vertex shader it should render correctly.)

    Or any other approach that you can think of.

    Please let me know what you think. Many thanks in advance!

    img_1.png img_2.png img_3.png
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You can can set the P3dPaintSphere/Decal component's Blend mode to Subtract or Multiply to get this effect.

    You could also use a custom shader that has two textures: the first is the paintable texture, and then you multiply (or some other blend op) it with your details texture. This would allow you to paint normally and not have any details disappear.
     
    ppd-enrique likes this.
  49. drbatuira

    drbatuira

    Joined:
    May 4, 2020
    Posts:
    23
    Hello.

    After changing the shader at runtime, the system continues to work (painting with the mouse), but the "preview" disappears, the painting is performed normally but without showing the preview.

    In this case, should I reconfigure the components, as if it were a procedural generation or can I call some function?

    I change the shader through this code:
    render.material.shader = Shader.Find(newShaderName);
     
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    To change the shader you should use renderer.sharedMaterial.shader, otherwise the material will get cloned and then it will lose its connected to Paint in 3D.

    If you want to use a cloned material then you must call the P3dPaintableTexture component's UpdateMaterial method after to update this link.
     
    drbatuira likes this.