Different tiling for two textures in one shader

Hey guys,
just as about any post here starts: I have no clue about shaders :wink:
What I am trying to achieve is: I want a texture (transparent ← alpha channel) to be covering a certain object and using the tile modificator to, well, make it tiled.
I have a second texture, basically a second alpha map, that blends certain areas in or out. This texture however has to be independent of the previous mentioned tiling.
Same for Offset.
You can see what I mean in the attached image, red being my (tiled 4x4) texture, green being my additional alpha.
3022150--225803--tiling.png

What I have got so far is a shader that does blend the two alpha channels nicely, but as soon as I change the tiling of the main texture also the additional alpha will change its tiling.
Changing the tiling of the alpha doesn’t affect the image at all.
Heres the code:

 Shader "Transparent/Diffuse + Extra Alpha"
{
     Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
     _AlphaMap ("Additional Alpha Map (Greyscale)", 2D) = "white" {}
}
SubShader {
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
     LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _AlphaMap;
float4 _Color;
struct Input {
     float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
     half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
     o.Albedo = c.rgb;
     o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_MainTex).r;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}

Thanks

Never mind. Heres the solution - in case someone else searches

 Shader "Transparent/Diffuse + Extra Alpha"
{
     Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
     _AlphaMap ("Additional Alpha Map (Greyscale)", 2D) = "white" {}
}
SubShader {
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
     LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _AlphaMap;
float4 _Color;
struct Input {
     float2 uv_MainTex;
     float2 uv_AlphaMap;
};
void surf (Input IN, inout SurfaceOutput o) {
     half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
     o.Albedo = c.rgb;
     o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_AlphaMap).r;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}

Note the changes in Line 18 and 23.
Cheers

2 Likes