Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Texture arrays

  1. #1
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    883

    Texture arrays

    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:
    Code :
    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?

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: Texture arrays

    Try it out and tell us ;-) Was that not the motivation behing 3d textures?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: Texture arrays

    Originally posted by yooyo:

    Is it possible to implement this on current hardware and is it worth?
    It should be emulable using the cube or 3d textures as you suggested, if you have no problem with limitations of that emulation (texture size limits, possible wasting of memory, wraping mode limitations, possible performance hit). Whether it is worth depens on your application, you will need to test it.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: Texture arrays

    Originally posted by Zengar:
    Was that not the motivation behing 3d textures?
    The 3d textures and texture arrays are designed for somewhat different purposes.

    The 3d textures are designed to store a 3d function like the marble pattern or attenuation of the light. For such use it is important that there is some form of interpolation as you move between individual slices. In this case the filtering simultaneously operates on elements from several different slices.

    The texture arrays are meant as way to allow per pixel selection of one from several ordinary textures (e.g. one from several different shadowmaps). In this case the interpolation between slices is undesirable and the filtering is applied only to the slice that was selected by the third value.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: Texture arrays

    Wouldn't that simply work using uniform arrays?

    Code :
    uniform sampler2D t[2];
    ...
    vec4 diffuse = texture2DArray(t[0], texcoord.st);
    vec4 normal = texture2DArray(t[1], texcoord.st);
    If the hardware doesn't support a variable index into the array, the driver could transform the access into a branch (if (i == 0) use texture0, else if (i == 1) use texture1 ...).

    I don't see why we would need new hardware here, dynamic branching seems enough (even static branching, but that would of course be very slow...). Of course new hardware could increase performance of the texture array access, but at least it would work on old hardware.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •