Hi guys, I have a problem with a shader i’m writing.
this is the result i have at the moment:
I’m using a sprite as mask that make the back sprite visible when it pass over it.
Then with another sprite containing details in alpha channel i’m making face features more darker.
My problem is that blue/black bar you see over and under the face.
In surface shader i’m using as output alpha the one of the Detail sprite, but this sprite is smaller than the the sprite over i apply the whole effect.
How can I say something as: " alpha = 0 out of the face area, and alpha = detail.a in face area" ?
this is my shader:
Shader "Custom/SlideFaceShader" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Mask ("Culling Mask", 2D) = "white" {}
_Details ("Details", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range (0,1)) = 0.1
}
SubShader
{
Tags {"Queue"="Transparent"}
Lighting Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest GEqual [_Cutoff]
Pass
{
SetTexture [_Mask] {combine texture}
SetTexture [_MainTex] {combine texture, previous}
}
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _Details;
struct Input {
float2 uv_MainTex;
float2 uv_Details;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 details = tex2D (_Details, IN.uv_Details);
o.Albedo = c.rgb * details.rgb;
// How can I make it 0 out of details texture bounds?
o.Alpha = details.a;
}
ENDCG
}
}
Hope this is clear enough!
Many thanks guys, hope you can help me, I can’t find a solution.
Thanks, Gabriele