- Home /
How to clean on RenderTexture to transparent with brush
Hi Everyone, (this is the question I posted here)
[done]1, I created RenderTexture, initial it in color(1, 1, 1, 0) with shader and attached to Plane object. And one checker pattern background behind it.
[done]2, Use Graphics.DrawTexture() to draw my brush texture (Tga format with alpha channel) with Alpha blending shader on it.("Blend SrcAlpha OneMinusSrcAlpha" in shader)(See Image1: the checker pattern is the background layer)
[Problem] 3, How can I clean the drawing back to transparent with my brush with correct shader in Unity?
Shader "Custom/CleanerShader" {
Properties {
// Adds Color field we can modify
_Color ("Main Color", Color) = (1, 1, 1, 0)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Transparent" }
LOD 100
Pass {
Lighting Off
SetTexture [_MainTex] {
// Sets our color as the 'constant' variable
constantColor [_Color]
// Multiplies color (in constant) with texture
combine constant * texture
}
}
}}
I’m new to unity shader and know that my shader changed whole texture to clear color, so the result is transparent square, not my brush shape. (See Image2), Any suggestion for it?? Thx
Just suggesting: may find more help with shaders in the Unity shaderlab forum http://forum.unity3d.com/forums/shaderlab.16/