I am trying to create an ice shader, basically where the ground texture slowly starts to freeze.
To do that I slowly want to fade another texture (the one with the ice crystals) in.
How would I do this?
Also how can I expand this idea by not just fading it in but only fade it in over a mask?
For example if I use this mask: Imgur: The magic of the Internet I only want the effect to fade through on the white bits but not on the black bits, or the other way around.
I would appreciate some explanation because I am a bit stuck on how to achieve this^^
So you would need to read the texture values of your normal texture, of your ice texture and your fade texture. You could then control the general fade strength with a float property from zero to one and lerp the main and ice texture:
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_IceTex ("Texture", 2D) = "white" {}
_FadeTex ("Texture", 2D) = "white" {}
_FadeStrength("Fade Strength", Range(0.0, 1.0)) = 0.5
}
...
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _IceTex;
sampler2D _FadeTex;
fixed _FadeStrength;
...
half4 frag (v2f i) : SV_Target
{
fixed4 mainColor = tex2D(_MainTex, i.uv);
fixed4 iceColor = tex2D(_IceTex, i.uv);
fixed fadeTexValue = tex2D(_FadeTex, i.uv).a;
fixed fadeValue = fadeTexValue * _FadeStrength;
fixed4 color = lerp(mainColor, iceColor, fadeValue);
return color;
}