I know this is old theme, but today I’ve got another one problem with arrays)))
So far I’ve used UNITY_SAMPLE_TEX2DARRAY_GRAD(_LandArr, uvForLanArr, ddx(localPos.xy), ddy(localPos.xy)) for my textures and UNITY_SAMPLE_TEX2DARRAY_LOD(_MaskArr, uvForMask, 0).r for B&W masks. Both of these strings are located near. Recently I’m discovered that if I delete second string (with UNITY_SAMPLE_TEX2DARRAY_LOD) then my first string stop works. It gives last one-colored LOD instead full texture as before.
float4 tex = UNITY_SAMPLE_TEX2DARRAY_GRAD(_LandArr, uvForLanArr, ddx(localPos.xy), ddy(localPos.xy));
UNITY_SAMPLE_TEX2DARRAY_LOD(_MaskArr, uvForMask, 0); //even without saving to variable!!!1111
//even if this string will be higher than previous...
o.Albedo = tex.rgb;
it works
float4 tex = UNITY_SAMPLE_TEX2DARRAY_GRAD(_LandArr, uvForLanArr, ddx(localPos.xy), ddy(localPos.xy));
o.Albedo = tex.rgb;
It not works…
How it possible?)) Can’t understand…(((
Can it depends of something in this initialization:
#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)
#define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) tex.SampleGrad (sampler##tex,coord,dx,dy)
#else
#if defined(UNITY_COMPILER_HLSL2GLSL) || defined(SHADER_TARGET_SURFACE_ANALYSIS)
#define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) float4(1,1,1,1)//tex2DArray(tex,coord,dx,dy)
#endif
#endif
UNITY_DECLARE_TEX2DARRAY(_LandArr);
UNITY_DECLARE_TEX2DARRAY(_MaskArr);