I’m currently working on a surface shader that uses a texture array. For some reason, the uv’s being passed to the surf function appear to always be (0,0,0), even though I’ve confirmed that the uv’s on the mesh (a simple quad) are [ (0,0,8) , (1,1,8) , (1,0,8) , (0,1,8) ].
I’m certain the texture array and mesh themselves are fine, because everything worked correctly when I used a vert/frag shader, but I want to switch it to a surface shader so I could easily have lighting.
Here is my shader code:
Shader "Rimply/TextureArray"
{
Properties
{
_MyArr ("Tex", 2DArray) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.5
#ifndef SHADER_TARGET_SURFACE_ANALYSIS
UNITY_DECLARE_TEX2DARRAY(_MyArr);
#endif
struct Input
{
float3 uv_MyArr;
};
void surf (Input IN, inout SurfaceOutput o)
{
#ifndef SHADER_TARGET_SURFACE_ANALYSIS
half4 c = UNITY_SAMPLE_TEX2DARRAY(_MyArr, IN.uv_MyArr);
o.Albedo = c.rgb;
#endif
}
ENDCG
}
Fallback "Diffuse"
}