Shader that blends more than 2 textures

Hi,

Maybe I’ll have better luck here.
I need to create a shader that allows you to blend more than 2 textures. I started with this below.

http://wiki.unity3d.com/index.php/Blend_2_Textures.

I’ve attempted to try to modify it to incorporate more that 2 textures. I was able to add a third but unfortunetly it will only blend the tex01 and 02 but not the third. I’m a new to writing shaders. Not sure what I did wrong here.

Here’s what I modified.

Shader “Blend 3 Textures” {

Properties {
_Blend01 (“Blend01”, Range (0, 1) ) = 0.5
_Blend02 (“Blend02”, Range (0, 1) ) = 0.5
_MainTex (“Texture 1”, 2D) = “”
_Texture2 (“Texture 2”, 2D) = “”
_Texture3 (“Texture 2”, 2D) = “”
}

SubShader {
Pass {
SetTexture[_MainTex]
SetTexture[_Texture2]

{
ConstantColor (0,0,0, [_Blend01])
Combine previous * constant + texture
}

SetTexture[_Texture2]
SetTexture[_Texture3]
{
ConstantColor (0,0,0, [_Blend02])
Combine previous * constant + texture
}

}
}

}

Any help would be greatly apperciated.

Thanks!

You’ve put _Texture2 in there twice in a row. You can omit the second instance.

Hi Daniel,

Thanks for replying. I tried getting rid of the second instance as you suggested. It seems that one slider only affect texture 2 and texture 3, the second slider doesn’t seem to affect texture 01 and texture 02 at all ??

Perhaps you want to use the lerp combiner? *+ seems odd in this situation.

Got it to work!! Thank you !

Could you please post the workin one?
thx.