Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

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

  1. murat303

    murat303

    Joined:
    May 22, 2014
    Posts:
    38
    Hi, I own two assets. I created a character with multiple sub-meshes in Character Creator, and I want to paint an alpha map for this character. I can do this in Paint in 3D, but I can't do it in Paint in Editor. When I look at the Analyze section, the Editor Asset doesn't see the sub-meshes, I can only paint the first submesh.
     
  2. Funtyx

    Funtyx

    Joined:
    May 3, 2017
    Posts:
    39
    In our car game there are several materials for each part of the car, how to combine all the painted decals on each part into one texture? Also, in addition to the decals, we also change the properties of the Metalic and Roughness material on each part and these values in numbers, how to combine both the decals and the Metalic and Roughness properties into one material with one Albedo and Metalic texture. The Metalic and Roughness properties and their numbers can be converted to a texture. Is this possible with your asset?
     
  3. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Hi Carlos, My VR 3d object paint app is progressing well. I'm looking to what I can add to its features and wondered if painting curvature maps can be done or added to paint in 3d. this would give users ability for worn edges look etc. I think the paint would be targeted to hit only certain angles on the mesh or normals. Images below shows the lighter paintable areas.

     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    Oh I see, thanks I'll fix it in the next version.


    In the latest version you can just change the material and it will work as expected. In older versions it would clone the material and make it harder to do, but this is no longer the default setting.


    Paint in 3D comes with the Presets system to make this easier to do. You can read about it HERE.


    By default, the counters will count all pixels in your texture. However, it's likely your mesh UV doesn't utilize all the pixels available, so it will be impossible to paint them all. Therefore the counter's MaskMesh and MaskTexture settings can be used to only count specific pixels. In your scenario you can just set the MaskMesh to the original mesh and it should work.
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    When you say several materials for each part, do you mean they are all transparent and act as layers stacked on top of each other?

    If so, you must combine them together with a custom script. For example, you can make a RenderTexture, and call Graphics.Blit to copy your base layer into it. You can then do Blit for each additional layer, but you must use the version of Blit that takes a Material, where the material uses Alpha Blending transparency, like the default sprite shader.

    To make a PBR texture from a PBR setting you also need a custom script. In this case you can make a Texture2D that is 1x1 pixel, and set that pixel to the PBR value you want.


    This is something I plan to look into adding to Paint in Editor. If it's not too difficult or performance intensive then I can also port it to Paint in 3D, but I'm not sure as I've never written this kind of code before.
     
  6. Davidnovarro

    Davidnovarro

    Joined:
    Oct 6, 2015
    Posts:
    22
    Hello, there is a bug in Mesh Fixer.
    upload_2024-3-16_13-16-2.png
     
  7. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    That's great, I look forward to seeing it.
     
    Darkcoder likes this.
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    Thanks, I'll check it out next week after I get back.
     
  9. The11thAlchemist

    The11thAlchemist

    Joined:
    Aug 10, 2020
    Posts:
    30
    Hello Darkcoder. I'm having an issue changing the CWPaintSphere blendmode channels at runtime. I'm able to change the channels in the Inspector at runtime, but not with code. Maybe I'm using your code wrong but I thought I could change the channels in the component using paintBrush.BlendMode.Channels.Set(1,0,0,0). I'm able to change color, opacity, scale, radius all by script but not the channels. Any tips would be appreciated. Unfortunately, I can't just use opacity because I've got each channel set for different properties (smoothness, metallic, emission strength) and I want to be able to adjust each individually whereas reducing opacity reduces all of them.
     
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    BlendMode is a property that returns a struct, so you cannot modify it like this. You can copy the BlendMode value out, modify it, and then assign it back, or directly assign it with a new BlendMode.
     
  11. The11thAlchemist

    The11thAlchemist

    Joined:
    Aug 10, 2020
    Posts:
    30
    Wow! Thanks for the fast response. Got it working
     
    Darkcoder likes this.
  12. Cerberus_team

    Cerberus_team

    Joined:
    Apr 9, 2014
    Posts:
    43
    Is there a way to Undo at a specific Index?
    I have 5 decals and i am trying to delete the 3th one, is this possible?
    I am using the local command copy to Undo.
     
  13. Funtyx

    Funtyx

    Joined:
    May 3, 2017
    Posts:
    39
    Good evening, I hope you're doing well.
    Could you please help with the following issue: In the screenshot, we see an editor with PaintableObject, through which, if we add a decal, we can export it to a texture and then use it in a material. Could you advise on how we can find all these textures after drawing (are they stored in memory)? We need to export all textures from the "PaintableObjects" editor into one large texture and then apply this texture to the material. I will attach a screenshot from Figma where we separately exported textures like paint_r_bumper, paint_hood, paint_door individually and manually combined them into one texture. Is there any solution to export all the necessary textures at once, rather than each one separately? I've written my script, but I can't access the objects from the editor. And the objects I do get are without decals.
    I'm attaching screenshots of the editor and one large texture that I would like to obtain as output during export and my script.
     

    Attached Files:

  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    Each CwPaintableMeshTexture component has the States list, which stores all undo/redo states. When using LocalCommandCopy, each state's paint commands are stored in the Commands list, which you can modify.


    It's not clear exactly what you're asking here. Let's say you get a list of 10 textures, how should they be combined? I don't see any Figma screenshot, and your code appears to just loop through each texture and write them on top of each other without any blending. So every texture except the last will be overwritten.

    If you want to create something like a texture atlas then Unity actually has this functionality built-in with the Texture2D.PackTextures function which will give you a list of coordinates that don't overlap, and you can then copy the pixels across. If you just want to show these textures together in any order then this is fine, but if you want to apply it to a mesh you would also need to modify the mesh UV which is more difficult.

    Or do you want to layer the textures on top of each other like in Photoshop or something?
     
  15. Funtyx

    Funtyx

    Joined:
    May 3, 2017
    Posts:
    39


    Good day!
    In your editor, I can manually export all the necessary textures one by one. However, how can I export all the textures located in the PaintableObject window at once, turning them into a single texture, preferably not manually but somehow through code? Because if I export the _AlbedoTex texture from the material, it is empty, without the decal, whereas if I export the texture manually from the PaintableObject window, I get the texture along with the decal in the "Asset" folder.
     
  16. Funtyx

    Funtyx

    Joined:
    May 3, 2017
    Posts:
    39
    Good afternoon How to save the decal texture through code, at runtime? We save the texture through your editor, but we are interested in saving it through code.
     
  17. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Hi,In an Android build the flow blend mode is not vey effective when using the flow right normal map. In windows build its good. Is there any adjustments that can strengthen the effect of the flow blend for making a good smudge effect on android.
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    You can find all paintable textures in your scene by looping through PaintCore.CwPaintableTexture.Instances, and then call GetReadableCopy() on each instance to get a Texture2D of it.



    The Flow blending mode itself should work the same on all platforms if applied to the same locations at the same time intervals. However, different platforms can have different screen resolutions, screen pixel densities, and frame rates. These can change how often the paint is applied as well as the paint spacing, which can change the way the Flow changes.

    For example, if your CwHitScreen component's Frequency is set to Once Every Frame, then devices with double the framerate will experience double the flow for the exact same movement. To make them work the same you can use Time Interval, which should work the same as long as each device is running at a high enough FPS to match the Interval seconds. If you want to guarantee the spacing then you can use Scaled Pixel Interval, but this can have performance issues for large swipes.

    If it still doesn't work as expected then let me know, it's possible there's some kind of normal map compression issue I'm not considering.
     
  19. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Ok, thanks, I'll try some of these setting changes. You mentioned normal compression and I had to change the player settings for normal map encoding for android to xyz as normal maps caused the paint to be all black on the other setting -(dxt5nm)
     
  20. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    I changed to Scaled Pixel Interval for the 2 smudge tools and that helped but I had to adjust the amount as it started to slow on my phone if it was set too low. The effect is usable on android now so many thanks.
     
    Darkcoder likes this.
  21. wibu_991

    wibu_991

    Joined:
    Mar 1, 2021
    Posts:
    3
    Hi, I'm working on a demo that includes the following feature:
    - Choose a color from the color palette then draw it to the palette below
    - Summarize the color of each area of the table based on the painted colors (for example, the areas marked 1,2,3,4).

    I have completed the color selection and coloring part, do you have any suggestions to get the color of each area?


    demo.PNG
     
    Last edited: Apr 15, 2024
  22. FrenzooInfo

    FrenzooInfo

    Joined:
    May 2, 2014
    Posts:
    47
    Hi Carlos,
    We bought your paint3D package and it has been very helpful for us. However I am trying to do screenspace decal and not having a lot of success with the sizes.

    Basically I would like to stamp a screenspace decal onto a mesh something like texture projection. I just can't seem to get the size correct. Perhaps I'm not using the right component?

    For the most basic procedure.
    1. Take a snapshot of the screen. It has a mesh rendered on it. The texture is the same size as the snapshot.
    2. Modify the texture externally.
    3. Use the decal component and paste the texture back onto the mesh.

    The default scaling is small square of the decal. I am using it programmatically so I'll be pasting inside the viewport at 0.5,0.5 right in the middle.
    What is the scaling that I should use to ensure that it's correct? Or possible if I'm using the wrong component. Which component should I be using? Or should I be using the tiled option of the decal painter?
     
  23. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Hi, The undo / redo slows down a lot the more I paint. I have it set for local command copy as full texture copy uses too much memory as I'm painting on 4k paintable textures. Is there a way to limit the local command copy states as this could be what's slowing things.

    Also, When I add a local mask at runtime it does not work. The 3d object was loaded at runtime from an external folder and the paintable mesh and texture components added then as well.
    If I add the local mask texture on the example scene it works ok. It works also if I pre add it to the object before loading but this is not what I need as I want the user to be able to add their own mask at runtime. is there a reset or clear that needs to be done on the paintable texture or something else?
     
    Last edited: Apr 18, 2024
  24. yetion

    yetion

    Joined:
    Feb 17, 2020
    Posts:
    1
    Hi!
    I am experiencing an issue with the Change Counter in Paint 2D. When I am painting on a drawing that utilizes masks to paint different parts, the problem only arises when using Blend : AlphaBlend(1,1,1,1). When i reach second part, it immediately shows 100% of the count, even if I have not yet started.
    Steps:
    1) Draw first part with AlphaBlend(1,1,1,1)
    2) Update texture and mask -> call these methods:
    counter.MarkMaskReaderAsDirty();
    counter.MarkCurrentReaderAsDirty();
    3) Start second part -> automatically marked count as total.
     
  25. globichopf

    globichopf

    Joined:
    Apr 18, 2017
    Posts:
    1
    Hi
    When using fast playmode options and skipping domain reloads, I got errors about meshes being null for paintable meshes using AutoSeamFix. The errors only occured after entering playmode more than once.
    When debugging, I noticed that the CwMeshFixer.cacheFirst dictionaries had old entries in them (from previous play-mode sessions) and many of the cached fixed meshes were null.
    I'm on 4.1.1.

    I added a fix/workaround by clearing the dictionaries in CwMeshFixer before the first scene is loaded:

    Code (CSharp):
    1.    
    2. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    3. private static void Init()
    4. {
    5.    cacheFirst.Clear();
    6.    cacheSecond.Clear();
    7.    cacheThird.Clear();
    8.    cacheFourth.Clear();
    9. }
    10.  
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    You can use the CwColorCounter component to count how many pixels or % of a texture is painted with specific colors. You can configure 4 of these, and use the MaskTexture setting to isolate each to a specific quadrant.


    Paint in 3D currently doesn't have any component to paint in screen space. If your camera is orthographic then CwHitScreen with the correct decal scale can do it, but not for perspective painting. The challenge with this is that all the existing paint components only send world space 3D hit point data, whereas screen space painting requires sending a matrix or screen space coordinates + camera data, so I'll have to think about which approach is best and how this will combine with the connected hit painting, clip painting, etc.

    If the local commands get limited then you wouldn't be able to undo properly once you reach the limit. One solution is to make a hybrid undo/redo system, where it stores a full state every 'n' local commands, but I haven't had a chance to look into it yet.

    Regarding the local mask you may have to manually call MarkMaskReaderAsDirty method after. If you let me know which component you're referring to here, is it the change counter or something?

    I'll test it out next week.

    Thanks, this is a feature I need to test with all my assets.
     
  27. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Does that mean in undo/redo a limit like the full texture copy method has?

    I'm adding a local mask texture at runtime to a paintable mesh texture component ( set for albedo ) that is on a object loaded from an external file but it doesn't mask. If I do this on an object that is already in the hierarchy it works ok.
     
    Last edited: Apr 22, 2024
  28. FrenzooInfo

    FrenzooInfo

    Joined:
    May 2, 2014
    Posts:
    47
    Hi Carlos,
    I am using an orthographic camera so I won't need perspective. Just need the exact decal scale or how I can calculate the exact decal scaling, given the ortho camera size. Hope you can help me with that.

    Thanks
     
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,416
    I can't replicate this issue. I modified the "07 Change Counter" demo scene to use a mask texture that is of the left side of the book, and a script that later calls:

    Code (csharp):
    1.  
    2.         var p = GetComponent<PaintIn2D.CwPaintableSpriteTexture>();
    3.         var c = GetComponent<PaintCore.CwChangeCounter>();
    4.  
    5.         p.LocalMaskTexture = otherMask;
    6.  
    7.         c.MaskTexture = otherMask;
    8.         c.MarkMaskReaderAsDirty();
    9.         c.MarkCurrentReaderAsDirty();
    This otherMask is of the right side of the book, and the change counter automatically updates to 0% change as expected, and painting the right side then increases as expected. If this issue persists I need you to prepare a really simple demo scene and send it to me via email or private message.


    There's no limit to Local Command Copy, otherwise you would be unable to undo after a certain point, it just gets slower and slower as you notice.

    Did you try calling MarkMaskReaderAsDirty as I mentioned?


    Great, then you just need your camera's Orthographic Size and Aspect Ratio settings. So for example if the orthographic size is 1, then a decal with a size of 1 should fill the whole screen vertically when painting at the center. Maybe I can make a demo scene for this in the next version.
     
  30. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Hi,I have called the void dirty materials in the paintable mesh for the loaded object ( using playmaker) after I add the local mask to the albedo- see image. This didn't work. What I found was if I paint with the local mask in place which does not seem to block anything then I undo and redo it shows the masked paint on the object??
    upload_2024-4-24_12-7-56.png


    Also, good news I am able to use the dynamic mask to paint edge/cavity effects by using a screen space shader from the asset store to create a dark light effect on a clone object seen by a mask camera which sends to the dynamic texture for the mask. All has to be in orthographic view for it to work. your dynamic mask demo was very helpful. Screenshot 2024-04-24 121620.png Screenshot 2024-04-24 122033.png Screenshot 2024-04-24 122946.png Screenshot 2024-04-24 123206.png
    Now just to get it working in VR!
     
    Last edited: Apr 24, 2024
  31. FrenzooInfo

    FrenzooInfo

    Joined:
    May 2, 2014
    Posts:
    47
     
  32. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    35
    Hi, In my app, If I destroy the current object I've painted then load another object in, the new object is unpaintable even with all it paintable mesh textures in place. The only way I can get a new model to be paintable is to completely shutdown the app and restart it. Is there a way to reset the new object to be paintable? i get this error:

    MissingReferenceException: The object of type 'CwPaintableMeshTexture' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
     
  33. f36893689

    f36893689

    Joined:
    Aug 17, 2021
    Posts:
    2
    how to use multi touch in this assets
     
  34. cr4y

    cr4y

    Joined:
    Jul 12, 2012
    Posts:
    45
    Hi,
    I'm using this amazing asset with my own shaders.
    During gameplay, I need to render the material to Texture2D (I achieve that by using Graphics.Blit() - if you have a better suggestion, please tell me).
    Unfortunately, after doing it on render, I cannot see modifications painted by the player.
    I suppose it is because this is the result of some low-level optimizations in this package. Do you know what I should do to see the user drawing on the final rendering?
    Thanks in advance!
     
    Last edited: May 3, 2024
  35. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    362
    Helloo,
    I have a problem with paint in editor. We used and older version of paint in 3d for a while now (very happily btw). But only really in editor, hence I was super excited when I discovered today that paint in editor has become it's own cleanly separated asset.

    However I found a few issues.

    First sticker brushes don't work for me. This is the Overlapping UV Mesh Cube scene and I paint on the unwrapped cube. The sticker only writes grey to albedo. The normal dent stickers have a similar problem.
    upload_2024-5-7_16-15-3.png

    --> I poked around because I also wanted Pen pressure support and I think I found the reason why stickers don't work.

    decalMaterial.SetTexture(_CwPaintTexture, tex) is never called in CwEditorBrush_Sticker.cs
    if I set albedoTex for that texture property the stickers start working.


    Another problem I faced is that the Angle setting sometimes prevents me from drawing to the texture while in orthographic mode. Depending on view angle and the angle set the in paint settings the brush does paint or not.


    And one more which is pretty bad but solveable, if HDR rendering is enabled in the URP asset
    depthCamera.RenderWithShader() spams the console with rendertexture errors and prevents the asset from working. The fix though is simply after calling CopyFrom(sourceCamera) setting depthCamera.allowHDR = false;

    Unity version is 2022.3.25f1
     

    Attached Files:

    Last edited: May 7, 2024
  36. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    75
    Hello, I am making a game where players can make vehicles by placing components together. Each component is a ProBuilder mesh. The player can also alter the mesh in-game by adjusting the mesh's faces, edges and vertex. After the player has adjusted the meshes on their vehicle, I would like to use Paint in 3D to enable the player to paint the vehicle. Will Paint in 3D work with ProBuilder meshes that have been altered? The original meshes were made in Blender, and their UV's unwrapped using the automatic UV tool, and then imported into Unity and ProBuilderised.
     
  37. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    362
    I am not the developer therefore this might not be 100% accurate, but as long as the UVs don't change and are layed out correctly it should not matter if the meshes are probuilder meshes or not.
     
  38. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    75
    Hi Fleity, thank you for your reply. When making the meshes in Blender, I used the UV smart unwrap, which appears to have made the UV layout without any overlaps. However, when the player adjusts the mesh in the game (by adjusting the positions of vertices, which changes the shape of the faces) I am wondering if the UV is automatically adjusted to to reflect the face changes. If not, the textures will appear stretched or shrunk. Do you know if this happens? Appreciate your help!
     
  39. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    362
    I do, the UVs are not automatically adjusted for that change, the texture will stretch.
     
    DromoDesigner likes this.
  40. kuropentakill

    kuropentakill

    Joined:
    Nov 23, 2019
    Posts:
    1
  41. ducloc96

    ducloc96

    Joined:
    Mar 18, 2018
    Posts:
    27
    Hi!
    I'm using Paint In 3D and checking the Splat Map Painting scene. I wonder if there is a function that can automatically gradually change the green palette to "Albedo R" or "Albedo G" textures...?

    image_001_0001.jpg Screenshot 2024-05-19 004121.png