I’ve been trying to use texture arrays as an alternative to having diffuse textureA, diffuse textureB, diffuse textureC, ect, and mixing them but I haven’t had much luck. I’ve tried to follow the example in the documentation, however 've had to innovate in a few area’s, given how sparse it is. What I’m aiming for is to take an array with four slices, and then blend them together based on a vector that I pass in.
In the properties I have:
_AO_Array ("AO Array", 2DArray) = "" {}
_BlendingValues ("Blending Values", vector) = (0.3333333, 0.3333333, 0.3333333, 0)
Then in the shader block:
UNITY_DECLARE_TEX2DARRAY(_AO_Array);
half4 _BlendingValues;
fixed4 mapArray(float2 uvs, sampler2Darray mapArray, half4 blendValues){
return lerp(UNITY_SAMPLE_TEX2DARRAY(mapArray, float3(uvs, 0.0)), lerp(lerp(UNITY_SAMPLE_TEX2DARRAY(mapArray, float3(uvs, 0.333)), blendValues.x), UNITY_SAMPLE_TEX2DARRAY(mapArray, float3(uvs, 0.667)), blendValues.y), blendValues.z);
}
And int the surf function:
fixed occ = mapArray(IN.uv_MainTex, _AO_Array, _BlendingValues).r;
The problem is that I get an error telling me that: Unexpected identifier “sampler2Darray”. Expected one of: in inout out uniform sampler sampler1D sampler2D sampler3D samplerCUBE sampler_state SamplerState SamplerComparisonState bool int or a user-defined type at line 85
This refers to the declaration of the mapArray function. I’ve tried using sampler2D[ ] instead of sampler2Darray, but that gust gives me:
Unexpected token ‘[’. Expected: identifier at line 85
So I’m pretty much at a loss.