- Home /
Answer by whydoidoit · Jan 02, 2013 at 07:20 PM
Here's a shader that will do that...
Shader "Whydoidoit/Lerp" {
Properties {
_MainTex ("First Texture", 2D) = "white" {}
_BlendTex ("Second Texture", 2D) = "white" {}
_Blend ("Blend", Range(0,1)) = 0.0
}
SubShader {
Tags {"RenderType"="Opaque"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _BlendTex;
float _Blend;
struct Input {
float2 uv_MainTex;
float2 uv_BlendTex;
};
void surf(Input IN, inout SurfaceOutput o) {
half4 c1 = tex2D(_MainTex, IN.uv_MainTex);
half4 c2 = tex2D(_BlendTex, IN.uv_BlendTex);
o.Albedo = (c1.rgb * (1-_Blend)) + (c2.rgb * _Blend);
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
}
Answer by Julien-Lynge · Jan 02, 2013 at 07:04 PM
@ina,
I don't believe so, but I haven't specifically tried it. Most likely you'd want to write a custom shader that uses two textures and a float value to sample both of them. This is very hard to do if you've never written a shader, but if you want to try it, check out this page: http://docs.unity3d.com/Documentation/Components/SL-SetTexture.html
There's an example there (Alpha Blending Two Textures) that might just do what you want.
That alpha shader in the docs is blending based on the alpha of texture1
You're right - I didn't look closely enough :)
Would be easy enough to change to an inspector float value, if you understand the basics of ShaderLab - but that could require quite a bit of reading.
Yeah - I can't do those fixed function things though :) Hence surface shader below...
Your answer
Follow this Question
Related Questions
CRT/LCD screen shader (for materials) 4 Answers
Animating from texture to texture 1 Answer
Is it possible to make an image sequence into an animated normal map? 0 Answers
How can I pan a texture to specific location on a sheet? 1 Answer
There is an issue with texture wrapping around sphere's in unity 0 Answers