Search Unity

TexturePaint on the Asset Store!

Discussion in 'Assets and Asset Store' started by Pheck, Dec 20, 2012.

  1. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    TexturePaint a runtime asset texture painting tool is now on the asset store! Yay!

    Its a 2d texture painting tool that can be used for very powerful decals, extend it for custom gameplay like Portal 2 painting gameplay, use it to shoot holes in walls or leave drag marks across the ground. Its a great, powerful and efficient tool.

    Whats the roadmap?:
    The current version is a 2d grid painting tool, and I am currently extending it to paint on 3d objects with any uv setup.
    After that I will be extending TexturePaint to support full HDR textures.

    DX11 compatibility has been added and is now in the Assset Store!

    TexturePaint has code paths that will work in Unity Pro (GPU or CPU) or Unity Basic (CPU only).
    Procedural shapes or textures can be used for the paint brush. (Texture brushes Unity Pro only.)

    I am very excited about this tool, let me know what you think and where you think I should take it.
    Thanks,

    Video:
    http://www.youtube.com/watch?feature=player_detailpage&v=YGeJ4_eS4-I

    Screenshot:


    Store:
    https://www.assetstore.unity3d.com/#/search/texturepaint
     
    Last edited: Mar 15, 2013
  2. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    Painting on 3d objects is now working!
    I am just ironing out the last bits of the interface and then I will submit it to the store as an update. :)
    I also have a fix for the log warning that happens in new levels.

    Next is HDR, file saving and editor painting mode.
     
  3. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Wow, awesome!
    Just one question - can you do paint mixing? Because from that youtube video, it looks like its just cycle through color, it doesn't look like you can "mix the paint" (let's say red + yellow = orange).
     
  4. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    Its not currently doing paint mixing, you are correct, the video is just cycling colors. Paint mixing would be possible though, it would just be a change in the shader in how it "prints" into the texture. The current idea is centered around holes in walls, blood splats, marks on floors / walls; but I wanted to make sure I was building it forward thinking for painting etc. (imagine painting a mask which shows flaming wood on a wood wall with a blowtorch in a game, etc.)

    I am finishing up the feature of painting on complex 3d objects right now and hope to submit that in the next day or two. Then I am working on file saving / editor mode. When I am working on editor mode, I will make sure to add "blend modes". While working on blend modes, I will make sure to think about mixing colors. ;)

    Thanks for the input, glad you like it. :)
     
  5. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    I just submitted the 3d painting feature set to the store. Look for it soon! :)
    Here is a quick screenshot.

     
  6. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
  7. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    TexturePaint and FluidSim have been updated on the store to add proper iOS support.

    yay!
     
  8. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Nice asset... I have a project with Kinect that needs to paint over 3D, this just uses the mouse right? Is it easy to transfer for another kind of input?
    How do you handle the painting?
     
  9. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @xandeck

    I use the mouse as an example input. Anything could be used for an input, for example I used enemies walking across a battlefield once.

    The system is designed to be highly flexible, painting is broken down into:
    - a "sim grid/3d object" which is used to determin where to paint into the texture.
    - a object with the paint brush script on it (I call these objects InfluenceActors)

    The paint brush tells the sim its position, rotation and scale. those are then used to paint into the texture. This allows anything to be used as a "brush".

    In the included sample files, I have an invisible paint brush object (InfluenceActor) that I update based on where the mouse clicks and then it rotates to match the surface normal.

    The video doesnt show it, but the system supports multiple paint brushes active at the same time. The max number is limited only by performance. I have an artificial limit set at 128 paint brushes at one time only because I didnt expect anyone to hit that limit. IF you need more than that, its a single variable change.
     
  10. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Thanks, looks promising. If we get the project, I will get your solution. :)
     
  11. Deleted User

    Deleted User

    Guest

    I need to save the new painted texture to disk...

    How can i do it?


    Thank's in advance.
     
  12. Deleted User

    Deleted User

    Guest

    Hi there...

    How to change Color in the texturePaintInfluenceActor in Runtime?

    OK...

    I got it ;-)

    #pragma strict
    private var tempColorDetails : colorInfluenceClass;

    var thisObject : GameObject;



    function Update () {

    }

    function OnClick () {
    tempColorDetails = thisObject.GetComponent(TexturePaintInfluenceActor).colorDetails;
    tempColorDetails.colorValue =Color.yellow;

    }
     
    Last edited by a moderator: Feb 23, 2013
  13. dougP

    dougP

    Joined:
    Mar 2, 2013
    Posts:
    6
    I bought your tool from the asset store. it worked great on pc, iPad and Galaxy s3. however, it did not work on Kindle fire hd and Galaxy tab. Render texture did not show. Could not paint on 2d nor 3d object. please help. I would like to use your paint texture function on my app. Thanks.
     
  14. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ emo55
    Save to disk would need to be done in the same way mentioned in the forums for saving render textures to disk. you need to use the readpixels method to copy the rendertexture data into an image that is then saved as a png.
    check out this and if that isnt enough, there are well documented methods on the forum. http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.ReadPixels.html


    @dougP
    I am not sure why it wouldnt work on Kindle fire or Galaxy tab but why it would on the s3. I have not tested the tool on Android and dont know that environment very well. I have tested pc, mac, iphone and ipad and know those environments much better. Since you mention it works on a Galaxy s3, it sound more like a Unity3d issue with that hardware or OS setup. Can you verify that unity is even creating render textures on the fire or tab? Does the tool work if you set it to not use render textures? (use the gpu boolean on the paint surface to switch to full cpu mode.) Do other features that use render textures work? does the log give you a error that would direct us to the problem?
     
  15. dougP

    dougP

    Joined:
    Mar 2, 2013
    Posts:
    6
    Pheck
    I just did a full cpu mode test on the galaxy tab and it worked. Painfully slow ofcourse. I'll poke around and see if these devices even allow me to use renderTexture. I'm not quite sure how to get a debug log from from these devices. Please let me know if u have any idea. Thanks

    Update: I just did a test with renderTexture and it worked. I manually create a renderTexture and blit a 2dtexture to it when a mouse click is detected.
     
    Last edited: Mar 5, 2013
  16. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @dougp

    ok, its good we have more info... the texture paint setup doesnt require a specific rendertexture format, but some of them look better than others. possible that hardware cant use the format that is set in the script.

    what format did your rendertexture test use?

    TexturePaint uses RenderTextureFormat.ARGB32 and is set at line 213.
    if you find your test used a different format, try setting this value to the format you used and see if that fixs it for that specific hardware setup.
     
  17. dougP

    dougP

    Joined:
    Mar 2, 2013
    Posts:
    6
    Pheck,
    It worked when I changed it to textureRenderFormat.ARGBHalf. However, it seems like I can't changed color texture in texturePaintInfluenceActor. I changed different color textures, even with an empty (clear) one and it still draws circle pattern. Any ideas?

    Update: RGBHalf causes rendertexture failed to create error. Switch to RGB565, no more error and works correctly in pc. However in galaxy tab, still only draws circle splat pattern. It must have failed to create correct rendertexture in Tab.
     
    Last edited: Mar 7, 2013
  18. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @dougP
    I am glad you found a format that is working for you.

    TexturePaint requires a rendertexture to allow the painting of an specific image as a brush instead of a procedural circle. if you can get it to create a texture and it still does the circle, then check the below:
    If you find you need different texture formats for different platforms, you could always have a if() statement that checks for platform and then sets texture format.

    Is "Use Gpu" turned on in the paint surface?

    Is "Use Texture" turned on in the paint brush and is a texture assigned that has detail which should show up when painted?

    Does it show the texture when painted on other platforms or do all platforms paint the circle?

    I am not sure what shader features android supports, but texture paint uses fairly traditional shader features. I would expect they should work on android. The circle you mention only shows up when using the CPU version instead of the GPU version, when the GPU isnt supported, or when a setting is off by accident.
     
  19. dougP

    dougP

    Joined:
    Mar 2, 2013
    Posts:
    6
    Pheck,
    Thanks for all your feedbacks. After few attempts to debug, it seems that TexturePaintScript.js fails at line 431 with impulseLocationTexMat.SetTexture when running on galaxy tab. Any idea? Do you have another simple impulseLocationTexShader for me to test just to see if anything show up at all? Thanks.
     
  20. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @dougP

    hmm... strange that its failing on that set texture and not on all set textures. But its possible that shader is the first shader in the setup to require shader model 3.0. because of the high instruction count on some of the shaders that deal with high numbers of influence actors it needs shader model 3. if you are not using high numbers of influence actors you may be able to remove #pragma shader 3.0 from the shader and it may work for you on android. Just a word of warning though, I added that to shaders because it was needed in a few setups. if you decide to remove it, do it one shader at a time until your setup is working the way you need.

    I dont know android galaxy tab, so I have no idea if it supports SM 3.0 equivalent features.
     
  21. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    I just uploaded a update to the store for TexturePaint that adds compatibility for DX11.

    Yay!
     
  22. dougP

    dougP

    Joined:
    Mar 2, 2013
    Posts:
    6
    I downloaded your latest update and it worked on Kindle Fire but quite unstable. Crashed after painting few times. Tried it on Galaxy S3 and it looked like rendertextures did not initialized correctly on 3D objects. It worked on S3 perfectly fine with previous version.

    Here's the screen capture:
    $Screenshot_2013-03-26-23-18-42[1].png
     
    Last edited: Mar 27, 2013
  23. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @doup

    hmm, interesting... well if the older version works better for you, there isnt any reason to use the new one.
    The only substantial change in the code is how it creates render textures, it was about a 2 line change.

    does the sample level work as expected on pc/mac?

    The crashes I cant really comment on without more debug info, most crashes tend to be questions for Unity corp though since they can be so platform specific with their code. Also, as far as i can remember, nothing changed in the painting code which means if the crash is from the update, it would be something to do with the rendertexture code in the script or in unity.

    before the most recent update it would create rendertextures without any special setup, just create them and use them. now it goes through a specific process of creating the texture, setting it on a dummy camera actor, rendering to it for one frame, the removing the texture from the dummy camera and deleting the camera. Unfortunately, Unity 4 dx11 wont work correctly with render textures without these extra steps. Since I dont have an Android hardware or software to test I dont know if it works and i cant debug it. But please let me know if you see something that might help if i changed it in the code to help you make your android project work. It sounds like its on teh cusp of everything working but it may need platform specific code changes to pull it together the same way across all of the hardware you are working on.
     
  24. dougP

    dougP

    Joined:
    Mar 2, 2013
    Posts:
    6
    @Pheck,
    Not destroying dummy cameras and set their background color to white did the trick for me. Just create one dummy camera and reuse it for other rendertexture creation. That way there're not too many cameras in the scene. It's now working on all my test devices. Thanks for all of your responses.
     
    Last edited: Apr 9, 2013
  25. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @dougP
    thats great, glad you found a solution. I hope this funny dx11 camera creation stuff gets worked out on the Unity end. it appears it can cause problems in a wider distribution concept.
    I will take a look at the dx11 setup in the store and look for any ways i can streamline it more than it is. maybe a dx9 logic check to use the old method that everyone is used to using.

    Thanks for the info, glad its working for you.
     
  26. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Hi Pheck, I just bought the plugin and tried it out.

    The 3D example is not working. The other 2 demos worked fine.

    I have unity pro 4.1.2 on Mac.
    Here are the screen shots.
    1. Before playing the scene: https://dl.dropboxusercontent.com/u/48378123/TexturePainBeforePlaying.tiff
    2. After clicking the Play button : https://dl.dropboxusercontent.com/u/48378123/TexturePaintPlaying.tiff

    Edit: For each mesh, I unchecked the "Static" box and now it these meshes show up in-game. I can now paint on them. Very strange ... The lightmap looks ok and the meshes being static should work but it doesn't. Do you know what the problem might be?
     
    Last edited: Apr 12, 2013
  27. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Have a Question:

    Use Case: "An Eraser"

    I have a texture on a model with a Decal. I would like to cover the Decal with a layer of paint. Then let the user erase the paint and exposing the Decal. Kinda like an Eraser tool. How would something like this be done.
     
    Last edited: Apr 12, 2013
  28. Wisit-Nik

    Wisit-Nik

    Joined:
    Jul 28, 2012
    Posts:
    12
    I have a problem with "ExampleEveryFrameUpdate" scene, after I saw you could use 2 influences (1. auto translate and 2. click paint) in that scene on youtube. But when I try by myself, it won't work, only auto translate one can paint but click paint didn't work at all.
     
  29. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    Hi Rocki,
    Sorry for the slow reply, when I am busy at work it doesnt lend me time to search forums for support requests. if you need a quick reply I recommend sending a request via the forum msg system instead. anyways... onto your post.

    Everything seems to work fine for me in 4.1.2 in both dx9 and dx11. Without more info, I dont know what would be causing this oddity for you.
    Are you on the lastest texturepaint version in the store? Are you seeing this issue happen with other objects? could it be a general 4.1.2 bug in unity?
     
  30. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    Hi WisitNik,
    Yes, I have noticed that also, its a bug happening in the latest version, but its not a bug. I just messed up the level setup last time i uploaded it and need to submit a cleaned up sample level.
    The other example level of "update once each click" is working fine if you are looking for a sample of that method.
    I am looking into the cleanup on that level right now and will upload it once I have it resolved... I think I just forgot to hook up the clicking script. :)
     
  31. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @rocki,

    hmm... well i think there are two things here. one is how to let someone paint and erase: one method would be to have a shader that looks for its color from a texture they can paint color into, then the shader looks at another texture for its transparency that the user can paint into. you would control which texture the user paints into by knowing what mode you let allowed them access to.

    the second part of your question is difficult because i dont fully understand what you want. you mention a piece of geo, with a decal on it. then you want to paint over the decal so people can erase the paint that was placed over the decal??? texturepaint just modifies a texture, which you can then render to the screen by putting it in a shader on a piece of geo. decals render over geo, so to paint over a decal you would need a way to render a texture over or inside of the decal so it could be hidden.
    I would you approach this by thinking of your paint as erasing the decal instead of painting over it. this would give you similar feedback and might be technically easier.

     
  32. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Ah, I get what you mean by :

    "texturepaint just modifies a texture, which you can then render to the screen by putting it in a shader on a piece of geo. decals render over geo, so to paint over a decal you would need a way to render a texture over or inside of the decal so it could be hidden."

    I think I understand how TexturePaint works now, it only modifies the existing texture. What I am looking for then is a kind of TexturePaint Shader that can support multiple textures. For example, if the shader can support 2 textures, then I can put a Decal texture on the bottom layer and have TexturePaint color layer on top. This way when I paint with TexturePaint color, they top layer gets filled with color which then covers the lower layer. Likewise, if I Erase the TexturePaint color layer, then the lower layer is revealed.
     
  33. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ rocki,

    Exactly!
    Texturepaint just paints into one texture (per script), you can then blend those textures however you want in a shader. you can also paint into multiple textures by setting up multiple texture paint actors.

    I was momentarily confused by your term decal... to me a decal is something in UE3 that rendereds a texture on top of geo. in unity they call them "projectors", but I was thinking of decals. :)
     
  34. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462

    Very cool.

    I understand what you mean, but I'm not a shader expert and cannot translate this to code. Do you think you can you whip up a small example of how this can be done. This would really help me. Thanks.
     
  35. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @rocki
    Part of what you are asking for isnt simple, The way you say some of what you want to do could be interprited into difficult work. Part of what you are asking about is fairly simple. If you want to blend between two textures, you want to mix them by writing a shader that uses the painted texture to lerp between your visible texture and the background texture. for example:
    lerp(backgroundTexture, decalTexture, paintedValue)
    there are many examples on the forum if you need some sample code.
     
  36. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Pheck,

    Sorry the question unintentionally asked for something that is difficult to do. This is due to my Ignorance of how Texturing and Shaders work behind the scenes.

    Thanks for the tip about the blending.
     
  37. ganesh-pingale

    ganesh-pingale

    Joined:
    Dec 19, 2012
    Posts:
    11
    hey is there any Undo functionality like paint if not how can I add for this.
     
  38. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ ganesh.pingale

    Unfortunately there is no undo method, everything happens at runtime and there isnt a "history" being saved. one could be implemented if you saved a different image for each paint action or for the last X# of actions. This wouldnt really be cheap on perf, but it would be possible.
     
  39. hoony

    hoony

    Joined:
    Aug 23, 2012
    Posts:
    5
    Hi Pheck.

    Is it possible to add multiple InfluenceActor? I want multi-tuch painting.

    How can I make it to work multiple influencesActor?
     
  40. Tonmeister.

    Tonmeister.

    Joined:
    Mar 30, 2013
    Posts:
    27
    I have exactly this problem with that particular scene, using the latest purchased and latest unity pro
     
  41. eduhcano

    eduhcano

    Joined:
    Mar 14, 2013
    Posts:
    1
    I'm trying to add multiple InfluenceActors, but I only get to paint with one of them. How can I setup the scene with multiple actors?
     
  42. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    hi there
    I'm running tons of these warnings when i hit play on any of the examples:
    Tiled GPU perf. warning: RenderTexture color surface (256x256) was not cleared/discarded, doing <run with profiler for info>
    UnityEngine.Graphics:Blit(Texture, RenderTexture, Material)
    TexturePaintScript:DissipateColor() (at Assets/TexturePaint/Scripts/TexturePaintScript.js:534)

    Any idea what it means?
     
  43. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    I sent a few messages a couple of days ago as per your contact instructions but not reply.

    ty!
     
  44. rufreakde

    rufreakde

    Joined:
    Jan 16, 2013
    Posts:
    36
    Hey :D,
    I have some questions and hope you can give me a reply.

    1. Could I use your API for a character Editor like in a RPG?
    So people can paint in-game on their armor or something like that.

    2. Would every "brush use" create a new material in unity? Or is it directly painted on a texture you store as a *.png ?

    3. Also is it possible to Layer a standard texture under the texture you modify with your API so by pressing restore it will reset the character looks.

    Cheers and thanks in advance :D
    ruFREAKde
     
  45. rufreakde

    rufreakde

    Joined:
    Jan 16, 2013
    Posts:
    36
    Still no reply? :(
     
  46. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ sonic vis
    As far as I can see, I have replied to all of your msgs. is there one that you are looking for that I may not be seeing in my in box?

    It can take me a few days to get back to a msg when I am swamped at work. I try to get to them asap since I know we are all busy.
     
  47. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ whit nit
    The click example was removed from that level, it should be reflected in the on screen instructions for that example level. It was removed because its redundant to the other example level.
     
  48. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ rufreakde
    I don't check the forum often because its not often posted to. the quickest way to get a hold of me is to send a msg via the forum mail system.
    For some reason I have not received email notifications of forum posts from the unity forum system ever since they switched software a few years ago. (I still like the old system better :( the search was much more effective, now I just use google to search the forum.)

    1 - You could setup a system that uses TexturePaint to paint on armor. but the API doesn't provide everything for a full inventory system, its mostly intended for runtime features that don't need to stick around forever.

    2 - TexturePaint paints into a texture in memory. it doesn't care how you use the texture in the materials or what material you use it in.

    3 - As for a base layer texture, there are built in methods for a starting texture, and to reset to a specific starting texture at runtime. you can also just overlay what is painted onto another texture in a shader if that works best for your setup.

    hope that answers your questions deeply enough.
     
  49. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    An update was posted to the store that contains improvements and files in C# for those that don't want to use JS.

    Enjoy, and if you see anything that could use improvement or feedback, make sure to msg me on the forum mail system.
     
  50. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    225
    @ eduhcano
    Using multiple actors isn't a problem, do you have a specific use case that you can help me build on my end to see your problem. TexturePaint supports around 64 to 128 actors by default, and that number is just a INT which you can turn up in the scripts. Outside of memory and perf of your platform, there isn't a limit to the number of actors TexturePaint can use.

    If you look deep in the code, you will find I optimize around specific set sizes of paint actors. For instance the difference in perf from 7 actors to 8 actors is almost zero because TexturePaint is batch processing actors in powers of two up to 8 as the largest size. It then processes smaller groups in powers of 2 depending on how many influenceActors are near a specific paint canvas. if you move all of your actors away from the canvas, it wont try to draw any of them.