Hi All, I figured this out finally.
I should mention that I got a clue here, albeit not one that I understood:
http://forum.unity3d.com/threads/unity-3-2-update-too-many-texture-interpolators-in-triplanar-projection.78579/
I needed to build my own normal variable and get it through using a vert program and changes to the input struct, using the one that's there already freaks out unity (a fixable bug?). My new normal stuff is ccalled "myNormal".
Shader "gamevial/TerrainWorldMapped" {
Properties {
_Control("Control",2D)= "grey" {}
_Splat0("Texture1 (R)", 2D) = "white" {}
_Normal0 ("Bump1 (R)",2D)="grey"{}
_Splat1("Texture2 (G)", 2D) = "white" {}
_Normal1 ("Bump2 (G)",2D)="grey"{}
_Splat2("Texture3 (B)", 2D) = "white" {}
_Normal2 ("Bump3 (B)",2D)="grey"{}
_Splat3 ("Texture4 (A)", 2D) = "white" {}
_Normal3 ("Bump4 (A)",2D)="grey"{}
//_MainTex ("BaseMap (RGB)", 2D) = "white" {}
//_Detail("Fallback Detail",2D)="white"{}
_Scale ("Texture Scale", Float) = 0.1
}
SubShader {
Tags { "RenderType"="Opaque" "SplatCount" = "4" "Queue" = "Geometry-100" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
//#pragma target 3.0
struct Input {
float2 uv_Control;
float3 worldNormal;
float3 worldPos;
float3 myNormal;
};
void vert(inout appdata_full v, out Input o) {
o.worldPos = mul(_Object2World, v.vertex).xyz;
o.worldNormal = mul(_Object2World, float4(v.normal, 0.0)).xyz;
o.myNormal=o.worldNormal;
}
sampler2D _Normal0,_Normal1,_Normal2,_Normal3;
sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
sampler2D _Control;
float _Scale;
void surf (Input IN, inout SurfaceOutput o) {
half4 vCT=tex2D(_Control, IN.uv_Control).rgba;
float vBlack=1-vCT.r-vCT.g-vCT.b;
float2 UV = IN.worldPos.xz*_Scale;
if(abs(IN.myNormal.x)>0.5) {
UV = IN.worldPos.yz*_Scale; // side
}else if(abs(IN.myNormal.z)>0.5) {
UV=IN.worldPos.xy*_Scale;//front
}
half3 vAlb=(tex2D(_Splat3,UV).rgb*vBlack)+(tex2D(_Splat0,UV).rgb*vCT.r)+(tex2D(_Splat1,UV).rgb*vCT.g)+(tex2D(_Splat2,UV).rgb*vCT.b);
half4 vNor=(tex2D(_Normal3, UV)*vBlack) + (tex2D(_Normal0, UV)*vCT.r) + (tex2D(_Normal1, UV)*vCT.g) + (tex2D(_Normal2, UV)*vCT.b);
o.Normal= UnpackNormal(vNor);
o.Albedo =vAlb;
}
ENDCG
}
FallBack "Diffuse"
}
↧