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. melksnis

    melksnis

    Joined:
    Sep 30, 2020
    Posts:
    8
    Hello!
    I cant get the color counter to work. the thing is I have 3 paintable textures on my object (it is a car that have rust layer - , paint layer and dirtiness layer. ) I want to be able to see how much rust is left , how much dirt is left and if the car's color is uniform. anyway I cant figure out how to assign paint counter to individual material .only thing working is channel counter -and I am not really sure if it is counting all materials or just one random. maybe there is another way to count individual material colors?
     
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    This asset is designed to work with MeshFilter+MeshRenderer or SkinnedMeshRenderer scenes setups only. It wouldn't be too difficult to modify it to work with a setup like yours, but because this is incredibly uncommon I don't have any plans to support painting these kinds of objects right now.


    By default the components like P3dColorCounterText output the total/average values for all counters in the scene. These components have the Counters list at the top, which allows you to specify specific counters though.

    I think I made a mistake with the demo scenes in the current version so they don't display the correct values. I've almost finished work on an update that fixes this and many more issues, so I can send you an early build of this you'd like.
     
    Opeth001 likes this.
  3. melksnis

    melksnis

    Joined:
    Sep 30, 2020
    Posts:
    8
    Thanks, I figured some stuff out by now, BTW when I disable change reader and paint (add changes) when after that I enable change reader it does not update until I paint on it again. How can I update it without painting? I want to check for changes only when when player decides to check for progress so I don't need change reader to be enabled at all times
     
  4. Danielsantalla

    Danielsantalla

    Joined:
    Jan 7, 2015
    Posts:
    73
    Hello guys. Is there a way to implement the "rotate towards mouse direction (Rotate to normal, relative to Draw angle)" functionality but in VR? Like, to rotate the Decals towards the controllers XY direction? I would like to implement that for P3D Hit Between or any other VR compatible script in the package. thanks.

    To be more clear, I want to emulate this type of movement but for VR upload_2021-5-17_4-41-47.png
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    Good point, I've fixed this and will send you a test build shortly.


    Nice idea, I've added a new P3dHitBetween.Orientation = ThisTransform setting. I'll send you a test build shortly.
     
  6. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    I'm trying to paint dots on a gameobject at hit points determined by a moving pointer that the user can point at the object entirely via script. I checked the examples and it seemed the most relevant scripts to do this were P3dProceduralSetup for the initialisation and P3dPaintFromCode for the painting. Unfortunately, nothing is painted when I run the program.

    This is what I'm doing. First set up the object in Start().

    Code (CSharp):
    1.  
    2. gameObject.AddComponent<P3dPaintable>();
    3. var paintableTexture = gameObject.AddComponent<P3dPaintableTexture>();
    4. paintableTexture.Slot = new P3dSlot(0, "_MainTex");
    5. gameObject.AddComponent<P3dPaintSphere>();
    6.  
    I didn't add P3dMaterialCloner, because the material is only assigned to that object. And I'm using P3dPaintSphere instead of P3dPaintDecal in P3dPaintFromCode, because I want to paint dots and not decals.

    In the update method, I do the following:

    Code (CSharp):
    1. var collider = gameObject.GetComponent<Collider>();
    2. var pSphere = gameObject.GetComponent<P3dPaintSphere>();
    3. pSphere.Color = Color.blue;
    4. pSphere.Radius = 0.01f;
    5. RaycastHit hit;
    6. if (Physics.Raycast(pointer.transform.position, pointer.transform.TransformDirection(Vector3.forward), out hit))
    7. {
    8.     if (hit.collider == collider) // check that this object has indeed been hit
    9.     {
    10.         Debug.Log("Object Hit");
    11.         pSphere.HandleHitPoint(true, 0, 1.0f, 0, hit.point, Quaternion.LookRotation(-hit.normal));
    12.     }
    13. }
    The Debug.Log("Object Hit") fires so I know the object is hit by the ray. But pSphere paints nothing. I inserted a breakpoint at the pSphere.HandleHitPoint line and tried to step into the HandleHitPoint method in debug mode, but the debugger didn't do so. It continued to the next line.

    The material of my gameobject has just a standard shader and an albedo colour. The gameobject has MeshFilter, MeshRenderer and MeshCollider components.

    What could be the problem?
     
  7. thecheesyone

    thecheesyone

    Joined:
    Jun 29, 2020
    Posts:
    1
    Hello,

    It seems like something might have broken with mobile finger painting with one of the newer updates. To reproduce this, I tested the chalk board example in my existing project on Unity 2020.3.8f1 LTS (URP and New input system) on desktop and using the mouse works and leaves the paint on the board, however, it doesn't work in on the IOS build. Fingers don't leave a mark. I also tested it in a fresh project and the issue happens there too. I added a bit of logging to see if the P3D input manager was just not noticing the mobile touches, but the logs show that it's receiving the right number of touches on screen.

    Is there an additional step to activate touch controls? It used to work in my project, so I'm curious if I might be missing something.
     
    Last edited: May 20, 2021
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    Does the P3dHitBetween component work? ("30 Between Painting" demo scene)

    This component works similarly to your code.


    Looks like I made a mistake somewhere with the new InputSystem code. I'll see what the issue is and send you a new build soon.
     
  9. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    Thanks for the reply. I hadn't checked out that example. I see it's possible to create a separate Paint object, which contains the painting logic. So I copied that object with P3dHitBetween and P3dPaintSphere, adapted it for my scene and the result is that I'm able to partially paint an object that I create using Probuilder, but still no success with my procedurally generated meshes. No paint appears on them at all.

    I'm using the same initialisation code for both types of objects, so not sure what's not working. Maybe my meshes are weird? Are there any conditions on meshes for painting to work?
     
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    ProBuilder likes to UV map meshes with tiling, which can't be painted properly. You can check the UVs HERE, there are also strategies to work around this earlier in the documentation and in the first few demo scenes.
     
  11. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    The Mesh Analyser tool is quite helpful. Thanks for pointing me to that. It does show the Probuilder mesh has overlaps and out of bounds values, and most importantly, it reports that none of the triangles of my non-Probuilder meshes have UV values assigned to them.

    With the VS debugger I checked the components of the mesh object directly in the code, and while it seems it does have a populated UV array, all the x values are 0, so there's definitely something weird going on with my meshes. Do you have any method to regenerate proper UV maps for procedurally generated meshes? The "Generate Lightmap UV" option you refer to in the manual is only for imported meshes.
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    Your procedurally generated meshes would also have to procedurally generate suitable UVs. ProBuilder for example is capable of generating them, but I rarely use it so I don't remember how. The "Paint Ball Throwing" demo scene map was made using it and then converted to a normal mesh.
     
  13. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    561
    Hi Darkcoder. I am enjoying using this package, I have a question though.

    I am trying to call the function to paint objects from a raycast. But when I move my cursor, away the paint moves with the hitpoint, instead of staying in place. I suspect I might be using the wrong function.

    If I am assuming correctly, which script and function should I be using?



    I understand that if the raycast ends when two different GameObjects are Point A and B, it creates a line on both instanced textures.

    I am using P3dHitThrough and P3dPaintSphere.

    My script is as follows:
    Code (CSharp):
    1.  
    2.     private void UpdateBeamPosition()
    3.     {
    4.         if (Physics.Raycast(XrInput.InputData.RigData.RayOrigin.position, XrInput.InputData.RigData.RayOrigin.forward, out rayHit, 1000f))
    5.         {
    6.             Beam.SetPositions(new Vector3[2] { XrInput.InputData.RigData.RayOrigin.position, rayHit.point });
    7.  
    8.             if(rayHit.collider.GetComponent<P3dPaintableTexture>())
    9.             {
    10.                 Debug.Log($"Hit the {rayHit.collider.name}");
    11.  
    12.                 PaintSphere.HandleHitPoint(true, 0, 1f, 0, rayHit.point, Quaternion.identity);
    13.  
    14.                 if (HitThrough.PointA == null)
    15.                 {
    16.                     HitThrough.PointA = rayHit.transform;
    17.                 }
    18.                 else
    19.                 {
    20.                     HitThrough.PointB = rayHit.transform;
    21.                 }
    22.  
    23.                 HitThrough.ManuallyHitNow();
    24.             }
    25.         }
    26.     }
    I thank you for explaining where I am going wrong.
     
  14. Danielsantalla

    Danielsantalla

    Joined:
    Jan 7, 2015
    Posts:
    73
    Hello guys.

    I'm trying to ReadColor of a 3D object with a convex mesh collider but I can't do it because of this error: attempting to ReadPixels outside of RenderTexture bounds! Reading (0, 512, 1, 513) from (512, 512).

    Any help with this? From what I understand, it is not working because ReadColor only reads 2D textures and not 3D meshes, but I might be wrong. Thanks

    Edit: more info on this, I can't use non-convex meshes because I'm attaching a rigidbody to the gameobject, so I'm obligated to use non-convex meshes
     
    Last edited: May 24, 2021
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    You've enabled the 'preview' argument in HandleHitPoint, so it doesn't apply anything.



    Convex meshes don't store UV data, so they can't be read from. If you're using a Rigidbody then you would have to manually (e.g. via script) move a non-convex collider to match it. Or, you could place this non-convex collider somewhere else, and do a second raycast against it by transforming the raycast position&direction to match the space of it. In both cases you would probably have to use a separate later to stop any conflicting hits.
     
    kittik likes this.
  16. berkanalbayrak

    berkanalbayrak

    Joined:
    Nov 13, 2017
    Posts:
    1
    Hello. I am loving this asset so far but i stumbled across something i couldn't figure out. I am trying to paint objects with Collision Painting and i want the decal or paint not to appear suddenly but using increased scale over time etc. Like the inverse of the Gradually Fade scene i want them to Gradually Appear :). Is it possible to do so in the latest version 1.11.4 ? If not so, what should my approach be while modifying it ?



    Edit: Also sometimes i need to use UV Utilization value of a mesh. Is it possible to get it via code ?

    Thanks in advance.
     
    Last edited: May 25, 2021
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    I already plan to make a demo scene for fading things in HERE. This can be done by painting a texture with Advanced/IsDummy enabled, and then using P3dGraduallyFade to fade toward it. Just make sure they use different Groups so you're only painting the dummy one.

    There's no easy to use code to get the overlap %, but the shader used to make it is there. You just need to copy+paste the code in P3dMeshAnalysis.cs:BakeOverlap (lines 111+), and replace the parts with Selection.objects with your own mesh or however you'd like it to work.
     
  18. crdmrn

    crdmrn

    Joined:
    Dec 24, 2013
    Posts:
    151
    @Darkcoder Is that feature in the latest update? Cause the changelog seems to suggest so, but I can't figure out how to do it ^^"

    EDIT: Ok, I managed to get it to work, but now i can't understand how to translate the hitpoint on the mesh to the splat map coodrinates... any suggestion?
     
    Last edited: May 27, 2021
  19. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    71
    @Darkcoder This asset is great, and It's working very well for a project I'm currently working on.

    I have a minor issue though. I'm using Paint in 3D and some of your other assets (LeanTouch+, and LeanGUI) to move the camera around the model. This is working well; however, when I undo it seems to capture that camera movements. It doesn't undo them, but it seems to count the inputs towards the texture. I'm using Full Texture Copy for my undo method (some of my meshes have skeletal animations).

    Do you know what might be causing this? and more importantly, how I might be able to fix this.

    Cheers!
     
  20. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    How are the blend modes supposed to be applied in a script using P3dPaintSphere to paint?

    I'm doing the following:

    Code (CSharp):
    1. var pSphere = paint.GetComponent<P3dPaintSphere>();
    2. var blendMode = P3dBlendMode.NormalReplace(new Vector4(1,1,1,0));
    3. blendMode.Color = colour;
    4. pSphere.Color = colour;
    5. pSphere.BlendMode = blendMode;
    6. RaycastHit hit;
    7. if (Physics.Raycast(paintBrush.transform.position, paintBrush.transform.TransformDirection(Vector3.forward), out hit))
    8. {
    9.     pSphere.HandleHitPoint(false, 0, 1.0f, 0, hit.point, Quaternion.LookRotation(-hit.normal));
    10. }
    but the paint only darkens the area it hits. If the texture of my object is black and I try to paint in white, the paint remains invisible.

    What I'd like is a simple paint with the new RGB colour replacing the original while keeping the alpha value of the original texture.

    --edit--
    Just tried different blend modes in the Inspector while trying to paint a black object with white paint and none of them produce white marks on the object. Clearly there's something I'm not understanding (or something's wrong). I'm using Vector4(1,1,1,0) for my channels, since I don't want to touch the alpha value of the target object (which is set to 200 on the 0-255 int scale). Object texture has a standard shader, transparent rendering mode and a single colour.
     
    Last edited: May 27, 2021
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    I don't understand your question.


    Are you using the latest version? I believe there was a bug like this in one of the earlier versions. As long as your buttons (e.g. undo) are on the UI layer with RaycastTarget enabled then P3dHitScreen should ignore them.


    You should use the Replace or AlphaBlend blending modes then, NormalReplace is for normal mapping.
     
  22. crdmrn

    crdmrn

    Joined:
    Dec 24, 2013
    Posts:
    151
    Basically as far as I can understand, textures can only be painted on based on UV, there is no "projection mode" similar to how splat painting works on terrains.

    Another question, I cant seem to be able to override textures once they are saved, meaning that if I export, stop the game, then play again I'm not able to change the colors I exported before... Im sure there's something I'm getting wrong, but I can't figure out what ^^"
     
  23. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    I tried all the blending modes. None of them allow me to do what I want, which is paint a colour on an object and keeping the alpha value (see my edit).
     
  24. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    71
    The documentation says I'm using 1.9.14. I'm not sure if that's correct because I only downloaded and installed it in March and I can see the seam fixer demo scene in my project (is there a way I can check version inside Unity?)

    The issue isn't with buttons, but the PitchYaw, LeanPinchCamera and LeanDragCamera scripts from LeanTouch.

    Maybe I'll need to try and update my project.. eek.
     
  25. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    561
    @Darkcoder is there a component you suggest I should use to modify different materials on one object? I can do it via adding MaterialCloners and PaintableTextures components with the correct indexes/slot info per material, but I am sure there must be a less ridiculous way.
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    By default all paint is applied in 3D space and baked into your textures. You can change this based on your Emit setting:

    upload_2021-5-28_11-18-14.png

    If you set it to PointsOnUV then you must have a non-convex MeshCollider on your objects, as the UV point of where to paint must be known.

    For the 3D modes this isn't necessary. However, since the paint is baked into your textures, your meshes do need to be UV mapped.

    If you want to load/modify a previously painted texture then you can use the Load button (or LoadAll at the bottom):

    upload_2021-5-28_11-20-56.png

    This is shown in the "03 Load And Export" demo scene. This button will be available if you Export the texture(s) before entering play mode, if not you can drop a specific texture into this slot and then click Load/Load All.


    I've attached a modified "01 Basic Setup" demo scene that begins with a semi-transparent red texture state, and with a brush that paints only the RGB white, and it works as expected. Let me know if this also works for you, or what must be changed to make it not work.


    You can select the PaintIn3D/GUIDE to see the currently installed version. The LeanTouch components don't trigger any painting or undo/redo state creation, that's only the Paint in 3D components like P3dHitScreen.

    Back up your project before updating. If you encounter any issues then I can check out 1.9.14 again and see if I can fix just that for you.


    What do you mean "modify different materials on one object"?
     

    Attached Files:

  27. crdmrn

    crdmrn

    Joined:
    Dec 24, 2013
    Posts:
    151
    I tried that already, but the load button is always greyed out, and even if I drag a texture in there, it doesnt seem to be changed on paint... it looks like I am painting over it, but the previously painted parts are not being overwritten :S
     
  28. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    71
    I've just updated my project to 2.2.4 with ease. The issue is still persisting though. A few notes:
    - The undo button works fine unless I click off the model. I temporarily disabled the camera controls and it still does it.
    - Interestingly, the undo button works perfectly if the click is on my UI panel. It only does it if I click in the scene.
    - Just to see, I put my background objects on the UI layer to see if that helped.. It didn't. I also turned off all my background objects, but the issue also occured when clicking the void.

    So for some reason clicking off my model is activating P3dHitScreen. I'm not sure if you have any ideas? I'll keep looking into it.

    Edit: The demo scene also has the same issue..
     
    Last edited: May 28, 2021
  29. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    Thanks for the file. I tried your scene and somehow some pieces of the spaceship disappear when I run it. And also, it doesn't show painting on a black texture, which is what I'm trying to do or at least support.

    Anyway, I was able to replicate the problem with the "30 Between Painting" scene. I just changed the main colour of the spaceship texture to black. When I run the scene, the ray, which is supposed to create red spirals on the ship, doesn't paint anything.

    Black_spaceship.jpg

    If I change the model texture back to white the red lines appear.

    White_spaceship.jpg
     
  30. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    561
    @Darkcoder I mean, one object with different materials applied. E.g.
     
  31. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    71
    Alright, I fixed the issue with a dodgey workaround. I check if the player is clicking on the paintable model. If they are, I enable StoreStates in the p3dHitScreen component, and if it isn't I disable it. It seems to work.
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    The Load button will be greyed out if there is no texture in the slot next to it. By default there is no texture, because you must click export to save it to your project first. The "03 Load And Export" demo scene setup seems to work fine for me, so I'm not sure what the issue you're having is. Maybe record a video of your whole paint process including the issue?


    Yes, clicking inside the scene (not UI) will register an undo/redo state, because you could potentially be painting something with that finger. I could maybe tighten up the behaviour in a future version so it only registers the undo/redo state when a paint command is generated, but even then it's possible the command won't actually paint anything. So for now this is intended behaviour.


    How are you making it black? If you're changing the material color then of course you won't see your paint, because the red pixels will be multiplied by the black color (0,0,0), and thus everything will render as black. You must instead change the P3dPaintableTexture.Color setting to black. See the "10 Base Color" demo scene for an example.



    If these materials are shared with other objects then yes you will need to add a material cloner and paintable texture(s) for each material. You could write a script to do this if you have many objects like this.
     
  33. YousifRagab

    YousifRagab

    Joined:
    Oct 30, 2015
    Posts:
    18
    Hey, I'm trying to make a car decal customization like the one available in Real Racing 3 where you can see the preview of a decal, reposition, scale, and rotate.
    I figured the scale and rotation but can't seem to preview the decal on my phone properly, it only works on pc.

    I tried to check if the user has clicked the Done button and then save its state, but this approach adds 2 decals one for preview and the other for the placed decal, and doesn't even work on mobile properly.

     
  34. hauwing

    hauwing

    Joined:
    Dec 13, 2017
    Posts:
    69
    hi, can the decal be used on a mesh that will deform during runtime? if not can I bake the decal to the texture beforehand in editor? thx
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    Are you talking about the Live Painting features? These are designed to be used for a scenario like this, where you can call the "ManuallyHitNow" method to apply the paint. Once applied you may want to delete the painting GameObject depending on how you want it to work.


    Yes, you can paint beforehand or paint a mesh that gets deformed (e.g. SkinnedMeshRenderer, or modifying the Mesh directly).
     
  36. doukisan

    doukisan

    Joined:
    Nov 26, 2015
    Posts:
    15
    Hi! Thank you for this amazing asset.

    I'd like to make it work with my Apple Pencil on iPad, but I don't to know where to start. I noticed the documentation has an example for VR, but I found it a little confusing. Can you please help me set it up? I just need a starting point, I guess.
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    Paint in 3D uses all touch inputs Unity provides, and if it integrates with the Apple Pencil, then this should automatically work too. You may need to use the new InputSystem package. I don't have one so I don't know though.

    The VR examples are designed for the legacy Unity XR system. To make it work with another system you can basically copy+paste the VR Pen/sprayer/etc onto your VR system's tool or hand GameObject, and hook up the button/trigger/etc to enable/disable the paint the same as the examples do (see the P3dVrTool component events). Just keep in mind that the P3dHitScreen component uses mouse/touch only so it's not suitable for VR, you have to use P3dHitBetween, P3dHitThrough, P3dHitNearby.
     
  38. YousifRagab

    YousifRagab

    Joined:
    Oct 30, 2015
    Posts:
    18
    When I use live decals it gives weird results, if I use P3DHitScreen instead of P3DHitNearby it fixes the issue but still can't seem to find a way to achieve what I want.
     
    Last edited: May 31, 2021
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    Live decals are designed to work for this kind of scenario, you just have to write the code to handle how to position and when to apply them. The paint itself will be applied using the same P3dPaintDecal component, so it shouldn't give weird results unless you give it a weird position or rotation.
     
  40. doukisan

    doukisan

    Joined:
    Nov 26, 2015
    Posts:
    15
    As far as I know, the Apple Pencil doesn't use the default touch inputs, it's registered as "Pen" in the new InputSystem, so it has it's own controls: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Pen.html

    So what you're saying is that I'm going to need to write a new controller script? Can I just create the actions for the new InputSystem and call the events for "On Touch" or something like this? I'd like to replace the touch inputs for the pen actions.
     
  41. YousifRagab

    YousifRagab

    Joined:
    Oct 30, 2015
    Posts:
    18
    Thanks, I used live decals, the problem is that the decal doesn't update its rotation, when it's placed on the front bumper it looks right (Rotation (0,0,0)), but when I place it on the hood it doesn't update the rotation so it looks stretched.

     
  42. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    56
    Wow, ok, I was indeed modifying the material of the object, which would be the normal expected way to change the colour or texture of an object. I don't understand why the pixels are "multiplied" if I'm not choosing that kind of blend mode. It doesn't quite make sense to me, but maybe there's a technical reason for that constraint?

    So I did manage to make painting on a black object work, even though it somewhat messed up my mesh-generating code. It'd be nice if gameobjects with their original unmodified materials could be used as is.
     
  43. Gamer98898

    Gamer98898

    Joined:
    Nov 18, 2017
    Posts:
    8
    Hie,
    I am using Paint in 3D Plugin in mine project . I want to ask one question is there any way to paint mine own material instead of texture painting , P3d Material component only allows us to paint like Texture painting .
    Please help ,
    if its possible to do material painting if yes then how
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    If there's no way to make the Pen act like a normal finger then the simplest approach would be to modify P3dInputManager.cs:Update (line 275+). This is where the touch and mouse data is submitted, you would just need to poll the pen data and send it via the AddFinger method while it's touching the screen.


    So rotate it? You can also use the P3dHitBetween component ("30 Between Painting" demo scene), which can rotate it based on the settings you use.


    The material color setting tints (multiplies) the albedo texture. For example, if you set it to black then there's no albedo texture you can set that will make it show anything except for black. Therefore, you should never use this setting when you want to paint your objects, as the aforementioned demo scene shows.


    I don't understand your question, what else are you going to paint except for the texture? This asset is for texture painting.
     
    Gamer98898 likes this.
  45. Gamer98898

    Gamer98898

    Joined:
    Nov 18, 2017
    Posts:
    8
    1. I want to ask is that possible like I created one material and I adjusted some values in that material for an eg metallic and smoothness values etc, So now I want the output same as the material properties while painting instead of texture painting.

    OR

    2. Is that possible I could do Thickness Texture kind of painting instead of tiling way.
     
    Last edited: Jun 2, 2021
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    1 - Paint in 3D only allows you to paint textures. If your shader/material has texture slots for the Metallic/Smothness/etc, then you can paint these. You could make this texture 1x1 pixel so the whole object gets painted at the same time. Just keep in mind the material settings for Metallic/Smothness/etc typically get multiplied by the textures for these settings too. So if you set the material's Smoothness to 0, then this will effectively make the Smoothness texture always 0, because they will get multiplied. This is the same as when you set the Color to 0,0,0, and then the Albedo no longer does anything. So if you're painting these textures make sure you set the slider to 1 or whatever value causes it to exclusively use the texture value.

    2 - Sure, if your shader has some kind of '_ThicknessTexture' slot or similar then you could paint that, same for any texture as long as it uses the mesh UV data.
     
  47. ahmedNabeel_UnityDev

    ahmedNabeel_UnityDev

    Joined:
    Sep 15, 2020
    Posts:
    3
    Yes I did add my shader to the group data, named "Albedo (RGB) Alpha (A)" in its "Shader Data" like "_MainTex@shadername", and I do get the preset for the gameobject textures, and I press "+Preset" for them, but still I'm unable to paint onto them.

    Well first I make clear to you that my gameobject is a floor, with multiple texture applied for pavement, grass, roads etc. And yes I'm able to paint other objects like car, but not that floor.. Hope you understand..

    Waiting for your helpful response.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,186
    What happens when you click Analyze Mesh in the inspector for this object after you've made it paintable? It sounds like the mesh may not be suitable for painting. You can read more info about UV requirements and such in the docs.
     
  49. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    71
    @Darkcoder I'm having another issue with undo/redo which I don't expect you to resolve, I just want to run it through you and see if you have any thoughts on what it could be.

    Basically, when I draw a stroke on iOS and want to undo it; sometimes it will undo the entire stroke, but more often than not it will only undo a part of it. The issue only occurs on iOS devices (I've tested multiple) and it works fine on PC and Android. I've been playing around with the p3dHitScreen component's spacing properties but with no success. The framerate differs between devices too (30fps for iOS, 60fps for Android, 120+ on PC). Do you have any ideas as to what could be doing this?
     
  50. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    31
    Hello!
    I'm trying to figure out a way to project editable text through my first person camera onto several objects in the world. After typing, I want to rotate the camera to find the right surface(s) for the text and with a click project it into the world from the current viewing position, so that when I move the camera, the text gets distorted and appears perfectly correct when I return to the exact origin of the projection. Currently I'm using HDRP's spot light and a render texture as cookie (the render texture contains the editable text) to project into the world. This is very controllable in terms of performance, as I know exactly how big the cookie texture is and I don't have anything to do with the projection surface's textures, but it has one huge downside: the spotlight has a falloff I can't seem to avoid. This means that the part of the text that gets projected onto a surface close to the camera is super bright, while text further away becomes increasingly dim and unreadable. I would like the text to be of even color, independent of distance.
    So, I was wondering if it is possible to achieve this result somehow using the Paint in 3d asset.
    Thanks for your help!