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
    social.png





    «2D/3D Paint» - a universal solution for Unity that allows to paint on 2D and 3D objects. You can also create a modern paint app with incredible features and outstanding performance!
    Unity 2019-2022 supported.

    WebGL Demo: https://unitymedved.bitbucket.io/XDPaint/3.0/index.html
    Documentation: https://unitymedved.bitbucket.io/XDPaint/3.0/Docs/index.html
    Asset Store: https://assetstore.unity.com/packages/slug/212475


    ✔️ Easy to use

    No code-writing skills are required: just add a component, set up a few parameters and there you go

    ✔️ High performance, works perfectly on mobile
    Asset uses GPU for painting, which provides high performance, and works even on mobile device

    ✔️ Works with any Shader
    The asset allows you to paint using any shaders and materials. Just choose from the list of textures you want to paint and you're set!

    ✔️ Supports 3D components
    Paint on animated objects with a great performance! MeshRenderer and SkinnedMeshRenderer are supported. Check out the WebGL demo and see how it's easy and cool

    ✔️ Supports 2D components
    Want paint in 2D too? No problem! SpriteRenderer and RawImage are supported. You can even create your own mobile paint app

    ✔️ Supports VR
    2D/3D Paint works with any VR device!

    [NEW] ✔️ Supports Layers and Blending Modes
    Paint on layers, merge, create new and use blending modes to get your desired effect

    [NEW] ✔️ Supports Layer Mask
    Layers support masks, so you can hide part of the layer using a mask texture

    [UPDATED] ✔️ Supports brushes
    Choose a brush and paint whatever you want! You can add your custom brushes and configure parameters, like size, color, hardness, and opacity, or use built-in 58 brushes presets

    [UPDATED] ✔️ Includes tools
    — Brush
    — Erase
    [NEW] Bucket
    — Eyedropper
    — Brush Sampler
    — Clone
    — Blur
    — Gaussian Blur
    [NEW] Grayscale Tool
    Be sure that more tools will be coming in future updates ;)

    ✔️ Draw from code
    Want to paint on any objects and not just use Input? Sure, you can draw on objects from code

    [NEW] Works with Pixel Art graphics
    You can draw with pixel-by-pixel precision

    [NEW] ✔️ Input System supported
    Asset works with a mouse, touch device, pen (tablet stylus like Apple Pen) or VR controller, or any other input device of the new Input System. The old Input Manager is supported

    ✔️ Pressure support
    Use an Apple pencil or any other device with pressure support for the best paint results

    ✔️ No colliders required
    No need to add any colliders for work

    ✔️ Works with any render pipeline
    Standard, Universal Render Pipeline (URP), and High Definition Render Pipeline (HDRP) are supported

    [UPDATED] ✔️ Undo / Redo
    Did some miss-click and want to undo your action? Undo and redo are supported. Undo/redo system also supports layers parameters

    [NEW] ✔️ Ability to save changed textures / layers
    Want to save your result painting? No problem, the asset supports it

    Allows getting the average color of the texture
    Check the average color of painting with high performance using GPU

    Supports drawing using collisions
    Drawing using collisions is supported and implemented in a few clicks!

    Long Term Support
    Be sure that you'll get support for newer unity versions and new features. I'm preparing a ton of new features, stay tuned ;)

    Full C# source code and example scene included
     
    Last edited: Jan 22, 2023
    ROBYER1 likes this.
  2. Jeff-Kesselman

    Jeff-Kesselman

    Joined:
    Apr 5, 2010
    Posts:
    99
    HI, Can you tell me what the drawing functions are of your package? I am looking for something I can drive programmatically to draw on a texture at run-time.
     
  3. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Thanks for your question! Sure, you can draw from code. For example, you can simulate input:

    Code (CSharp):
    1. var screenPos = new Vector3(screenPos.x, screenPos.y);
    2. var ray = Camera.ScreenPointToRay(screenPos);
    3. RaycastController.Instance.Raycast(ray.Value, out triangle);
    then use functions for painting:
    Code (CSharp):
    1. PaintObject.OnMouseDown(screenPos, 1f, triangle);
    2. PaintObject.OnMouseButton(screenPos, 1f, triangle);
    3. PaintObject.OnMouseUp(screenPos, 1f, triangle);
    I'm working now on upcoming update that will significant improve convenience, user-interaction, performance and add some new features (including more comfortable drawing from code).
    Let me know if you have any questions.
     
  4. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    A huge update of 2D/3D Paint is here!

    What's new:
    - New feature: TOOLS! Asset have 4 tools: brush, erase, eyedropper(color picker) and brush sampler(brush picker). More tools will be added in future updates;
    - Brush parameters: change brush texture, opacity, hardness or color using editor or from code;
    - TextureKeeper - now Undo/Redo functionality saves texture and works more faster than before. Old class StateKeeper was removed;
    - Added an ability to limit Undo/Redo actions quantity;
    - Added an ability to draw from code;
    - Asset was partially rewritten to give you best performance;
    - New Demo scene: now it is more comfortable and user-friendly;
    - Properly works with alpha and color mixing;
    - Bug fixes.
     
    Last edited: Oct 14, 2020
  5. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Version 2.0.1 released.

    What's new:
    - Fixed Input for WebGL;
    - Improved performance for getting neighbors triangles.
     
    Last edited: Oct 14, 2020
  6. adrian-taylor09

    adrian-taylor09

    Joined:
    Dec 22, 2016
    Posts:
    63
    Is it possible to paint on meshes with tiling materials?
     
  7. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Yes, sure :)
    Note that if model has the same uv-coords in a few places, painting result will be duplicated
     
  8. kmedved

    kmedved

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

    What's new:
    Editor:
    - Added ability to save/load Triangles data using ScriptableObjects
    - Added ability to initialize PaintManager from Inspector

    Core:
    - PaintManager initialization moved from MonoBehaviour.Awake() method to MonoBehaviour.Start()
    - Improved PaintManager initialization from code
    - Improved memory management
    - Fixed PaintManager.GetResultTexture() method that returned an incorrect texture
    - Removed SkinnedMeshRenderer scale restriction
    - PaintManager.SetSourceMaterial() marked as obsolete

    Other:
    - Bug Fixes
    - Improved manual
     
    Last edited: Oct 14, 2020
  9. kmedved

    kmedved

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

    What's new:
    New Features:
    - New Tool: Clone tool - clone the part of the image with a few clicks!
    - New Tool: Blur tool - set parameters and blur the part of the image!
    - Average Color Calculator - get an average color of the texture!

    Core:
    - Improved memory management
    - Fixed work of 'Brush Sampler', 'Eyedropper' tools with active PaintManagers
    - Added sender to BasePaintObject events
    - Removed obsolete method PaintManager.SetSourceMaterial()

    Other:
    - Bug Fixes
    - Improved manual
     
  10. kmedved

    kmedved

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

    What's new:
    Core:
    - Improved Clone tool performance
    - Improved thin lines drawing
    - Fixed Brush Sampler tool memory management

    Other:
    - Improved brushes quality
     
  11. kmedved

    kmedved

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

    What's new:
    Editor:
    - Added ability to set texture size from PaintManager Inspector

    Core:
    - Default texture size were moved from Settings to PaintManager.Material
    - Fixed setting material for multi-materials objects
     
  12. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
  13. Furagido

    Furagido

    Joined:
    Mar 10, 2020
    Posts:
    1
    Hey!
    I'm currently working on a project and using 2D/3D Paint to draw on some 2D sprites. Unfortunately, upon drawing on the sprite, it is not painting its contour correctly, as you can see on the image (before and after painting):
    AliceBefore.PNG AliceAfter.PNG
    Is there a way I could paint the sprite with a more precise contour?
     
  14. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Thanks for your post!
    Can you tell me more about contour: how do you convert source sprite to second image? Did you try to use brush hardness?
    Can you email me, because sometimes unity doesn't send new posts notification? My email: unitymedved@gmail.com
    Thanks!
     
  15. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Last day of discount!
    2D/3D Paint is on sale for 50% off!
     
  16. Luchunpen_0

    Luchunpen_0

    Joined:
    Aug 7, 2014
    Posts:
    58
    Hi !
    I have a question: When I paint using semitransparent color - the final color isn't transparent. I think it is because total transparent value is summed up. Can I draw with constant transparent, even if the next line is drawn over existing ?
     
  17. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Thanks for your question!
    I'm working right now to improve texture blending with transparency, please email me and I'll share my current implementation before public release :)
    My email: unitymedved@gmail.com
    Thanks!
     
  18. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
  19. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    I wonder if this support layers and blend modes?

    Its been my dream to create multiplayer painting game.
     
  20. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! It supports two layers for now: background (source image) and layer for painting, I'm planning to add multiple layers and blending options in future updates :)
     
    Gekigengar likes this.
  21. AuriMoogle

    AuriMoogle

    Joined:
    Jun 4, 2018
    Posts:
    15
    Hi, I found your asset in the store and thought that it would be a great way to implement the painting feature of our game. But it seems like it isn't handling the basic UV problems I encountered when I tried to implement the feature myself.

    It places a color circle in the texture at the correct position but does not account for the UV coordinates of the surrounding pixels or the UV scale.

    1. Color is bleeding between not adjacent vertices
    ColorBlobImage.png
    2. The UV scale is not accounted for. The brush size depends on the size of the specific UV
    ColorBlobGif.gif

    We have normal UVs, nothing special. No overlapping vertices. UVs:
    ColorBlobUVs.PNG

    Your plugin seemed like it could handle all these problems. Which settings must be tweaked to fix these issues?
     
  22. kmedved

    kmedved

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

    Currently it does not find edges on the mesh/uv and when you paint on the mesh, it finds corresponding uv position on the texture and bake brush on it. I'll think how to implement this functional it in future updates.

    Brush scales as image on your texture multiplied by brush scale value. If some big part of the mesh vertices has a few pixels, brush will be baked and cover all big part of the mesh. The solution I can offer for now - change model uv with texture.
    Can I ask you to send me that model with texture to my email? I'll check it and let you know what else I can offer for this case.

    Also you can email me directly, because sometimes unity doesn't send new posts notification and I can miss some post. My email: unitymedved@gmail.com
    Thank you!
     
  23. AuriMoogle

    AuriMoogle

    Joined:
    Jun 4, 2018
    Posts:
    15
    Thank you for letting me know about the bleeding issue, I've sent you another email. Due to NDA I think we can continue there. And thank you for your support!
     
  24. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Hello, I'd like to ask how layers are planned to be implemented in the future for preparation. Texture Array 2D?
     
  25. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! I'll create List of custom classes that will have RenderTexture field
     
    Gekigengar likes this.
  26. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    How would you suggest using this asset with a rawimage that is fitted to a user's screen if they are on a phone or tablet, does the drawing from a touch or pointer always line up if the raw image is scaled, or would you suggest a different approach to 2d canvas drawing?
     
  27. kmedved

    kmedved

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

    Can you tell me in details, what goals do you want to achieve? What do you mean about pointer line up with scaled raw image?
     
  28. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Thanks for getting back to me, some other assets we tried before using this one (which we will be probably) had a rect transform they drew on of a set size like square, so when we wanted it to fit the screen and cover the whole screen, we scaled their square image with an aspect ratio fitter to make sure it always covered the screen. When we did that, the logic for casting from the point on the screen to that image got completely borked.

    What I would like to know is, with this asset, can we have a rawimage in the canvas that covers the whole screen on mobile phones/tablets, with transparency so that people can draw over the top of what is going on underneath that canvas, and it will fit the screen scale at any aspect ratio without the drawing being broken or offset?
     
  29. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! For you task you can create RawImage with RectTransform settings to fit whole screen, after you can create PaintManager from code and it will use texture with size from RectTransform.rect:

    Screenshot 2021-03-25 at 20.39.50.png

    Code (CSharp):
    1. public GameObject objectForPainting;
    2. public Material material;
    3. ...
    4. var currentPaintManager = objectForPainting.AddComponent<PaintManager>();
    5. currentPaintManager.ObjectForPainting = objectForPainting;
    6. currentPaintManager.Material.SourceMaterial = material;
    7. currentPaintManager.Material.ShaderTextureName = "_MainTex";
    8. currentPaintManager.Init();
     
    ROBYER1 likes this.
  30. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Did that earlier today, works an absolute treat, thanks for the code example and what a great asset!
     
    kmedved likes this.
  31. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Glad to hear it, thank you! Let me know if you have any questions :)
     
  32. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Any news on layer feature? Already purchased, and still very interested in having layers :)
     
  33. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! I'm still working on version 2.4. I'll probably add layers support to version 2.6 or 2.7, do my best ;)
     
    Gekigengar likes this.
  34. drbatuira

    drbatuira

    Joined:
    May 4, 2020
    Posts:
    23
    Hello, how are you?

    Would it be possible to update the controls for the new input system?

    I made this update, but I think for other people, it would be cool.

    Another interesting feature would be the "mirror" feature, painting on one side, reflects on the other

    Thanks for your attention.
     
    Last edited: Sep 6, 2021
  35. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Thanks for your reply! I'm good, hope you're doing well too :)

    Wow! It sounds amazing! I planning to add new Input System support with update v. 2.6, can you share with me your implementation? My email: unitymedved@gmail.com

    Can you tell me more about "mirror" feature in details? Do you paint on 3D objects?
     
  36. drbatuira

    drbatuira

    Joined:
    May 4, 2020
    Posts:
    23
    I just sent you an email, to make it easier, I made a zip with your product already changed, explaining where I changed it =)

    I'm in prototyping, I don't know your code, I just made it work to test. Sure you know where else to change.

    The cool thing about the new input system is that you can configure the action in code, regardless of how many/what controls, VR/keyboard/mouse.

    About the mirror, I thought:
    I'm painting a car, when I paint on one side, I want it to paint on the other side too.
    In the image, it would be as if the UV map were mirrored in the middle, when painting with red, it would also be painted pink (in this case it would be the same color, I paint on one side and it will be reflected on the other side of the UV map)

    upload_2021-9-6_16-38-23.png
     
  37. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Thanks for sharing! I appreciate it a lot!

    About the mirror:
    You can get paint positions and draw dots/lines with offset on other side using next code:

    Code (CSharp):
    1. PaintManager.PaintObject.DrawPoint(new Vector3(512, 512)); // drawing a point, where argument - position on texture
    2. PaintManager.PaintObject.DrawLine(new Vector2(400, 612), new Vector2(100, 100)); // drawing a line, where arguments - start and end position on texture
    I'll think how to implement it into the new tool, thanks you for an idea!
     
  38. kmedved

    kmedved

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

    What's new:
    New Features:
    - Added Brush Preset System: create your own brushes presets or just use built-in
    - Added ability to change angle of the Brush
    - Added Paint Modes: default and additive
    - Added ablitiy to block Canvas raycasts for all supported components
    - Now PaintManager has its own Brush, Tool and PaintMode: use shared settings for all PaintManagers or set the values independently
    - Added events to PaintManager

    Editor:
    - Added PropertyDrawer for Brush class
    - General Inpectors improvements
    - Updated Manual
    - Added API Changes document

    Core:
    - Rewritten tools, now tools take up less memory
    - Optimized clone, blur tool and gaussian blur tool
    - Fixed brush preview when brush size has large value
    - Fixed bug when paint has incorrent UV value when model transform had non-default scale value

    Other:
    - Bug fixes
    - API changes

    Small Paint Modes comparing:
     
    drbatuira and Gekigengar like this.
  39. kmedved

    kmedved

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

    What's new:
    Core: Fixed performance issues
     
    Gekigengar likes this.
  40. O-H-42

    O-H-42

    Joined:
    Jul 15, 2020
    Posts:
    4
    Hello.
    I'm looking into using this Paint Asset in Hololens2.
    There was mention of VR support, but is it possible to use it in AR games and coexist with MRTKv2?
    If they are possible, how can I use them?
    Thank you very much.
     
  41. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hello! Thanks for your question!
    Unfortunately I didn't have experience with MRTKv2, but I'm sure that it will work. You need to write your functional for invoking start/finish drawing (it can be pressing button down/up for your device) in InputController.cs (it contains comments where do you need to add it), set flag IsVRMode and PenTransform in InputController component. That should be enough :)
     
  42. O-H-42

    O-H-42

    Joined:
    Jul 15, 2020
    Posts:
    4
    Thank you for your reply. I'm going to buy it and try to use.
     
    kmedved likes this.
  43. ANILAYAZ

    ANILAYAZ

    Joined:
    Mar 10, 2021
    Posts:
    5
    Hello,
    Is there a way for me to read vertexcolor information via triangles and use it as a mask? I want to be able to mask the painting input on a surface.

    I want to be able to switch between different masks.

    E.G.: painting a character's face. I want to use vertex color values to determine where to paint on demand. If it is lips, lips have color32(0,0,255,255) and I want to use it as a mask. But later on if it is eyeliner, then use color32(255,0,0,255)
     
    Last edited: Nov 15, 2021
  44. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Hi! Thanks for your question!
    From the box, asset does not support getting vertex colors while user paint, but I think that you can do it in another way: for masking, I'd recommend to use it with different meshes or submeshes, in that way you can paint only mesh that you need :)
    Let me know if you have any questions
     
  45. ANILAYAZ

    ANILAYAZ

    Joined:
    Mar 10, 2021
    Posts:
    5
    Thank you very much for your quick reply!

    This would add a bit of extra complexity for the skinned meshes I think and also would cause hard seams for the masked areas.

    I am trying to find the most optimized way for achieving the result below basically.
    [02.25]


    Here they use texture masks. I'd like to find a cheap way to integrate it to the 2d/3d package as well. (lower eyeliner section after [02.55])

    So actually they swap masks then paint in it. I'd love to get some technical suggestions regarding this process.
     
    Last edited: Nov 15, 2021
  46. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    189
    Are you using mesh with one submesh and material? If so, I think that good solution is to create shader that will use mask texture alpha to paint on specific area and switch mask texture to change paint area. Before you switch your mask texture, you can bake result into Texture or RenderTexture to save previous result of painting. I suppose that this will not require changing the asset code.
    Please note that this method may have a large memory consumption, depending on the number and size of your textures
     
  47. kmedved

    kmedved

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

    What's new:
    Core:
    - Fixed DirectX11/12 issues

    Other:
    - Improved AverageColorCalculator accuracy
    - AverageColorCalculator.SkipAlphaPixels field was renamed to SkipTransparentPixels
     
  48. drbatuira

    drbatuira

    Joined:
    May 4, 2020
    Posts:
    23
    @kmedved , hello again.

    What file/script can I get where painting is being done?

    I want to test this displacement.

    Thanks
     
  49. kmedved

    kmedved

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

    If you need painting result, you can get it using methods:

    - PaintManager.GetResultRenderTexture() - returns result RenderTexture (source texture + painting texture + preview);
    - PaintManagerGetResultTexture() - returns the resulting texture;

    Let me know if you have any questions
     
  50. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Last edited: Feb 3, 2022