Ok so I’m creating a grid based map mesh and coloring the vertexes based on what terrain each tile will be; then a texture array is used to map textures to those colors. (As i understand the process) so the issue is the small quad area inbetween 4 tiles. I’m attempting to blend the 4 surrounding colors, the splat map should be doing a channel on R,G,B,A and each of those values carries a value of 1 for the vertext/splat mapping.
I wind up with this:https://imgur.com/a/ybS7ZvT It displays 4 textures from the texture array, but the one spot I try to blend 4 colors refuses to show anything but a single texture.
Here’s the shader code I’ve worked up to this point. Am I just missing something simple or is this a more complex problem?
Shader "Custom/TileShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Terrain Texture Array", 2DArray) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows vertex:vert
// Use shader model 3.5 target, to get nicer looking lighting
#pragma target 3.5
UNITY_DECLARE_TEX2DARRAY(_MainTex);
struct Input {
float4 color : COLOR;
float3 worldPos;
float4 terrain;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void vert (inout appdata_full v, out Input data) {
UNITY_INITIALIZE_OUTPUT(Input, data);
data.terrain = v.texcoord2;
}
float4 GetTerrainColor (Input IN, int index) {
float3 uvw = float3(IN.worldPos.xz * 0.02, IN.terrain[index]);
float4 c = UNITY_SAMPLE_TEX2DARRAY(_MainTex, uvw);
return c * IN.color[index];
}
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c =
GetTerrainColor(IN, 0) +
GetTerrainColor(IN, 1) +
GetTerrainColor(IN, 2) +
GetTerrainColor(IN, 3);
o.Albedo = c.rgba;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}