Two Textures blend by alpha mask // problem with bindChannels, two UV sets

Hi guys,

I already found the right shader that blends two textures with alpha mask: white → tex1 and black → tex2:

Shader "Custom/TwoTexMixAlphaMask" {
Properties{
	_MainTex ("Main Texture (RGB)", 2D) = ""
	_PathTex ("Path Texture (RGB)", 2D) = ""
	_PathMask ("Path Mask (A)", 2D) = ""
}
SubShader {
	Lighting On
	Material {
		Ambient [_Color]
		Diffuse [_Color]
	}
	Pass{	
		SetTexture [_MainTex]

		SetTexture [_PathMask]{
			combine previous, texture
		}
				
		SetTexture [_PathTex]{
			combine texture lerp(previous) previous
		}
	}
}
Fallback "Diffuse"
}

this works very good, the problem is, i need to tile both textures but not the alpha texure. So I try to use “bindChannels” to set the coords for the both UV sets, one for tiling sets and the other for non-tiling set:

BindChannels {
	Bind "Vertex", vertex
	Bind "texcoord", texcoord0	        // 1st UV - tiling textures	
	Bind "texcoord1", texcoord1	// 2nd UV - lightmap and blend map
}

The result is: texture1 is tiled (correct!) alpha texture is not tiled (correct!) but the texure2 looks not like my tree texture, it is only brown colored, please have a look to my pictures to understand what i mean.

  1. My original textures in the editor:
    the last one is the alpha texure
    1077118--40223--$three original texures.png

  2. after i applied the shader without “bindChannels”:
    1077118--40225--$after aplied shader.png

  3. after i used “bindChannels” in my shader to apply the uv sets. The tree texture doesn’t looks like my original tree texture anymore:
    1077118--40224--$with bindChannels.png

It seems like the bindChannels assigns the coordinates not correct…

Can someone help me with this issue?

Have you tried binding all three textures to the appropriate channel?

Alternately, you should be able to use your original shader (without BindChannels) and a single UV set to get what you want by modifying the Tiling factors in the Material inspector for the textures you want to tile.

Thank you, it works for me!

hi,
This shader works perfectly but
can U tell me how can i add a bump texture to the main texture?

thx ,