Search Unity

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

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

  1. Emphy

    Emphy

    Joined:
    Feb 7, 2014
    Posts:
    33
    @Darkcoder, what exactly is the best entity to put a HitCache on? Would that be each GameObject that is painted, or is it also performant/efficient to have just one HitCache on some sort of BulletImpactManager and we just call InvokePoint() on that all the time depending on where a bullet hits? Or would that come to a grinding halt pretty quickly?
     
  2. Likesundayqaq

    Likesundayqaq

    Joined:
    Jun 13, 2022
    Posts:
    9
    I have a question, when I choose to set Require Button to Touch in the P3dHitScreen script, then pack an APK and run it on the phone and I don't know how to recognize the finger, I swipe the screen with my finger, but the corresponding graph doesn't appear
     
  3. Likesundayqaq

    Likesundayqaq

    Joined:
    Jun 13, 2022
    Posts:
    9
    There was also a problem that when my finger was swiping across the screen, even though I set the draw frequency to low and Connect Hit to true, one graph after another didn't connect
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Can you modify one of the example scenes with your mesh that replicates the issue, and send me a unitypackage of this scene + your mesh so I can test it myself? Also, let me know the exact Unity version and Android devices you experienced this issue with.


    If you want each object to share the same texture then you can use the texture atlas feature shown in the "64 Atlas Painting" demo scene.

    Based on your description the best solution is to use one sub/mesh with different LocalMasks depending on where you want to isolate paint. There's no automatic way to generate these masks at runtime, but it can easily be done with some code:

    1 - Create 2 versions of your mesh, the first is the single submesh version you use for the painting, and then a second one that's split into multiple submeshes (or multiple meshes).
    2 - Create a RenderTexture for each sub/mesh.
    3 - Blit each RenderTexture so that it's black.
    4 - Call the PaintIn3D.P3dBlit.White method on each RT with the sub/mesh for it.
    5 - You now have LocalMasks for all parts, which you can swap between as needed.


    It depends on your game. You can see the code for this class just caches lists of IHit___ components for a specific GameObject and its children. So ideally you would only use one per GameObject, but it's probably not an issue if you have multiple, unless you're talking about hundreds sharing the same redundant data.



    What do you mean the graph doesn't appear? The input manager converts all mouse and finger data into CwInputManager.Finger data, where mouse data has a negative finger index. If you set the requirement to touch only, then it will ignore all finger data with a negative index. The code for this (P3dHitScreenBase.cs::FingerWentDown) looks ok to me. I'd need to see a simple demo scene that demonstrates the issue.

    I need to see a demo scene so I can replicate this. Also I need to know the exact version of Unity, Paint in 3D, Android device, etc.
     
  5. magglemitch

    magglemitch

    Joined:
    Dec 8, 2013
    Posts:
    112
    @Darkcoder - I'm setting up scene saving functionality, and my scene contains a large number of paintable objects. So when I go to save, it basically runs through all the saved objects and uses the GetPngData() method from the P3DPaintableTexture to then save using WriteAllBytes. The process can be a little slow (due to larger textures and the number of them) - and I was wondering if there are any ways to potentially optimise this process? I realise I can probably only do so much, but do you know if it would help if I were to use jpgs per chance? (as I don't have a need for any alpha channels)
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    PNGs have optional alpha so that doesn't matter, and jpg compression is likely slower. TGA files are uncompressed (or use very fast RLE), so that might be an option.

    The process of transferring the textures from the GPU to the CPU will always be slow though, so there's only so much you can do with this strategy.

    Another option is to gradually save the textures in your scene over time so the hit isn't all at once, but this would require some code to manually save them. You could also make it only re-save textures after they get painted using the P3dPaintableTexture component's On modified event.

    Another option is to store paint hit data rather than the texture itself. This is only viable if your objects don't get painted too much though, otherwise it would get a little tricky as you would need to save occasional full texture states alongside newer paint commands. This would require a lot more code.
     
  7. magglemitch

    magglemitch

    Joined:
    Dec 8, 2013
    Posts:
    112
    No worries - thanks!

    Extra question - wanting to capture a timelapse video of painting up the scene but wanted to have control over how I capture it after the session. Do you know if its possible/easy to save state information to say a text file so that I can some how feed it back in later on? Like if I perform 30 paint actions in the session, I can then feed that back in the editor so I can go through the 30 different actions or something like that?
     
  8. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    hi @Darkcoder
    first of all I want to say that this asset is pretty amazing. The possibilites are pretty much endless and that it works both in editor and game is impressive too.

    However it took me sooo many hours to figure out that every p3d material is a prefab itself with p3d painters attached to it and those were used the absolutely same way in the editor as in ingame. And that those painters needed the same groups assigned as the mesh I was painting on and that the material textures needed to have similar names to the groups.
    I wish there was a more high level explanation about how everything works with each other in the documentation.
    The original use case I wanted to achieve was paint directly into the alpha channel of a URP MetallicMap and I tried to achieve that through setting that group, but in the end I was more successful with setting the painter/painting material to RGBA and only the paintable target to metallic map.

    There are a few other issues I noticed as well.

    1. I tried to make a fill tool for the editor. I set up a new p3d hit screen in editor tool with Points On UV, added a P3D Paint Fill component to it but nothing happens when I try to use this.
    Without the P3D Paint fill component I get this error.
    upload_2022-9-14_17-3-12.png

    2. I can not get triangle painting to work in the editor


    3. Is it possible with one of the existing configurations to paint flow maps? I see that the liquify example behaves similar already as in the brush rotates into the direction I draw in but using the drawing direction / cursor velocity as color vector?

    4. I would probably just add this for myself but it's a bit strange to rotate the view with alt+left key in edit mode and see the model being painted if the cursor is over it, maybe similar to required keys the navigation keys could be excluded?

    Sorry for dumping so many questions / suggestions on you at once. I just spend so much time with the tool the past days :)
     
    Last edited: Sep 15, 2022
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The "89 Command Serialization" demo scene shows you how paint commands can be de/serializalized to JSON. Keep in mind this requires advanced C# knowledge to configure.


    Yeah the in-editor painting feature at its core is quite complex. The challenge is that it's designed to support any kind of shader/material, but since each texture slot can be any kind of texture or even a combination of textures it means there's no straightforward way to paint anything. For example, if a paint material paints metallic then currently you must configure one P3dPaintDecal component per texture type that has metallic, which is a lot of different texture types because many textures pack metallic into a specific channel.

    There are various different approaches that might make this setup easier, but to be honest barely anybody uses the in-editor features of this asset so it's not something I spend too much time on.

    1 & 2 - I'll send you a new build that should fix these.

    3 - Paint brushes can be rotated to the finger/mouse direction, but painting a flow map requires the paint color to be modified based on this angle, which is not a feature of this asset. The draw angle code is in P3dHitScreenBase.cs line 360. To change the color this draw angle information would need to be sent to the paint component.

    4 - The camera controls are all left up to Unity. The in-editor painting only uses the left mouse button to paint.
     
    fleity likes this.
  10. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    That actually surprises me a lot, sure there are probably simpler assets for in editor painting but this asset is so powerful at that. :D

    thanks I will check that out right after answering this message. :)

    Sounds doable, if I come up with a portable solution I'll share it here. Having a flowmap tool for inside the editor would make my life quite a bit better.

    Of course, the issue is that left mouse button + alt is already an existing action used by unity and they kind of conflict, so I propose to add something along the lines of
    Code (CSharp):
    1. if (LeftMouseButton.isPressed && requiredKeys)
    2. // becomes
    3. if (LeftMouseButton.isPressed && requiredKeys && !LeftAlt.isPressed)
    but this is really a very very very minor suggestion
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    3 - Another approach that might be easier is to make a new blending mode that changes the color based on the drawing angle. While the drawing angle isn't sent to the painting shader, the rotation of the sphere/decal is. This rotation is used by the Flow blending mode (rot value) to adjust the flow direction, but you could probably use it to change the color.

    4 - Oh I see, yeah this makes sense, I'll see if I can add it to the next version.

    I'll answer the private message in a little bit.
     
  12. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    thanks :)

    regarding 4 -
    My bad pseudo code above is completely wrong btw. I implemented it this morning but had to realize first that the input system does not capture keyboard input at the right time if the game view isn't focused (even though I changed the relevant setting in project settings). What one wants to use is Event.current.alt.

    I added a static bool to P3dSceneTool.cs "AltKeyPressed", set it in HandleBeforeSceneGUI()
    and then check for that in P3dHitScreen_InEditor.cs too.

    Code (CSharp):
    1. // P3dSceneTool
    2.  
    3. 29: public static bool AltKeyPressed;
    4. 143: AltKeyPressed = Event.current.alt;

    Code (CSharp):
    1. // P3dHitScreen_InEditor.cs
    2.  
    3. 62: if (!P3dSceneTool.AltKeyPressed && (P3dSceneTool.LastSet == true || mouseSet == true))
     
    Last edited: Sep 19, 2022
  13. magglemitch

    magglemitch

    Joined:
    Dec 8, 2013
    Posts:
    112
    Cheers! I've gone through this and managed to work something out. I'm wondering if we're able to have a little more control somehow on what is saved? Instead of commands could I possibly save states and load those back in instead? That way I could save the states every x amount of seconds rather than loading in every command (as some of the painting commands save A LOT of data).
     
  14. cftcimert

    cftcimert

    Joined:
    Apr 4, 2018
    Posts:
    14
    Hi, when two masks overlap, the mask does not work properly. I think it happens because the active mask takes the closest mask. Is there a solution to this?
     
    Last edited: Sep 28, 2022
  15. Illia_Kovalenko

    Illia_Kovalenko

    Joined:
    May 25, 2016
    Posts:
    5
    Hi there! I'm trying to simulate spray-painting using P3dHitBetween logic (ClipConnected = true) in VR. When I'm moving slowly and P3dPaintSphere radius is static it looks perfect (1), but when I'm trying to change painting radius in the Update() cycle according to distance between wall and spray can it looks strange (2). Are there any ideas how to fix it, maybe use another painting component, improve radius calculations, etc.? Thanks!
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      209.9 KB
      Views:
      126
    • 2.PNG
      2.PNG
      File size:
      197.1 KB
      Views:
      127
  16. Illia_Kovalenko

    Illia_Kovalenko

    Joined:
    May 25, 2016
    Posts:
    5
    Hi @Darkcoder I've tested P3DHitScreen input with scaled pixel interval input frequency, and it works fine. Is it possible to port this hit screen input recognition logic to VR?
     

    Attached Files:

    • 3.PNG
      3.PNG
      File size:
      160.9 KB
      Views:
      134
  17. TheSheyper

    TheSheyper

    Joined:
    Jul 3, 2013
    Posts:
    22
    Hi @Darkcoder
    I have this error when trying to reveal lightmaps with painting :

    Error assigning 2D texture to 2DArray texture property 'unity_Lightmaps': Dimensions must match
    UnityEngine.Material:SetTexture (string,UnityEngine.Texture)
    PaintIn3D.P3dPaintableTexture:ExecuteCommands (bool,bool) (at Assets/Plugins/CW/PaintIn3D/Required/Scripts/P3dPaintableTexture.cs:1324)
    PaintIn3D.P3dPaintableManager:UpdateAll () (at Assets/Plugins/CW/PaintIn3D/Required/Scripts/P3dPaintableManager.cs:148)
    PaintIn3D.P3dPaintableManager:LateUpdate () (at Assets/Plugins/CW/PaintIn3D/Required/Scripts/P3dPaintableManager.cs:128)

    I'm using the URP/BakedLit material, and I have UV0 and UV1, painting on UV0 works as expected, but UV1 with "unity_Lightmaps" slot and Coord set to "Second" does not seem to work.
    If you have any hint on how to achieve this, right now I'm kind of stuck -_-
    Thanks a lot for your help (and your asset :) )
     
  18. euugine

    euugine

    Joined:
    Mar 4, 2014
    Posts:
    4
    Hi all! I want the bot to color the object. And I think I need to get the positions of unpainted pixels and pass them to the bot so that it comes there and paints. Can I somehow get these positions, but so that they are next to the bot. I don't want the positions to be randomly taken from the texture, otherwise the bot will run back and forth. Maybe make some sphere around the bot, and if an unpainted pixel gets into it, we pass its coordinates and the bot will paint it over. Is it possible?
     
  19. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    You are trying to directly paint into the lightmap? Although that sounds like it should work (during runtime at least) it might be better to paint in a dedicated mask texture and blend the lightmap in the shader based on the mask?


    ------

    I feel like you expect all of us to have knowledge of your specific project... which is more than a bit assumptious.
    If I were you I would look at the examples containing a count of unpainted pixels, the asset certainly has some info of about the has been painted state.
    Further what you suggest sounds doable but advanced (and not necessary related to this asset). What you want to do is sample the texture and check if the pixels are unpainted. Doing this on the cpu might be rather expensive and slow, a compute shader could help here if you use it in a jump-flooding kind of way, iteratively moving further away from your initial sample position until you reach a threshold of unpainted pixels. This is still rather unsafe though, because a single unpainted pixel could cause the bot to move there and you would probably have to decide if you want to sample everything based on world positions or uv coords (and then deal with the inconsistencies). All in all not a simple task...
     
    Darkcoder likes this.
  20. TheSheyper

    TheSheyper

    Joined:
    Jul 3, 2013
    Posts:
    22
    Hi @fleity
    Thanks for the answer, I understand what you mean, and indeed your mask solution could be better, but the thing is it does not seem to recognize the "unity_Lightmaps" slot, so that does not really change the pb -_-
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Yes of course, you can call the Save/Load method on each P3dPaintableTexture any time to save its current state to PlayerPrefs, or call GetPngData/LoadFromData and store it yourself somewhere. You can then erase any previously stored states.


    Only one mask (the closest) is supported.

    Depending on your scenario you may be able to make RenderTexture and build your own mask from any number of textures/sprites.


    VR painting is usually based on P3dHitBetween, which gives you full control over the paint orientation and such, so you should be able to easily enough port this.


    As the error states, you're trying to paint a texture array. Paint in 3D can only paint textures (non array).

    You would have to make some custom script that extracts an array slice or something to support this.


    What fleity said is spot on. All paintable textures are stored on the GPU, and accessing it from the CPU is very slow. Another approach is to make a grid of invisible objects or virtual points, and you manually delete them when you paint in that area. This way you immediately know on the CPU which areas haven't been painted. These all require custom scripts to make.
     
  22. Illia_Kovalenko

    Illia_Kovalenko

    Joined:
    May 25, 2016
    Posts:
    5
    Thanks for your replay:) yes, I'm using P3dHitBetween in VR mode, but is it possible to change the drawing radius frequently to avoid weird dotted line effect? It appears when I move my hand very fast and also change my drawing sphere radius according to the distance between spray and wall. This effect is still present even if I'm using ClipConnected = true feature.
     

    Attached Files:

    • 2.png
      2.png
      File size:
      197.1 KB
      Views:
      116
  23. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84
    Hi there!
    I'm testing the Paint3d example "Paintball Throwing", and everything works correctly with the map gameobject.

    However, if I add your spaceship (or a basic sphere) with its own P3D Paintable, Material Cloner, Texture, P3D Color counter, I then only see the paint explosion without the painting effect when the ball hits the spaceship (or a basic sphere)

    I am at a loss as to why the painting effect does not apply correctly. Perhaps a quick tutorial could help?

    Thanks!
     
  24. TheSheyper

    TheSheyper

    Joined:
    Jul 3, 2013
    Posts:
    22
  25. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The ConnectHits and ClipConnected features only work if the paint radius remains the same. This is because connected hits only store the previous and current paint points, not the radius. Storing the radius is difficult because that's handled by the paint component, which is downstream from the hit components.

    Perhaps the paint components could cache their radius and position pair history, and perform a lookup when painting a connected hit. I'll add this to the to-do list.



    I'm not at my PC right now so I can't say for sure. From what I recall, the paintball demo scene uses a special shader to paint on top of the base tiling brick texture. If so, this likely uses a different paint group than the default Albedo group that the spaceship demo scenes use. If you change the groups to match or modify the paintballs to also paint albedo then it should work.
     
  26. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84


    Thank you very much Darkcoder, this was exactly the case! I added a second P3D paint decal on the ball and set its group to albedo and now the effect works correctly on both the map/floor and the objects (spaceship/sphere).

    Thanks a lot!
     
    Darkcoder likes this.
  27. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84
    Hi Darkcoder,

    I am now testing the "Paintball Throwing" with low poly characters skinmeshes, using your UV recommendation at https://carloswilkes.com/Documentation/PaintIn3D#UV. Unfortunately, the preconfigured overlay material (which appeared to have been renamed "Shiny White Overlay (Second UV)" ?) doesn't let the base material color to pass through (resulting in an all gray/white rendering). I've tried many combination, but the only ones that work, effect wise, is the one with this overlay issue.

    Would you be able to look at my settings (attached pic) to see if there is anything wrong?

    PS: I have also encountered the same issue using the paint function in the inEditor basic setup.

    Thanks!
     

    Attached Files:

    Last edited: Oct 10, 2022
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    You've set the P3dPaintableTexture component's Color opacity to 1, which means the override will apply instantly everywhere (white). But you only want it to apply to areas that you've painted right? So you should set this to 0.
     
  29. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84
    Hi there! I think I understand what you mean, but can't find the settings to make it work. I've also noticed that the Albedo of my body material sometimes gets removed upon return from play when using the "Shiny White Overlay (Second UV)" as a secondary material. This setup of mine seems unstable.

    I think a tutorial on this would be greatly beneficial. So, let's start from the beginning and do it step by step:

    I have added the Paintable, Cloner and Texture component. All settings are set to modify the _MainTex (which is a reference to the baked texture on the material). On play, it does not apply the paint properly (due to the low-poly mesh issue that is stated in your documentation).

    According to your documentation, as I don't mind replacing my original shader/material, I then set the shader of my material to Paint in 3D / Solid (instead of URP). I also set the coord to "second", I use "premultiplied albedo" as the group and use "premultiply" as the conversion. On play, it still can not apply the paint properly. In my particular case, it only apply the paint to the eyebrows (see pic).

    What is the next step?

    I hope to create a "one stop" solution on this issue with this exchange.

    Thanks!
     

    Attached Files:

  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    First you need to understand how your mesh is configured regarding colors and UVs, and secondly how the Solid shader works so you can change the settings to match.

    Some low poly models like the ones by Synty use a color palette texture, and the UVs of each triangle are squashed into a single point on top of a specific pixel to give them all the same color. This looks like the same setup as your mesh. This is a setup that cannot be painted directly, and you will need to enable Lightmap UV generation as described in the documentation. Enabling this will put paintable UV data in the secondary UV slot, but keep in mind you cannot use these paintable UVs for your aledbo texture, because they must use the aforementioned squashed UVs that match your color palette.

    If you use the Solid shader then you need to configure the Albedo texture to use your color palette as you have done, and you need to leave the first (non-override) "Use Second UV" unchecked as you have done.

    However, what you need to do is configure this and your paintable components to use the secondary UV data you just generated. This means you don't want to paint the _MainTex, you want to paint the albedo override texture which is called "_AlbedoTex" with Coord = Second as you have, and you then need to enable the material's "OVERRIDE SETTINGS / Use Second UV" setting.

    The setup I describe here is shown in the "09 Override" demo scene, so I recommend you study this scene.
     
    The11thAlchemist likes this.
  31. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84

    Thank you Darkcoder for such a detailed explanation, I was able to make it work.

    FYI: I am using the Advance People System 2. I had indeed generated the lightmap UV on the asset model. As you instructed, I changed the slot to the Premultiplied Albedo RGB weight A (aka, _AlbedoTex) and checked the Use second UV in the material override setting. Moreover, I also had to create a transparent texture (based on the original) and set the Format in its import setting to "Alpha 8" (otherwise it wasn't perfectly transparent over the original texture). This transparent texture was then added as the material override Premultiplied Albedo RGB weight A.

    I hope that this exchange (and it's solution) will be helpful for anyone else who loads up Paint3D and encounter this particular issue.

    Thanks again for your help, I can now continue my experiments with your asset!
     
    Darkcoder likes this.
  32. Illia_Kovalenko

    Illia_Kovalenko

    Joined:
    May 25, 2016
    Posts:
    5
    Oh, got it, thanks for your reply!
     
    Darkcoder likes this.
  33. ChickChick007

    ChickChick007

    Joined:
    Oct 29, 2019
    Posts:
    1
    Hello!
    There is a "Touch offset" field in the "3D Hit Screen" script. On different devices - different effect (shift)! This value is multiplied by "CInputManager.scaleFactor", so this scale is not correct! How to solve this problem?
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    It should offset by the same physical distance. If you want it to behave differently then change the code?
     
  35. Kostachok

    Kostachok

    Joined:
    Feb 27, 2017
    Posts:
    4
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
  37. Kostachok

    Kostachok

    Joined:
    Feb 27, 2017
    Posts:
    4
    Can't paint any submesh other than 0

    upload_2022-10-19_16-46-20.png upload_2022-10-19_16-46-56.png upload_2022-10-19_16-49-2.png
     
  38. Kostachok

    Kostachok

    Joined:
    Feb 27, 2017
    Posts:
    4
    Created a second UV channel.
    Mesh analysis shows that the plugin still sees a sweep of 6 submesh.
    upload_2022-10-19_16-52-39.png upload_2022-10-19_16-55-43.png upload_2022-10-19_16-56-6.png
     
  39. chaoy1

    chaoy1

    Joined:
    Oct 5, 2022
    Posts:
    1
    Quick question:
    I'm new to VR game design and I'm planning to enable players to draw only on certain assets using sprays in 3D VR games. Also, I want to drop sprays and eraser on the ground so that players can grab them and paint whenever they want to. I'm wondering if this can be achieved and if there's a tutorial for this part. If there is, I will buy it
     
    Last edited: Oct 19, 2022
  40. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Not sure if this is a known issue (it kinda seems familiar, so sorry if it is), but I've just come across this issue on a Samsung J5 Pro running Android v7.

    Attached image shows right after I start painting, where the texture turns into what looks like the wireframe.

    It is the 01 Basic Setup scene using Paint in 3D 2.0.3, in Unity 2019.4.40f1.

    Any thoughts?
     

    Attached Files:

  41. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I need to see your Paint in 3D components setup.


    Paint in 3D comes with VR examples, but they aren't designed for a full game. For a full game you will want to use one of the many VR toolkits/assets out there that implement everything.

    To make them compatible with Paint in 3D you just need to enable/disable the paint component (e.g. P3dHitBetween) when you press the VR trigger while the tool is being held. This may require a little bit of custom code, or perhaps the VR toolkit you use has some inspector events you can connect, like the Paint in 3D example components show you.


    This is quite an old device and I don't have one so I don't know as I've never seen this issue. You can try changing the build mode graphics API setting, or trying the S6 fix HERE.
     
  42. Aleksei-Kolotilov

    Aleksei-Kolotilov

    Joined:
    Jun 3, 2015
    Posts:
    17
    I'm also having trouble painting IClone characters. I tried everything that is possible, but nothing helps, it turns out to draw only on the head. I added components for each material, but it does not work. It would be cool if the author of the plugin tried to color the character from IClone himself. I will be very grateful to the author if the plugin can work with iClone.

     
  43. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Thanks, the S6 fix worked.

    To confirm, is this fix safe to use as long as my UVs don't overlap?

    What happens if they do overlap?
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I just made a new project with Paint in 3D 2.0.3 + iClone Winston, dropped him into the Zombie Blood demo scene, added a BoxCollider and made his body + clothes paintable and everything works as expected?

    upload_2022-10-22_9-37-33.png

    You may have to shrink the BoxCollider size so it more closely matches the model, or increase the P3dPaintDecal's Scale.z so it can paint deeper.



    If they overlap then only the last of the overlapping triangles will be painted, it will be impossible to paint the ones before it.
     
  45. Aleksei-Kolotilov

    Aleksei-Kolotilov

    Joined:
    Jun 3, 2015
    Posts:
    17
    I checked Winston, it really works, but it's an old version of CC2. I'm using CC3 and the UV Channel is different there.
    Here is the CC3 model https://drive.google.com/file/d/1jhvguMQVn8LN-O-plBmk6diVCMYdJXKB/view
     
    Last edited: Oct 22, 2022
  46. Kostachok

    Kostachok

    Joined:
    Feb 27, 2017
    Posts:
    4
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    It looks like the UV goes outside of the normal 0..1 range, so it cannot be painted.

    UV data outside of this range is usually only used for tiled texture mapping, but it looks like they did it just to simplify UV layout?

    To paint this kind of UV data you would have to modify the code. If you open P3d Decal.cginc and P3d Sphere.cginc and find the "float2 texcoord = ...;" line, you should be able to add this to the end to fix this: texcoord %= 1.0f;

    This change would be undesirable on other meshes so it's only a fix for this particular mesh UV setup.
     
  48. Aleksei-Kolotilov

    Aleksei-Kolotilov

    Joined:
    Jun 3, 2015
    Posts:
    17
    Added fix, now it works, but it looks very strange.
    upload_2022-10-23_18-11-39.png
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    This line shouldn't change the base texture like this. The modification should be from this:

    Code (csharp):
    1. float2 texcoord = i.texcoord0 * _Coord.x + i.texcoord1 * _Coord.y + i.texcoord2 * _Coord.z + i.texcoord3 * _Coord.w;
    to this:

    Code (csharp):
    1. float2 texcoord = i.texcoord0 * _Coord.x + i.texcoord1 * _Coord.y + i.texcoord2 * _Coord.z + i.texcoord3 * _Coord.w; texcoord %= 1.0f;
    I forgot to mention it but you also need to change P3D Texture.shader with the same thing.
     
  50. Aleksei-Kolotilov

    Aleksei-Kolotilov

    Joined:
    Jun 3, 2015
    Posts:
    17
    Thanks, it works!
     
    Darkcoder likes this.