Hello.
I'm looking for a transparent diffuse shader that combines two textures' alpha channels like this
I think there was a standard shader in one of the online repositories that does this, but I can't find it anymore.
Appreciate your help!
thanks, vivien
Edit :
Related to the above: What could I do to animate (scroll) the texture 1 and it's alpha and keep texture 2 static? (The result would be a scrolling transparent texture with a static alpha that makes it f.i fade at the borders)
Thanks!
taoa
October 8, 2010, 10:33am
2
How did you end up with some white in your red/green/blue channels? ^^
Anyway, here you go:
Shader "Transparent/Diffuse + Extra Alpha"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_AlphaMap ("Additional Alpha Map (Greyscale)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _AlphaMap;
float4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_MainTex).r;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
Sinon vous auriez pu me demander directement.
V.
Azial
February 24, 2013, 11:20pm
3
Nice Shader, for those who want it as additive Shader (useful for fire-effects like in WoW since Wotlk) I wrote this:
Shader "Custom/AdditivMask" {
Properties {
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_MainTex ("Particle Texture", 2D) = "white" {}
_AlphaMap ("Additional Alpha Map (Greyscale)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
Blend SrcAlpha One
AlphaTest Greater .01
ColorMask RGB
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _AlphaMap;
fixed4 _TintColor;
struct Input {
float2 uv_MainTex;
float2 uv_AlphaMap;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex) * _TintColor;
o.Albedo = c.rgb;
o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_AlphaMap).r;
}
ENDCG
}
FallBack "Diffuse"
}
I was able to pull off an unlit effect by using
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
//o.Albedo = c.rgb;
o.Emission = c.rgb;
o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_MainTex).r;
}