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 6 of 6

Thread: GLSL fragment texturing with instancing

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    5

    GLSL fragment texturing with instancing

    In a nut shell: Is there a way to have a specific texture bound depending on what instance is currently processed?

    This idea can apply to many uses, for example a cube would only need to be uploaded once and to draw it multiple times you can use instancing and various methods to translate each cube. But my problem is that texturing each cube is a different beast. If the sampler2D has no constructor to let you choose the texture buffer of choice inside the shader, then it seems like you can only bind 1 texture for the entire instancing batch.

    I've thought about rendering the instances in batches according to what their texture should be, but what if object order is important which could apply to 2D rendering with textured quads.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,201
    You could do this with a texture array, letting the instance id (or some other per-instance attribute) specify which array slice to use.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    665
    http://www.opengl.org/registry/specs...ss_texture.txt might be what you're looking for.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    5
    wow yes that's great, thanks its working!

    I'm just curious, is this only available on Nvidia cards like GTX 680+ because I would like to make my application as compatible as possible.

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,211
    If pre-Kepler (pre-680) and/or cross-vendor compatibility is important, see mhagain's reply. This only requires an OpenGL 3.x capable card, and is cross-vendor.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    665
    The problem with array textures is that all the textures you put in one array have to match in size and format. That might not be very orthogonal to the input dataset.

Posting Permissions

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