It’s a little bit tricky to explain what I want to do, but hopefully the images will help clarifying it.
I want to make a shader that takes two textures. The first texture should highlight the texture beneath it, using additive blending.
Texture 1: Black and white image used for Highlight.
Texture 2: RGBA image, alpha is telling what part to render.
Animated UV script is added to scroll the highlight image across the mesh.
So far (with help from a friend) I get this result:
The text alpha is correct and overlay is displaying sort of correct but the text is black.
This is the additive effect I want but it should only display within the alpha (which is the text border).
Here is the code so far (at the moment it displays the text correct but not the highlight, I can sort of see the highlight moving beneath the text when I animate the UV’s):
Here are the texture files: http://www.coindrop.dk/unityforum/highlightshadertextures.zip
Hope someone can point me in the right direction.
Shader "Decal2" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_DecalTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
//Tags { "RenderType"="Opaque" }
//Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
//LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _DecalTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_DecalTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
half4 decal = tex2D(_DecalTex, IN.uv_DecalTex);
c.rgb = lerp (c.rgb, decal.rgb, decal.a);
//c.rgb = lerp (decal.rgb, c.rgb, decal.a);
c.a *= decal.a;
c *= _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Diffuse"
}