I have got a Texture(Render Texture) and a need to crop it with Apha Texture.
Can anybody help me with shader?
I’m sorry for my bad English.
I have got a Texture(Render Texture) and a need to crop it with Apha Texture.
Can anybody help me with shader?
I’m sorry for my bad English.
What do you mean by crop? Can you post a link to an image?
Do you mean masking? If so then something like the following should do the trick:
fixed3 outColor = tex2D(_RenderTexture, _UV) * tex2D(_MaskTexture, _UV).a;
ilya_ca
Yes, you right. I’ve found the solution:
SetTexture [_Mask] {combine texture}
SetTexture [_MainTex] {combine texture, previous}
I wouldn’t recommend using fixed function shaders (they’re ummm, out of date and quite inflexible). Take a look at surface shaders (they are the simplest ones and very powerful): http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaders.html
If you’re not using lighting, and fixed function does what you want, then fixed function is the most concise, portable, and usually the most efficient way to write a shader. They will run fine on very old hardware, OGLES 1.1 (which is still often faster than OGLES 2.0), and Unity will convert them to tiny (much smaller than any surface shader) vertex/fragment shaders as necessary on anything newer.
ilya_ca
Thank you. I tried to use a surface shader, but when I attempt to use it, I receive error - “Shader needs a normls…”. I need only position and uv. I didn’t understand how to change that.