Jan,do you have a NVIDIA card?I have an Ati so there might be some undocumented differences…
anyway,try replacing the shader with this one,it has specific texture coordinates for all three splats,might do the trick.
It also has a color slot for the pseudo-AO,so blueish indirect illumination from the sky can be faked.
Shader "Terrain/ThreeLayer Bumped" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_Shadow ("AO shadow", Color) = (1,1,1,1)
_Roughness ("Roughness", Range (0.0, 1.0)) = 0.0
// _Burn ("Lightmap multiplier", Range (0.0, 2.0)) = 1.3
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_Parallax ("Height", Range (0.005, 0.08)) = 0.02
_MainTex ("Base (RGBA)", 2D) = "white" {}
_MainTex_b ("Bumpmap (RGBA)", 2D) = "bump" {}
_MainTex2 ("Base 2 (RGBA)", 2D) = "white" {}
_MainTex2_b ("Bumpmap 2 (RGBA)", 2D) = "bump" {}
_MainTex3 ("Base 3 (RGBA)", 2D) = "white" {}
_MainTex3_b ("Bumpmap 3 (RGBA)", 2D) = "bump" {}
_lightmap ("Lightmap", 2D) = "white" {}
_Mask ("Mix Mask (RGBA)", 2D) = "gray" {}
}
Category {
Tags{ "RenderType"="Opaque"}
Blend AppSrcAdd AppDstAdd
// Cull Back
SubShader {
UsePass "Specular/BASE"
Pass {
Name "Blend_Layers"
Tags { "LightMode" = "Pixel"}
Color [_PPLAmbient]
Material { Diffuse [_Color]
}
CGPROGRAM
#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_builtin
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct v2f {
V2F_POS_FOG;
LIGHTING_COORDS
float3 uv[3];
float2 uv2 ;
float3 viewDirT;
float3 lightDirT;
};
float4 _MainTex_ST,_MainTex2_ST,_MainTex3_ST,_Mask_ST;
uniform float _Shininess;
v2f vert (appdata_tan v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.uv[0].xy = 1-TRANSFORM_TEX(v.texcoord, _MainTex);
o.uv[1].xy = 1-TRANSFORM_TEX(v.texcoord, _MainTex2);
o.uv[2].xy = 1-TRANSFORM_TEX(v.texcoord, _MainTex3);
o.uv[0].z = _Shininess * 128;
o.uv2 = TRANSFORM_TEX(v.texcoord, _Mask);
TANGENT_SPACE_ROTATION;
o.viewDirT = mul( rotation, ObjSpaceViewDir( v.vertex ) );
o.lightDirT = mul( rotation, ObjSpaceLightDir( v.vertex ) );
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
uniform sampler2D _MainTex;
uniform sampler2D _MainTex2;
uniform sampler2D _MainTex3;
uniform sampler2D _MainTex_b;
uniform sampler2D _MainTex2_b;
uniform sampler2D _MainTex3_b;
uniform sampler2D _lightmap;
uniform sampler2D _Mask;
uniform float _Parallax;
uniform float _Roughness;
uniform float3 _Shadow;
//uniform float _Burn;
float4 frag (v2f i) : COLOR
{
float4 mix = tex2D(_Mask,i.uv2);
float n1 = tex2D(_MainTex_b, i.uv[0].xy).a ;
float n2 = tex2D(_MainTex2_b, i.uv[1].xy).a ;
float n3 = tex2D(_MainTex3_b, i.uv[2].xy).a ;
float result=n1;
result=((result*(1-mix.g)) + n2*(mix.g));
result=((result*(1-mix.b))+n3*(mix.b));
float2 offset1 = ParallaxOffset( result, -_Parallax, i.viewDirT )+i.uv[0].xy;
float2 offset2 = ParallaxOffset( result, -_Parallax, i.viewDirT )+i.uv[1].xy;
float2 offset3 = ParallaxOffset( result, -_Parallax, i.viewDirT )+i.uv[2].xy;
float3 normal1 = tex2D(_MainTex_b, (offset1)).rgb * 2 -1;
float3 normal2 = tex2D(_MainTex2_b, (offset2)).rgb * 2 -1;
float3 normal3 = tex2D(_MainTex3_b, (offset3)).rgb * 2 -1;
float3 resultn=normal1;
resultn= ((resultn*(1-mix.g)) + normal2*(mix.g));
resultn= ((resultn*(1-mix.b))+normal3*(mix.b));
float4 col1 = tex2D(_MainTex,offset1);
float4 col2 = tex2D(_MainTex2,offset2);
float4 col3 = tex2D(_MainTex3,offset3);
float3 lightmap = tex2D(_lightmap,(i.uv2)).rgb;
float4 result1=col1;
result1= ((result1*(1-mix.g)) + col2*(mix.g));
result1= ((result1*(1-mix.b))+col3*(mix.b));
result1.rgb *=lightmap*2.0;
result1.rgb=lerp(result1.rgb,result1.rgb*_Shadow,((1-result)+resultn.r+resultn.g)*_Roughness);
return SpecularLight( i.lightDirT, i.viewDirT,resultn, result1,i.uv[0].z-(result1.rgb*_Shadow), LIGHT_ATTENUATION(i) );
}
ENDCG
}
}
}
Fallback "Diffuse", 1
}