9
2011
Painting holes with shader v1.0
mHolePainter v1.0
Using a shader from http://www.unifycommunity.com/wiki/index.php?title=Dissolve_With_Texture we can paint “holes” to the cutout texture.
Webplayer:
http://unitycoder.com/upload/demos/mholepainter1/
Download:
mHolePainter1.UnityPackage
Related Posts
12 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [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
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- 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
[…] http://unitycoder.com/blog/2011/08/09/painting-holes-with-shader-v1-0/ […]
What about doing the opposite?
I mean, painting texture on a completely transparent object?
Make the mask initially black, and paint with white color.
I have assigned shader to multiple objects . when i edit one object all other objects also get erased..
may be thats sound silly I am a new to unity. please help
I think it happens because if you place the same script on multiple objects and you paint one object, other objects will also register the raycast hit as true and will erase from that same position where it hits on the other object..
so should modify the script and move it to camera..(and then paint on the raycast hit target only)
or for a quick test, in the current script should check when the raycast is hitting, that is the hit target same as this object..
what modification s are neede so as to attach it to the camera… just want to say that your script is superb…
I did necessary changes and attached to the camera but still it doesnt work… it fails to do following part
Vector2 pixelUV = hit.textureCoord;
pixelUV.x *=tex.width;
pixelUV.y *=tex.height;
tex.SetPixel((int)pixelUV.x,(int)pixelUV.y, Color.black);
tex.Apply();
HI, How do we know if object is completely Erased or not.?
Every time you paint, could check that if pixel is not painted color, then increase pixel counter.. (until pixel counter equals total all pixels)
Or after each click, go through all pixels and see which ones are painted and which ones not.
Would be faster to use SetPixels32() array (and check from the array), instead of the invidual SetPixel()/GetPixel()
Thanks for reply, Can you provide me the C# version of the Script with some Solving example related my Query. Hope you Don’t mind
Unfortunately no time at the moment..
Try first yourself, post results/question in Unity forum, so others can help also ๐
ok thanks i will try ๐