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:
Shader error in ‘Unlit/DisplacementEnv’: cannot map expression to ds_5_0 instruction set at line 136 (on d3d11)
Compiling Domain program
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP
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.
bgolus
August 6, 2017, 12:59am
2
I believe it uses Sample() which is only supported in pixel shaders. You need to use Load() or SampleLevel() in everything else.
1 Like
JonathanPearl:
Oh hey, that fixed it!
Thanks a lot!
How exactly?? I am having the same issue now…