- Home /
add alpha variables to a customised diffuse detail shader
I have modified the diffuse detail shader so that it now had more layers that are overlaid. I want each of these layers to fade in gradually using alpha. How do I change the shader to allow each layer to have its own alpha variable? Below is my shader code. Thanks for any help.
Shader "Custom/Dirt" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Detail ("Detail (RGB)", 2D) = "gray" {}
_Detail2 ("Detail2 (RGB) Trans (A)", 2D) = "gray" {}
_Detail3 ("Detail3 (RGB) Trans (A)", 2D) = "gray" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 250
CGPROGRAM #pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Detail;
sampler2D _Detail2;
sampler2D _Detail3;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_Detail;
float2 uv_Detail2;
float2 uv_Detail3;
float2 trans_Detail3;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
c.rgb *= tex2D(_Detail,IN.uv_Detail).rgb*2;
c.rgb *= tex2D(_Detail2,IN.uv_Detail2).rgb*2;
c.rgb *= tex2D(_Detail3,IN.uv_Detail3).rgb*2;
o.Albedo = c.rgb;
o.Alpha = c.a;
} ENDCG }
Fallback "Diffuse Detail" }
By fade in, do you mean that Detail1 might be a pattern of cracks, transparent between them. So, when you combine it with $$anonymous$$ain, it looks like someone drew the cracks drawn on top of $$anonymous$$ain?
In other words, the Detail textures should act like Decals?