Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

【50% OFF】 ⏱Paint In 3D ️️✏️ In Game & In Editor & Skinned Mesh Painting

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

  1. ppd-enrique

    ppd-enrique

    Joined:
    Jun 16, 2022
    Posts:
    4
    Looks like it'll work! Thank you very much!!
     
    Darkcoder likes this.
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,231
    Is there any way to have custom brushes for splatmap painting? I made a new Splatter brush, and selected it, but painting on the mesh, it's still a simple white sphere:

     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    How is your paint material configured? If it's using child P3dPaintDecal components (like all the example paint materials), then the "Shape" you set will be applied to your material. You can check the "P3dPaintableManager" GameObject in your scene, the tool + material will be spawned in there. For example:

    upload_2022-7-7_13-2-49.png

    You can see the Decal tool has been spawned with the Stone_Path_001 material, and every P3dPaintDecal component from the material has its Shape setting set to the "Square C" I picked.
     
    Last edited: Jul 7, 2022
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,231
    Thanks...but as I said, I'm painting splatmaps, and the P3dPaintableManager object (which only appears at runtime) has nothing in the inspector, nor any children. The Red/Green/Blue/Alpha objects that are children of the Tools object in the hierarchy have no Shape input field. I'm using the Splatmap Demo scene.
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    I see, then you're not using the in-editor painting features (the Paint in 3D window), so you can close it as it's not important. If your splat map painting tools are using the P3dPaintDecal component then you will want to manually set the 'Shape' setting, similar to the screenshot I posted.
     
  6. alfredbaudisch

    alfredbaudisch

    Joined:
    Dec 13, 2010
    Posts:
    25
    Before I buy, I want to know if I can I do the following (wash/clean dirt/rust mechanism):
    1. Let's say my Mesh has a material where I the Albedo comes from 3 blended textures with Lerp. Example: a car that has a base texture, then it has a dirt texture that cover portions of the car (Base Texture -> Lerped with Dirt -> the amount comes from b&w/alpha texture).
    2. With Paint in 3D I want to paint the blending texture that defines the dirt amount. Basically I will either erase the white parts or paint with black. In the car example, I will wash the dirt from the car.
    3. I also want the brush to be a custom brush that I can rotate, resize, etc. In this case, the brush can be a custom material, where then I rotate and change the shape with material uniforms.
    Does Paint in 3D allows me to do that?
    1. Paint a texture that is used by the mesh to lerp with other textures (in this case I can also make the custom shader)?
    2. Use a custom material as brush or an adjustable brush?
    Example that I accomplished in UE:

     
    Last edited: Jul 12, 2022
  7. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Hello there again!
    Once again i am struggling with some stuff:(
    I am using a SprayPaint mode to paint "transperancy" as i've mentioned before (your advice worked like a charm btw, thank you!).
    My paint area is quite small, so i've tried to make the brush itself smaller. But when i do it accordingly to manual, it stops painting. So basicallly: as long as radius of the brush is less then 0.3 - it doesnt paint. Can you please help me figure it out? Here are my settings:
    2022-07-12 175405.png 2022-07-12 175835.png
     
  8. jsinisi001

    jsinisi001

    Joined:
    Sep 23, 2014
    Posts:
    4
    Was anyone able to get this to work with FinalIK, or VRIK more specifically? All the bones look like they're in the right places and aligned with what's being rendered, just controlled by VRIK, but Paint in 3D seems to be ignoring the bone positions and painting as if VRIK is disabled and it's just the animator driving things.
     
  9. jsinisi001

    jsinisi001

    Joined:
    Sep 23, 2014
    Posts:
    4
    For anyone in the future who wants this to run with VRIK, I actually just found the solution a few minutes after asking lol. Just go to script execution order, drag in P3dPaintableManager, drag it all the way to the bottom below VRIK, and hit apply. It should now be working perfectly and without weird offsets. Awesome asset btw!
     
    Last edited: Jul 13, 2022
    hopeful and Darkcoder like this.
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    Yes, this scenario would be very easy to configure with Paint in 3D.

    The 'Start Size' of your particles is 0.3 units. When the particles hit, I assume Unity reports the particle position (i.e. 0.3 units away from the surface), rather than the hit point. This would explain why the paint doesn't appear when your paint radius is below 0.3 units. You can use the P3dPaintDebug component to visualize where the paint hit data is being applied to verify this. To get the true hit point the particle collision position result would need to be moved toward the surface by the radius of the particle. However, from what I can see there's no way to get the radius (or any information) from a particle collision event. At best you could modify the P3dHitParticles code (OnParticleCollision method, finalPosition = ... part) so the hit point is moved toward the surface based on the hit normal and the initial particle radius data from the ParticleSystem.


    Thanks. Glad you found a solution!
     
    alfredbaudisch likes this.
  11. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Thanks a lot for your explanation! It all worked out, when you explained - i just needed the brush size to be slightly bigger then the particles size:)
    <3
     
    Darkcoder likes this.
  12. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,231

    There is no P3PaintDecal component in use. I'm using your Splat Map demo scene, the tools there have P3DHitScreen and P3DPaintSphere components, and the mesh to be painted has P3DPaintable, P3DMaterialCloner, and P3DPaintableTexture. Could you look at your demo scene and see how/where to assign a custom brush?

    thanks
    Dave
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    I see, then you will have to replace the P3dPaintSphere components used in this scene with P3dPaintDecal components, give them similar settings, and you will then be able to set the shape.
     
  14. GreaterHawkeye

    GreaterHawkeye

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

    I'm trying to setup a scene with FPS view and still be able to paint.
    I created a new Unity Project with the FPS Template where we got a PlayerCapsule that can run etc, with some ProBuilder environments.

    Can I setup this scene to work with PaintIn3D?
    I added the P3D Paintable component to the 3D objects on the scene and clicked the buttons Add Paintable Texture and Add Material Cloner
    I created a "Painter" object (randomly put that in the middle of the scene), added P3D Hit Screen and P3D Paint Sphere to it.

    Now I'm walking in the scene (FPS view) but cannot paint on the objects (also tried with a good old 3D Cube I just created). I guess this is due to some kind of P3D Hit Screen I should setup in order to correctly raycast from the camera view to the objects?

    Thanks!
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    P3dHitScreen performs a raycast from the camera position toward the mouse/finger. If your camera is surrounded by a CapsuleCollider, then it might be hitting that before it hits any paintable objects in your scene. You can try putting the capsule on a different layer, and changing the P3dHitScreen's Layers so they don't conflict.

    If you want to shoot at the center of the screen like in many FPS games, then you might want to use P3dHitBetween instead, which can be set to fire between the camera position, and some Transform in front of the camera. The same collider layer issue may exist though. If you're using this component you may want to disable it and manually call its ManuallyHitNow method when you shoot.
     
  16. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    As my cursor is locked in the screen I assume it is in the center of the screen anyway so I think I could go for HitScreen. I also put the "Painter" GameObject (the one who's got the P3DPaintSphere and P3DHitScreen components) outside the Player, I don't think this is necessary to have it into it.

    But still that doesn't work. I even tried to put the camera outside the player, like a bit above it.

    Did I miss something in the configs?

    The scene:
    upload_2022-7-21_16-50-38.png

    The cube I want to paint on:
    upload_2022-7-21_16-49-55.png

    The "Painter" Object:

    upload_2022-7-21_16-53-2.png

    The Capsule with the camera a bit above:
    upload_2022-7-21_16-53-57.png

    Thank you very much for you help!
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    One issue I can see is you're painting _MainTex, which is a fake texture slot in URP. See HERE for the solution to that.

    You can also use the P3dPaintDebug component to see where paint is being applied in the Scene view.
     
    GreaterHawkeye likes this.
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,231
    Okay, I tried that, but nothing else works as you describe. The P3dPaintableManager object (which only appears at runtime) still has nothing in the inspector, nor any children. Choosing different options in the Paint in 3D: Paint tab has no effect on the actual brush, and the brushstroke is always one pixel, changing the size values has no effect.

    It would be cool to have a Splatmap demo scene set up in a way to work like this, but I sure can't figure out how to do it. I will switch back and use Photoshop.
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    The painting in the Splat Map demo scene works using the "Tools/___" child GameObjects. These GameObjects use the P3dPaintSphere components, which you must replace. You should completely ignore the main Paint in 3D window (you should probably close it), and completely ignore the P3dPaintableManager.

    All of this confusion is arising because you're combining the in-editor features with the in-game painting examples, when they're designed to be separate. If you just stick to one workflow (in-game in this case), then everything will become clear.
     
  20. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    301
    Quick question - Does this asset support Filling of connected polygons? Not filling the entire mesh but filling an area by connected vertexes
     
  21. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    69
    Hey @Darkcoder

    I've run into an issue that I'm not sure how to fix.

    Seems to be a problem with the 40 Undo Redo scene and using the Unity Input System package.

    Here's the correct behaviour using the old input system (Input Manager):


    And here, the incorrect behaviour, is with the new input system (video shows v1.2.0, but have tested with 1.3 and 1.4.1)


    Issue description:
    - I'm simply tapping the undo button which on the second tap incorrectly triggers the redo button to be enabled
    - Then I tap and hold the undo button and drag down which incorrectly produces paint stroke on mesh

    Other details:
    - Paint in 3D v2.0.3
    - Unity 2019.4.35f1
    - Video captures recorded on Android 10 (Samsung Note 9)
    - Weirdly, regardless of input system used, issue can also be seen in editor (using pc with touchscreen), however with mouse, the problem doesn't appear
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    Paint in 3D has a feature where you can paint the triangle underneath the mouse/finger. To make it paint multiple triangles like a quad or complex polygon you would have to modify the code to calculate which other triangles to paint, and then loop the same triangle painting code over them.


    I just made a new project with Unity 2019.4.39f1, Input System (1.3.0) package only, and Paint in 3D 2.0.3. The Undo Redo demo scene works as expected on my Pixel 6. Perhaps the specific version you're using had some bug that would cause this?
     
  23. GreaterHawkeye

    GreaterHawkeye

    Joined:
    Apr 13, 2017
    Posts:
    34
    It worked, thanks :)

    Another question on another subject: I'm trying to add multiplayer (networking) to the scene, have you already tried that with PaintIn3D? If yes, do you have high level advices on syncing the painted textures through different clients (what networking library to use, like Netcode or FishNet, what to be aware of, what should be synced exactly...)

    Thank you very much!
     
  24. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    69
    I downloaded .39f1 and did the same tests from a fresh install and had mixed results. And just to confirm I was using the v1.3.0 Input System and set my project to use "Input System Package (New)" option, not the "Both" option.

    These showed the issue:
    - Samsung Note 9, Android 10
    - Samsung S10, Android 11
    - In editor (Windows 10, Lenovo Yoga 12)

    These didn't show the issue:
    - Samsung A8, Android 9
    - Pixel 2, Android 11
    - iPhone X, iOS 14 (I think)

    I started debugging and noticed that on the devices with the problem the CwInputManager.AddFinger method gets called twice and on the second time, the ray cast made in PointOverGUI doesn't hit the gui. I'll continue debugging but that's where I'm at right now.

    Any thoughts?

    EDIT:

    It seems like for Android when there's a mouse plugged in, the problem will appear. I think for the Android devices that showed the issue without a mouse, CwInput.GetMouseExists still returned true for some reason. For now I can just return false on Android so I can move on. Let me know if there's a proper fix though.
     
    Last edited: Jul 25, 2022
  25. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    The "72 Simulated Multiplayer" demo scene shows you how the setup might look like. There are no actual multiplayer examples though, because there are so many systems and I'd rather not deal with maintaining that.



    Interesting. Well if it reports there being a mouse then that still shouldn't cause issues, unless Unity is somehow also saying the mouse is going down when you touch the screen. I don't know about the new Input System, but legacy Input has some setting where it emulates a mouse using data from the first finger. I presume this system is to make mouse-only controls still work on touch screens, but of course this would cause issues like you see since it will paint the scene, thus messing up the way undo/redo works... at least if the mouse position is different from the touch position.

    In any case, I don't have a mobile mouse or touch screen monitor. It would be easiest if you can make a custom component that can read out the data from the CwInputManager to see what Unity thinks is happening. This code just outputs what the InputSystem sees, so it's unlikely there's much I can do unless I manually override the reported values based on something?
     
  26. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    69
    I think you can replicate it if you just force CwInput.GetMouseExists to return true and build that to your Android device. Other than that a bluetooth mouse maybe (I was using a wired USB mouse). I'll try to have a look, though.
     
  27. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    12
    could we use virtual mouse to paint?
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    The mouse existing wouldn't cause the issue you describe, because the only thing that would change is the mouse hover would exist. While the mouse hover applies preview paint under the mouse, it doesn't perform any actual paint or store any paint states. The issue in your video is that when you tap the undo button it's also storing a paint state, this causes the undo button. Therefore I assume the issue is that for some reason a mouse click event is also being sent to Unity when you tap the screen, and the coordinates of this mouse must be different to your finger.


    With custom code, yes. The P3dHitScreen component uses the CwInputManager class for mouse/finger data. This class converts Unity's Input or InputSystem data into CwInputManager.Finger data. So for a virtual finger you would modify the code to CwInputManager's Update method to call the AddFinger method with your virtual mouse.
     
  29. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    12
    Thank you very much, another question: I created a game where four players together paint a surface using joysticks,
    Sometimes for one of the players it doesn't color for a few seconds, then comes back to color, could it be too heavy?
     
  30. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,231
    I'm just using the Splatmap demo scene, with my own mesh added, so I have no idea how I ended up combining in-editor and in-game methods.

    I've now tried using the splatmap method with the Basic Setup scene, but I don't know how to get the onscreen color channel buttons. I've tried making a standard brush in the splatmap scene, but it doesn't work at all. The documentation has one sentence about splatmap mode, so I have no idea how to create a functioning splatmap scene myself. Would it be at all possible to get a demo splatmap scene that will work with custom brushes?
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    I have no idea, you'll have to debug it and see what's happening.


    The "Paint in 3D" window's "Paint" tab is the in-editor painting. This is designed for painting standard textures like Albedo and Normal, so you shouldn't use it in this scenario.

    The reason why this asset isn't easy to use with splat maps is because Unity doesn't have any built-in splat map shaders or features for this, so there is no obvious way to support them and have them 'just work' with anything else.

    As an example I created the "Paint in 3D/Splat" shader, which is shown in the "Splat Map Painting" example. This shader has the "_SplatMap" texture, whose R/G/B/A textures define different splat maps. However, if you're using a different shader then this texture slot name is likely different, so you will want to change the P3dPaintableTexture component's Slot setting to what your shader does use:

    Inside this scene (like all the other in-game scenes) you can see the "Tools" GameObject, which has child GameObjects of all the different painting tools used for that example:

    upload_2022-7-29_13-5-36.png

    In this demo scene there are 4 tools to paint (R, G, B, A) and 1 to clear (all RGBA). These tools use the P3dHitScreen and P3dPaintSphere components to paint.

    The main difference between all the painting tools in this demo scene and the others is that:

    1 - The are painting to the Splat group, not the default Albedo group.

    upload_2022-7-29_13-15-28.png

    2 - They are using the Replace blending mode, not Alpha Blend:

    upload_2022-7-29_13-10-33.png

    3 - The colors must be set with opacity.

    upload_2022-7-29_13-10-50.png

    This color setting is key, because it defines how this particular paint tool will change the underlying splat map.

    As you can see in the above example, this tool is painting RGBA 0,1,0,0, aka the second splat map is being painted, and the other 3 splat map channels are being set to 0.

    To paint with a shape you must delete the P3dPaintSphere component, and replace it with P3dPaintDecal, and you must set these very important settings. It might look something like this:

    upload_2022-7-29_13-17-31.png

    I hope this clears things up.

    Also keep in mind this just an example of how splat map painting might work. For an actual project each user is probably using a completely different shader that may implement things differently, therefore this is quite an advanced aspect of this asset. I highly recommend you go through all the in-game tutorial demo scenes, as they will explain most of the pre-requisite information used here like how the tools work, how decals work, etc. If you skip all of this and go right to this example then it's no wonder it seems very confusing.
     
  32. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    69
    I'm not sure if the mouse existing would "cause" the issue, but I think it might be just uncovering the issue.

    I've had a look and am coming up to a wall. As far as I can tell CwInputManager is behaving normally. It triggers the OnFingerDown which P3dHitScreenBase is subscribed to.

    P3dHitScreenBase confuses me. So if I debug HandleFingerDown, after starting the scene, and on my first touch, the length of "fingers" (list) is 1, which has a finger index of -1337. Then in the LateUpdate, "fingers" has a length of two, where both finger index is -1337. Then on my second touch, HandleFingerDown has "fingers" as being a length of two, where the first item is finger index 0, with Down being true, and the second item is finger index -1337 with Down being false. So the finger with index 0 is the one that is giving me the incorrect touch.

    HandleFingerDown seems like it should not allow the incorrect Down from being added to "fingers" but it's already been added as a valid touch and that's where I get the invalid undo state.

    Also to clarify, when I'm touching on the screen, I'm touching a GUI layer which should prevent any painting.

    Any tips? Anything I can check?
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    Finger index -1337 is the mouse hover. This will be present if the input system reports there is a mouse connected.

    P3dHitScreenBase's OnEnable method adds all P3dInputManager.Fingers via HandleFingerDown, which is where the hover finger will be added. This finger shouldn't cause any undo/redo states to be created though, since it should never send any 'up' state.

    If it's incorrectly sending mouse down/up events then that will be finger index -1, which it sounds like you didn't see, so the issue must be from an actual finger (index 0 or greater)?

    What you need to check is the "P3dStateManager.StoreAllStates" method, and see when this is called. When you tap over a UI element this method shouldn't get called, but in your project for some reason it is, so you should get a stack trace for this.
     
  34. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    69
    Thanks, I'll take a deeper look. As I understand now though, StoreAllStates is getting called in P3dHitScreen.PaintEvery (I'm using once per frame frequency) because down equals to true. As mentioned in my previous post, there are two fingers existing on this frame where one is the actual touch finger (index 0), and the other is a hover. The actual touch has down equals true, which confirms what you suggested that it's coming from an actual finger.

    Also just to clarify, though, I'm not sure it's a problem with my project specifically. It seems like it's an issue when a device has touch input, in addition to mouse input. That's why the problem can be replicated by attaching a mouse to an Android device, or simply forcing CwInput.GetMouseExists() to return true (to simulate an attached mouse), which to my understanding shouldn't cause the issue itself.
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    Multiple fingers existing shouldn't be a problem, the issue is when a finger goes down for the first time it should trigger a StoreAllStates. If you've set the paint frequency to be once per frame then it should only call StoreAllStates on the first frame your finger goes down, all the other frames will be a finger held state which shouldn't cause this to get called.
     
  36. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    @Darkcoder Hi, I am just starting to use this great asset in Unity 2021.3.5f1 inHDRP. It seem like I have a litlle problem trying the basic demo. Left clicking on the Plane model does not paint anything. Any help would greatly appreciated. Thank you . Here is the error in my console:

    NullReferenceException: Object reference not set to an instance of an object
    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.PropertyEditor.DrawEditors (UnityEditor.Editor[] editors) (at <1f0be198f5164d2489de92f22c998266>:0)
    UnityEditor.PropertyEditor.RebuildContentsContainers () (at <1f0be198f5164d2489de92f22c998266>:0)
    UnityEditor.InspectorWindow.RedrawFromNative () (at <1f0be198f5164d2489de92f22c998266>:0)
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    This is from the "01 Basic Setup" demo scene?

    Also, you need to copy+paste the full stack trace, this doesn't show which source files and lines the NullReferenceException is coming from so it doesn't tell me much.
     
  38. magglemitch

    magglemitch

    Joined:
    Dec 8, 2013
    Posts:
    99
    I'm having a very weird issue. I've been noticing in my project a huge FPS drop on the Quest 1 when painting and have been trying to figure out what it is. I grabbed an old apk build and the fps drop wasn't there so something has happened since. I've then grabbed the git commit I did for that build and rebuilt it out again and for some reason the fps drop is there again. Could you know of anything that may be causing this?
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    Can you (deep) profile the code to see which part is causing the drop? Also, which two versions of the asset are you comparing, and what painting features are you using?
     
  40. Emphy

    Emphy

    Joined:
    Feb 7, 2014
    Posts:
    33
    Hey Darkcoder, awesome asset. Been tinkering with it and it's fun.

    From a practical POV: ok so I have some custom bullet script that knows when the bullet impacts. I added a P3D Hit Cache in the script and a P3D Decal painter component on the bullet. Works fine, I call hitcache.InvokePoint and yeah, awesome, my zombie gets splattered with blood in the face (or rather, where he's hit)!

    upload_2022-8-20_23-35-49.png

    Now, the P3D decal painter that paint the blood splatter is on the bullet and whilst fun, it could also hit other materials ofc. Flesh, stone, sand, you name it. What's the easiest way to go about this? Because P3D Decal painter has quite some useful options and I don't really want to recode all that. It seems a bit much to give every projectile type in my game a whole bunch of P3D Decal Painter components with different textures/colors and enable the one I need depending on the material it hits. Very impractical and much work.

    I was thinking maybe along the lines of ScriptableObjects for material, so that when a bullet hits an object we can ask it, what material are you and maybe also link to it the decal that's needed. But again, ideally it would be of the same order as your original decal painter, with all the options.

    Maybe you have a smart idea :)
     
  41. HonduneGames

    HonduneGames

    Joined:
    May 14, 2015
    Posts:
    5
    Hey @Darkcoder just picked up the package but im having a large problem that is making it unusable for me, im hoping im just doing something wrong and there is a way around it.

    Effectively it seams that there is no way to limit a decal to the current UV island, no matter how I set it up. Decals always bleed over into neighboring islands, even if the margins in the unwrap are massive. Is there any way to limit the decal to only the current UV island?

    Here is a quick example with a cube. I realize in a cube example you may be able to get away with it by using the normal limit settings (though even still with the beveled edges itll never be perfect), but on the actual complicated meshes in my project this is isnt a solution. I also realize potentially the local mask feature *could* be used to do this, but doing this for every uv island project wide would be a massive undertaking and take up a ton of space.

    The project is otherwise very impressive and blazingly fast, I really hope there is a way around this slight issue for my specific use case! Thanks!
    blender_Akg7WWOuni.png Unity_oZK0cxgOdp.png Unity_S9hVdObLrP.png
     
    Last edited: Aug 22, 2022
  42. ppd-enrique

    ppd-enrique

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

    Thank you very much for your assistance earlier. I've made a lot of progress with the implementation, but I have a strange bug that happens only on mobile builds.

    On my project I'm now able to paint a model and to keep track of how much it's painted using the p3dChannelCounter. It works perfectly in the Unity Editor.

    However when I actually build and test on iOS and Android devices, I can start painting as normal, but suddenly the painting behavior goes haywire. Two things happen:

    1) Unrelated parts of the texture become painted in strange patterns.
    2) The channel counter also over-counts massively.

    As I said, this bug happens only on mobile. I've tried a few things, but nothing seems to fix it.

    Would you happen to have any insight on what may be the cause?

    Thanks in advance.
     

    Attached Files:

  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    This really depends on what settings you are changing between material types and bullet types. From what I imagine, the best solution would be to make one P3dPaintDecal component per material type, and before you apply the decal you override any settings specific to that bullet like the radius or depth.


    By default the UV island locations don't matter, because the paint is applied in 3D where only the spatial position of each pixel matters.

    If you care about UV islands then you must paint in UV space (change P3dHit___ component to Emit = PointsOnUV). If you need to both paint in 3D and you care about UV islands then you must manually restrict painting to specific UV islands. This can be done using the P3dPaintableTexture component's Advanced/LocalMask feature, or by splitting your mesh up into multiple parts and restricting paint to one part at a time. When painting in 3D the painting itself is performed in 3D so there is no knowledge of UV islands, the underlying mesh geometry, etc.


    Does this issue occur in the "52 Channel Counter" demo scene?

    Check the GUIDE asset and let me know which version you're using.

    Which devices do you experience this issue with?

    Which exact version of Unity are you using?
     
  44. AndryInt

    AndryInt

    Joined:
    Jul 16, 2015
    Posts:
    3
    Hey Is there any chance to erase paint?
     
  45. ppd-enrique

    ppd-enrique

    Joined:
    Jun 16, 2022
    Posts:
    4
    @Darkcoder , thanks for replying.

    The issue does *not* occur on the "52 Channel Counter" demo scene.

    I am using version 2.0.2. I tried upgrading to 2.0.3 but the issue still reproduced exactly.
    My Unity version is 2021.2.4f.

    The behavior is exactly the same on all iOS and Android devices I've tested, down to the exact paint patters when it goes "off-the-rails". On my previous post I said it only happens on mobile, but I tried making a PC build and the exact same bug occurs. So it seems to happen on all builds, but not inside the Editor.
     
  46. HonduneGames

    HonduneGames

    Joined:
    May 14, 2015
    Posts:
    5
    If you notice in the screenshot of my settings I provided I already have it set to PointsOnUV. Even in PointsOnUV mode the decals still bleed over into other uv islands regardless of the size of the margins in the unwrap.
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,181
    Yes, you can use the ReplaceOriginal blending mode.


    If the issue doesn't occur in demo scene 52 then you need to tell me which modifications must be made to it to replicate the issue seen in your setup.


    I see. In the case of UV painting the issue is that your decal is so big that's it's painting across to other UV islands. When painting in UV space only the UV coord is sent. The paint doesn't know which triangle or UV island it's painting, and there's no automatic feature to catalog UV islands and ignore them. Such a feature would have to be done using LocalMasks or multiple meshes/submeshes.
     
  48. Bananzabro

    Bananzabro

    Joined:
    Oct 19, 2020
    Posts:
    21
    Hi there again!<3
    I'm using your asset in mobile game and it's now done and should be taken by publisher, but i have a single weird bug, and it drives me crazy - i don't even know where else to start digging.
    I'm using both regular mesh and skinned mesh with some blendshapes in my game (i'm painting both of them with spray paint).
    Everything works fine in unity, but in build (currently tested only android one) skinned mesh is not being painted. Regular mesh is painting ok though.
    I've already checked:
    1. I do have every component needed to paint on skinned mesh:
    - mesh collider,
    - P3DPaintable class with material cloner class and paintable texture class,
    2. I've unchecked including scale bool in paintable texture class (it is false now).
    3. My painting particles do work and also have all needed components.
    4. I've checked that my layer mask settings are right (both in HitParticles class and in object that i'm painting).
    5. I've checked that my blendshape colliders are in the right place for painting (i paint my object after i change its blendshape weight and i checked that its colliders are on and in the same place as mesh.
    6. I've checked game logs in build and it has no errors or exceptions.
    7. UV map is fine too.
    And the weirdest thing - it all works in unity.

    Is there anything you can advise? Is there anything i should know maybe, when painting on skinned mesh? Any ideas at all why this can happen only in build?
    Can it be somehow connected with object bounds (skinned mesh component field)?
    Can it be because of multiple cameras on the scene (i use main camera and two more cameras for different UI)?

    Thank you very much in advance, would be grateful for any help - i am ddesperate here:(
     
    Last edited: Aug 27, 2022
  49. HonduneGames

    HonduneGames

    Joined:
    May 14, 2015
    Posts:
    5
    Okay so I tried this with multiple meshes and submeshes. It sticks to its own uv island this way, But also every single mesh or submesh creates a new clone of the material and only edits its own new texture...
    So that leaves me with using the local mask feature. This does work theoretically, but creating a mask texture for every single uv island on every single mesh I want to paint is a huge ordeal and takes up a ton of space in the project. Is there a way to maybe generate local masks on the fly?

    I guess I should explain the goal here, maybe there is a better way to do this that i am missing. Imagine in my cube example above that you can select a part of the cube (top, front, left side, etc.) and the decals should ONLY apply to that portion of the mesh. I do not want individual materials/submeshes for all of these parts, and as the cube is a single smooth shaded object separate meshes arent possible either. and of course I want the end result to all be in one material and on one texture.
     
  50. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    116
    Hi Bananzabro, are you using "optimize game objects" in Rig setting of skinned mesh? I remember having a problem painting my skinned mesh when I used "optimize game objects". I forgot to let Carlos know of this issue, may not even be a problem anymore.
     
    Darkcoder likes this.