18
2012
Texture Paint with Soft Brush
Now that the Android Basic is free, trying to make a simple multi-finger painter program as a test..
Current features:
– Orthographic camera, with full view sized drawing plane (see forum: Creating plane of dynamic sizes)
– Special shader that uses that drawing texture as emission.. (might work with just diffuse also..)
– Didnt find any code for drawing soft brush circles using for..loops.., tested MidPoint Circle Algorithm but it gives hard edges..(could blur it?)
– Now its using “decal splatting”, it takes 1 soft texture brush (see image#2 below), splats that into the drawing texture.
– Problem: alpha is not additive..so if you paint and dont move, it gives bad results (hmm..disable painting, if not moving?)
Todo / ideas:
– How to fix fast moving?
– Use input.touches + raycast? (or no need raycast?)
– Add some GUI (clear button..or actually use the shake gesture?)
– Add effects? (sliding image, from gyro?)
Webplayer:
http://unitycoder.com/upload/demos/TexturePaintSoftBrush1/
Download source:
coming later..
—
Image#2: soft brush texture, 64×64 (alpha values are used for painting)
—
Image#3: Profiler statistics for current version (8.11.2012)
—
Image#4: Quick test with particles, its quite fast 30-45fps on old android galaxy s plus
Related Posts
16 Comments + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
Why did you post this if you are not going to share source??????
How D H**L will it benefit to others??????????????????
Just waist of time…………………..
Source: “coming later..”..Oo? or if you are in a superRush, there is donate button & request source option, but as mentioned in post there are problems with the current version.
Hi mgear,
I’ve donate button and sent you something, but I see no way to request source code and I’m really curious to see your implementation. Any way to contact you? π
Hi there
I did something similar but on my android phone it goes really really slow. From the moment I press and draw with my finger until I actually see the stuff it seems to take about 1/4 of a second. Very noticiable when you draw fast.
How was your speed?
I’m curious to see the code too π
Hi mgear,
I’ve hit the donate button and sent you something, but I see no way to request source code and I’m really curious to see your implementation. Any way to contact you? π
Hi, sorry havent checked emails yet..i’ll send it later today!
Hi,
Do you think this could work at a decent frame rate on a mobile device ( iOS platform )?
I have also implemented something similar on iOS but with very low frame rate.
Tested on samsung galaxy s plus, ~4fps while painting.. Its using setpixels(). Maybe could get the same effect with “painting” additive particles over the plane instead?
Hi filo,
actually I made a donation and got the code from mgear but I think he forgot about it because the code I’ve got never worked on android. I never got a newer version so there is no way for me to help you about the ios speed π
Hmm.. I did sent 2 versions, first one 29.5.2012 (had some errors) and the other one on 31.5.2012 (email me if you dont have the file)
the version from may 31 didn’t work either…
in any case using set pixels/getpixels would make it extremelly slow. At the end I wrote my own system which i’m not too happy about (and i can’t share since it’s used on a propietary game http://www.dibudibu.com ) but it’s over 40 fps on an old nexus one.
The best way to do this is with an additive shader on a render texture. No matter what you try with setpixels it will never be as fast. I would love to see an implementation because I only found partial ones for mobile over the web.
Wow, thank you both for responding so fast.
I am also using setpixels and getting the same results. Very low frame rate.
Optimised few lines out from the paint loop and now its ~6.2fps
Some other ideas to try:
– Use high res plane, paint vertice colors instead of texture
– Paint additive particles
– Use setpixels32()
– RTT: http://answers.unity3d.com/questions/175692/getpixelsetpixels-or-stencil-eraser-brush.html
– Draw (build) a mesh instead of painting anything..
– Draw using linerenderer
– Draw using rageSpline or other 2D toolkits
– Draw using GL functions
– Fast Floodfill?
Here’s the current version for android, if someone wants to test the speed on different phones:
fingerpaint1.apk : http://www.mediafire.com/?kdjax0y49xsms3d
Added deep-profiler image, texture2D.Apply(false); takes most of the time..
Also made a quick test with particles, its quite fast, 30-40fps on that old android phone.
hey are you still going to give the source? I really wanna use this