New DX10 spec introduce arrays of textures or render targets or any other resource. Of course new GPU ie require for all this features, but what to do with older GPU’s? Is it possible to make some kind of texure arrays on (I hate to say this) DX9 or DX8 hardware?
My idea is limited only on 2D texture arrays.
We can use cube maps which allows to use up to 6 textures on one texture slot, or using stack of 2D textures in one single 3D texture.
Cube maps have 6 textures (+x, +y, +z, -x, -y, -z). Application can bound diffuse texture to +x, normalmap +y, glossmap +z, … and access from shader:
sampler2DArray t;
...
vec4 diffuse = texture2DArray(t[0], texcoord.st);
vec4 normal = texture2DArray(t[1], texcoord.st);
texture2DArray(t[0], texcoord.st) call can be implemented as textureCube(t, vec3(1.0, texcoord.s, texcoord.t))
texture2DArray(t[1], texcoord.st) call can be implemented as textureCube(t, vec3(texcoord.s, 1.0, texcoord.t))
3D texture implementation can be a bit easier than cube texture. We only need nearest filtering along z (or r) texture axis and using unnormalized texture z (or r) coordinate.
texture2DArray(t[0], texcoord.st) call can be implemented as texture3D(t, vec3(texcoord.s, texcoord.t, 0.0))
texture2DArray(t[2], texcoord.st) call can be implemented as texture3D(t, vec3(texcoord.s, texcoord.t, 2.0))
Is it possible to implement this on current hardware and is it worth?