Search Unity

[RELEASED] 2D/3D Paint

Discussion in 'Assets and Asset Store' started by kmedved, May 30, 2019.

  1. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Thanks for your question!

    Yes, you can replace methods for new input system in InputController.cs, but if you want to draw frame rate independent, it requires to modify logic of drawing points and lines as they uses only one input data per frame. This is in my todo list for version 2.6 ;)
     
  2. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Yep, I have the new input system running and so far so good. I'm running into an issue with painting though that I'd like your feedback on.

    My intended usage with 2D/3D Paint is to just paint greyscale masks at runtime. When painting with the default settings (ARGB render texture, 8 bits per channel), painting soft strokes is fairly low quality. Banding occurs or otherwise poor brush painting results. Do you have any suggestions? Maybe the painting should be done without gamma correction?

    If i switch to a 16bit render texture, the greyscale reproduction and brush stroke softness is much better but of course the framerate takes a hit. Any help is appreciated!
     
  3. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Which platform and graphics API are you using? Can you share with me your paint object shader?
     
  4. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0 released!

    What's new:
    Core:
    - New features: layers and blending modes. Asset works with layers and supports 26 blending modes;
    - New tool: grayscale - tool for discolorating parts of the texture;
    - Undo/Redo functionality was rewritten from scratch and now supports layers parameters change;
    - Added support for the new Input System and Pen support;
    - Added support for submeshes and UV channels;
    - Added 48 new brushes;
    - Added support for perspective cameras when using the SpriteRenderer component;
    - Added ColliderPainter component to paint with collisions;
    - Added ability to set default texture color;
    - Fixed brush preview offset;
    - Fixed bug when Canvas UI didn't lock input interaction in case of RawImage painting;
    - Optimized memory usage for tools;
    - Improved VR support.

    Editor:
    - Added CustomEditor for Settings.

    Other:
    - Updated Manual;
    - API changes (see "v.3.0_API_Changes.pdf" for details);
    - Bug fixes.
     
    DragonCoder and Gekigengar like this.
  5. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Congratulations! 2D/3D Paint is now the first and only painting asset in the store to feature layers and blend modes.
    Maybe the marketing material should promote and feature this more, I am sure a lot others look to this as well! :)
     
    kmedved likes this.
  6. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,698
    Really awesome update! Even the UI is neat. Am gonna buy this very soon.

    Have only two suggestions:
    - A thing that's really missing compared to regular art programs: An "airbursh", aka a brush with very soft edges. Maybe the main brush can do that just by providing a simple fading circle? Procedurally generated in the shader might yield best results.
    - The blur brush is really cool but is there a way to avoid it pulling the color from the layers beneath onto the blurred layer?
    Just blurring the current layer and change transparency to blend with the underground would be more intuitive (and what I'd need for something I have in mind).

    In every case keep up the great work on likely the best drawing asset out there!
     
    kmedved likes this.
  7. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Thank you! I never thought about it, and it sounds so cool! :)
    I plan to do another promotion video focusing on the layers feature ;)

    Thank you! :)
    - For "airbrush" you can use Default Paint Mode with small brush opacity value, hardness ~0.15 and turned on flag "Draw On Brush Move" in the tool settings, I attached an image, is that what you need?
    Untitled32.png
    - Yes, you can turn off flag "Use All Active Layers" in the tool settings. In this case only active layer will be blurred
    Thank you so much, I have huge plans to improve it and add new features ;)
     
    DragonCoder likes this.
  8. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    I am guessing the next thing in line is image effects & adjustment layers? :D
     
  9. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Nope, but I'm sure this will come as a pleasant surprise ;)
     
    Gekigengar likes this.
  10. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.2 is out!

    What's new:
    Core:
    - Added support for pixel art graphics;
    - Improved brush accuracy drawing;
    - Fixed a bug when WebGL build didn't work correctly in case of disabled brush preview;
    - Fixed a bug when some classes were stripped from build;
    - Fixed default texture size for RawImage without source texture;
    - Fixed a bug when layer texture was copied twice in case LayersContainer was used;
    - Fixed a bug when the extra texture was created in case of PaintObject didn't have source texture and LayersContainer was used;
    - Fixed a bug when a brush with a large size has an incorrect preview position.
     
    Gekigengar likes this.
  11. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.3 is out!

    What's new:
    Core:
    - Improved drawing using collisions;
    - Added support for Sprite from the atlas.
     
  12. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.4 is out!

    What's new:
    Core:
    - Added new 'Vector3 localPosition' argument to PaintManager.PaintObject.OnMouseHoverHandler / OnMouseDownHandler / OnMouseHandler events to get paint object local position;
    - Fixed a bug when PaintManager.UseSourceTextureAsBackground flag was automatically unchecked if the object didn't have a source texture;
    - Fixed a bug when the layer might have incorrect color when the user invoked Undo in case the object didn't have a source texture;
    - Fixed a bug when CanvasGraphicRaycaster might be removed in case of PaintManager component destroying;
    - Decreased memory allocations in Editor.
     
  13. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.5 submitted!

    What's new:
    Core:
    - Added ability to paint on a few submeshes of the same paint object simultaneously using a few instances of PaintManager component;
    - Added ability to use Jobs System and Burst Compiler for raycasts to increase performance;
    - Added ability to paint on SpriteRenderer with non-default pivot;
    - Added ability to get layer texture from code;
    - Decreased memory allocations in Runtime;
    - Fixed a bug when the layer Mask was applied incorrectly;
    - Fixed a bug when painting on SkinnedMeshRenderer was performed with offsets when an object has a non-default transform scale;
    - Fixed an exception when Undo/Redo was disabled in XDPaintStatesSettings;
    - Fixed a bug when undo/redo may fill layer texture with solid color;
    - Fixed a bug when SpriteRendererPaint returned an incorrect paint position.

    Editor:
    - Now asset sets Mesh.isReadable = true to Mesh assets automatically.
     
    Gekigengar likes this.
  14. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    hello @kmedved

    I had recently purchased this tool, I want to know if we can create a mechanism through which user can paint using Raycast mechanism lets say user has a gun, the raycast would be done from the nozzle to say x distance and if it found the objects is paintable then it would paint the object. Hope to hear from you soon.
     
  15. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hello! Yes, you can paint with collisions using "ColliderPainter" class or create similar functional to paint with raycasts. Also, drawing from code might be helpful: https://unitymedved.bitbucket.io/XDPaint/3.0/Docs/index.html#drawfromcode
     
    sahil_unity643 likes this.
  16. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    Hello @kmedved Is there any way to paint two different meshes simultaneously? let say I have a spray gun and some part of water is on the half part of first mesh and other on another half but only the one half is painting, Do you have any solution for that, please guide me.
     
  17. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Yes, you can create the PaintManager for each mesh. Note that it will work if you use different materials for each object.
     
  18. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    Hii, I already have paintmanager on both the meshes and different mateial as well but still facing the same issue, Any other solution?
     
  19. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Can you send me a small Unity project with an issue?

    My email: unitymedved@gmail.com
     
  20. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    Nevermind @kmedved I had solved the issue by taking a combined mesh, Another question is that any way to control the speed of painting?
     
  21. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Can you tell me, please, what you mean by the speed of painting?
     
  22. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    Kind of progressive painting Paint as per time, Suppose if we have to brush on a model it will not directly paint as whole but after 3 to 4 hands of the brush on the model the color will be seen as whole
     
  23. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    To achieve it, you can set the brush opacity to ~0.25-0.35 with Additive Paint Mode, or ~0.05 in case of Default Paint Mode
     
  24. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    thank you, I used opacity as a speed parameter
     
  25. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.6 is out!

    What's new:
    Core:
    - New tool: BUCKET - tool for filling texture parts with selected color;
    - Decreased memory allocations in Runtime;
    - Fixed VR Input.
     
  26. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    Helllo @kmedved I don't know exactly what it is but suppose if i have two models if one model is exactly behind another and if we apply the paint then the paint will be applied to both.
    Note: I have different material on both models and different texture as well.
    upload_2023-2-25_10-47-12.png
     
  27. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! This is what I'm working for right now for the next update :)
    Please, write me an email and I'll share my current implementation

    My email: unitymedved@gmail.com
     
  28. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    sure i will mail you the same
     
  29. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Hello, the version I use is 3.0.6, and I use SkinnedMeshRenderer to paint the object. When I change the position of the object in transform, the drawing ray can only recognize part of the object, and some parts cannot be drawn. This problem does not exist in 3.0.4.

    Here, the left arm cannot be painted.
    upload_2023-3-15_20-22-45.png
     
  30. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hey, thanks for your reply! I already fixed it and planning to release version 3.0.7 with a fix soon, for now, can you import the attached .unitypackage and check it, please?
     

    Attached Files:

  31. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Thank you! It's good, and no problem now
     
    kmedved likes this.
  32. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Hi! I want to paint together and use this wonderful asset to access the multiplayer online function. Is it difficult to do so? Can you give me some advice? Thank you so much
     
  33. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hey! Thanks for your question!

    If you need to draw using a few online clients, subscribe to events of drawing lines and dots (PaintManager.PaintObject.OnDrawPointHandler and OnDrawLineHandler events), then send the data to clients and reproduce each action from received data. Also, you can send other data such as brush parameters (size, color, angle, etc.), selected layer index, etc.
    This approach minimizes traffic and gives you the fastest way to achieve multiplier painting.

    How to draw from code you can read here: https://unitymedved.bitbucket.io/XDPaint/3.0/Docs/index.html#drawfromcode
     
  34. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.7 is out!

    What's new:
    Core:
    - New features: Brush and Bucket tools support painting using pattern texture! You can also control the scale, angle, and offset!
    - New feature: RaycastController can use Depth Texture to prevent paint on the multiple PaintObjects at the same time;
    - Fixed a bug when Undo/Redo system would clear a layer if the order of the layers was changed;
    - Fixed a bug when Undo/Redo system invoked PaintManager.Render() multiple times per action;
    - Fixed a bug when SkinnedMeshRenderer has incorrect boundaries;
    - Fixed a bug where painting on the SkinnedMeshRenderer would not work if the position was changed;
    - Fixed memory leak when a material field didn't have the source texture.

    Editor:
    - Added PropertyDrawer for ToolManager;
    - Added the ability to manage settings for each PaintManager tool;
    - Tool settings were rewritten from scratch and now can set Texture fields;
    - XDPaintSettings now shows the current version of the asset.

    Other:
    - The demo scene has been updated, and the user can now invoke the context menu with the right mouse button to manage the settings of the selected tool.
     
  35. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Thanks for your answer! I will try it. Awesome new version update!!!
     
    kmedved likes this.
  36. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Thank you so much for your suggestion! I tried it and it's pretty good! but i ran into a problem

    I send the data to other clients in the OnDrawPointHandler action, then other clients reproduce each action from received data as shown in the picture below, in which the OnDrawPointHandler action will be called when Render() is executed, and then the receiver will send the data to the sender. It stuck in a loop.
    upload_2023-4-2_1-21-46.png
    Is there a suitable place to get the data and send message to avoid re-sending message when draw from code?
     
  37. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hey! Thanks for your question!
    You can add a flag to avoid the loop stucking, for example:

    Code (CSharp):
    1. using UnityEngine;
    2. using XDPaint;
    3.  
    4. public class SomeClass : MonoBehaviour
    5. {
    6.     [SerializeField] private PaintManager paintManager;
    7.     private bool isReceivingData;
    8.  
    9.     private void Start()
    10.     {
    11.         paintManager.PaintObject.OnDrawPointHandler += OnDrawPointHandler;
    12.     }
    13.  
    14.     private void OnDestroy()
    15.     {
    16.         paintManager.PaintObject.OnDrawPointHandler -= OnDrawPointHandler;
    17.     }
    18.  
    19.     public void OnReceivedDataFromServer(Vector2 texturePosition, float pressure)
    20.     {
    21.         isReceivingData = true;
    22.         paintManager.PaintObject.DrawPoint(texturePosition, pressure);
    23.         isReceivingData = false;
    24.     }
    25.  
    26.     private void OnDrawPointHandler(Vector2 texturePosition, float pressure)
    27.     {
    28.         if (isReceivingData)
    29.             return;
    30.      
    31.         paintManager.PaintObject.DrawPoint(texturePosition, pressure);
    32.     }
    33. }
    In the example, if isReceivingData is true, painting in OnDrawPointHandler method won't be invoked.

    Alternative, you can comment line 354 in BasePaintObject.cs to not invoke event when drawing from code:
    upload_2023-4-3_20-19-18.png
     
  38. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Hi! Thank you for your answer! now everything is working perfectly fine!
     
    kmedved likes this.
  39. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    hello @kmedved
    I want this specific layer texture during we paint, but I cant able to get the painted texture reference but only the unpainted texture. Can you please tell me how we can get this painted texture reference?
    upload_2023-4-18_12-3-25.png
     
  40. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hey! If you need to RenderTexutre of the layer, you can invoke:
    Code (CSharp):
    1. var layerRenderTexture = PaintManager.LayersController.Layers[1].RenderTexture;
    2.  
    In case if you need Texture2D, you can invoke (don't forget to destroy it when you don't need it anymore, as it may lead to memory leak):
    Code (CSharp):
    1. var layerTexture = ((LayersController)PaintManager.LayersController).GetLayerTexture(1);
     
  41. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    @kmedved But I don't want the non painted texture from this method I am only getting the initial texture that i had applied but instead i want the texture of that layer while I am painting. For eg if on the layer 1 i have some dirt applied now at runtime from that layer I am erasing that dirt so just want the reference of that particular layer texture yeah I also don't want the merge layer texture i.e. texture combination of layer 1 and 2 just want the texture of that particular layer at runtime
    upload_2023-4-19_11-7-6.png

    upload_2023-4-19_11-8-39.png
     

    Attached Files:

  42. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    If you need result RenderTexture, you can invoke:
    Code (CSharp):
    1. var combinedRenderTextrue = PaintManager.GetResultRenderTexture();
    In case if you need Texture2D:
    Code (CSharp):
    1. var texture = PaintManager.GetResultTexture(true); //argument - whether to hide brush preview
    Note that it should be destroyed as texture creation is definitely a possibility for memory leaks in Unity if you're not disposing of the old ones properly.
     
  43. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 3.0.8 is out!

    What's new:
    Core:
    - New feature: added support for multi-finger allowing users to draw with more than one finger at a time;
    - Fixed a bug when mesh bounds size had an incorrect value;
    - The events PaintManager.PaintObject.OnMouseHoverHandler / OnMouseDownHandler / OnMouseHandler / OnMouseUpHandler / OnDrawPointHandler / OnDrawLineHandler were marked as obsolete and PaintManager.PaintObject.OnPointerHover / OnPointerDown / OnPointerPress / OnPointerUp / OnDrawPoint / OnDrawLine were added instead.
     
  44. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    85
    Does it just paint basic color? Or can it paint on normals, too? I am thinking of a more "organic" brush isntead of just a color... thank you for a quick answer!
     
  45. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hey! It paints on any shader texture (except the normal map textures, but I have this item on my to-do list and will be implemented it in future updates). The asset does not paint on vertices or normals, only on textures
     
  46. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    85
    That would be great, because I might want to use it for blood. Without an impact on the normals, it would not fit my needs 100%, so I hope this will be integrated. Here is an example of what I mean:

    https://assetstore.unity.com/packages/vfx/shaders/realistic-blood-shader-218900

    I believe that this use case and others of that kind will be very attractive for developers. The question is, if you implement that into your painting asset, or if you might plan a different asset for such uses cases. I don't know how your current asset is structured, I'd prefer an easy integration in general - I assume, that your painting tool is somehow "modular" to use it in such a use case, although I see that it is focused somehow on traditional painting.

    Would be happy to know how near you will get to that use case (using also normals), and if I should wait for a new asset or grab it maybe now...
     
  47. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    It looks very interesting! I'll try to implement it in a few next updates, but currently, I don't have estimates for this feature
     
  48. sahil_unity643

    sahil_unity643

    Joined:
    Feb 21, 2022
    Posts:
    12
    hello @kmedved Can you please help me with this issue?
    As seen in the image , there are two layers on a surface one is dirt and one is cleaned now I am erasing the dirt from the active layer and now the issue which I am facing is that i can't able to get the texture of that particular layer only, I don't want the combined texture .i.e. layer1 and layer2 but the texture of the active Layer, I do get that texture but its not have any progress of my erasing, so in brief i just want the progress of my erasing the active layer and have to apply that texture in my emission map so that only the only dirt part can emit on surface. Hope to hear from you soon!

    upload_2023-5-26_16-22-23.png
     

    Attached Files:

  49. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hey! As I said before in this thread, if you need to RenderTexutre of the layer, you can invoke:
    Code (CSharp):
    1. var layerRenderTexture = PaintManager.LayersController.Layers[1].RenderTexture;
    2.  
    In case if you need Texture2D, you can invoke (don't forget to destroy it when you don't need it anymore, as it may lead to memory leak):
    Code (CSharp):
    1. var layerTexture = ((LayersController)PaintManager.LayersController).GetLayerTexture(1);
     
  50. haleler51

    haleler51

    Joined:
    Apr 9, 2015
    Posts:
    30
    Hi, this looks like a great tool. Does it currently have the feature to paint on quads/triangles? Other applications, like Blender, have the ability to fill the mesh's quads or triangles with a solid color. This is very useful for low poly texturing.