Sampling Texture2DArrays in Domain shader not working

The following line works in vert shaders and frag shaders:

UNITY_DECLARE_TEX2DARRAY(_DispTex);

// ...

float4 disp = UNITY_SAMPLE_TEX2DARRAY(_DispTex, float4(0, 0, 0, 0));

But when used in a domain shader I get with:

Anyone know why this happens? MSDN says that Texture2DArrays are supported in the domain shader, so what gives?

On a side note, is there anywhere I can see what the UNITY_SAMPLE_TEX2DARRAY macro expands to? It doesn’t look like it’s in UnityCG.cginc. If I knew what it was doing, I may have a chance at just writing the sample code for the targeted platforms.

I believe it uses Sample() which is only supported in pixel shaders. You need to use Load() or SampleLevel() in everything else.

1 Like

Oh hey, that fixed it!

Thanks a lot!

How exactly?? I am having the same issue now…