# OpenGL 4D textures with bilinear interpolation

I want to use and interpolated 4D texture in OpenGL, i.e. a texture that is accessed with a texture coordinate vector (s, t, p, q) and interpolated linearly in every texture coordinate.

The extension GL_SGIS_texture4D does exactly this. However, it is unsupported on literally every GPU I have access to.

If the was a GL_TEXTURE_3D_ARRAY, I guess I could sample the appropriate 2 layers of a 3D array texture with the (s, t, p) coordinates and then manually interpolate in the q coordinate. However, there are only "ordinary" GL_TEXTURE_2D_ARRAY texture arrays. A possible solution is to treat the texture array as 2D array of 2D texture, sample the appropriate 4 layers with (s, t) and then manually interpolate in p and q. This method is somewhat constrained by GL_MAX_ARRAY_TEXTURE_LAYERS​. I am also afraid of the relatively large number of 2D texture fetches required to fetch a single 4D texture value.

Is there a simpler way of achieving 4D interpolated textures?

• You mean s, t, p, q. I know this sounds pedantic, but GLSL does not let you mix-and-match swizzle component sets. w belongs to xyzw, t belongs to stpq and r belongs to rgba. Logically, these coordinates would normally be s, t, r, q, but GLSL uses p as a synonym for the 3rd component in texture coordinates. Otherwise, r would refer to the first component. – Andon M. Coleman May 25 '14 at 12:46
• @AndonM.Coleman Thanks, I edited my question accordingly. – Kristóf Marussy May 25 '14 at 14:56