2
$\begingroup$

Currently I have textures which need GL_NEAREST and some other need GL_LINEAR in the same texture2dArray. In the shader I perform a manual GL_NEAREST lookup via textureFetch().

To avoid this my question is, is it possible to set the value of GL_TEXTURE_MIN/MAG_FILTER for each texture in a texture array to different values?

I know of the same size restrictions, but could not find anything regarding mipmapping.

$\endgroup$

1 Answer 1

3
$\begingroup$

Array textures do not contain textures; they are a single texture that contains a number of images, with each image being of the same size, format, mipmap depth, etc.

As such, the sampling parameters that are part of the texture apply to sample fetches for all images within the texture.

That having been said:

In the shader I perform a manual GL_NEAREST lookup via textureFetch().

This means your FS knows when to look the texture up with linear filtering and when not to. As such, you could have two different array texture samplers in the shader, one of which you expect to use linear sampling and one which uses nearest.

Both of these samplers can be using the same texture object, just paired with a different sampler object (which contains all of the filtering parameters for the texture). One sampler would use nearest filtering, the other would use linear.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.