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

Thread: Several Textures applied to 1 Vertex Buffer Object

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    15

    Several Textures applied to 1 Vertex Buffer Object

    Hello, I have a fairly simple question.

    I'm trying to figure out whether or not I can use several different texture objects on different faces within a vertex buffer object.
    I want to make a 3D-Modeling program, and I need to decide the most flexible and best way of creating geometry. So I figured I have two reasonable options:

    1. Pack all of the vertices under one vertex buffer object (along with corresponding indices/normals) to render the whole model.
    2. Use several vertex buffer objects (all triangles) that combine to form the model. (This is not a Triangle Strip)

    I do know that it is possible to put all of the desired textures into a texture atlas, and specify texture coordinates accordingly. However, I wanted to know if it was possible to have many texture objects, each applying to different triangles, or being reused.

    Thanks in advance, Nick.

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    Hello,

    you can use multiple textures on one object. For this you have two options:
    A) store the texture-unit to use per vertex as an additional user defined attribute and use this to select the texture to sample from in the fragment shader (you will be limited by the total number of textures == #of texture units)
    B) render the VBO with multiple draw calls and switch the texture units in between. the same idea as you might had when describing your multiple VBO approach, but you can use one buffer and only draw some parts of it.

    If all textures have the same dimensions, you could also use texture arrays.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    15
    Quote Originally Posted by menzel View Post
    A) store the texture-unit to use per vertex as an additional user defined attribute and use this to select the texture to sample from in the fragment shader (you will be limited by the total number of textures == #of texture units)
    Please correct me if I'm wrong. Does this mean that I should use an array as an attribute to send to the fragment shader that contains values that describe which texture to use?

    The array would have as many elements as there are vertices, each specifying a different active texture to use.

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    It's an additional array with one value per vertex, you would have to sent this information from the vertex shader to the fragment shader and bind all possible textures at the same time. That may be a lot of extra data for switching between 16 textures but its possible. (this technique might become more interesting if nearly each triangle has a different texture and you can bind thousands of textures (e.g. bindless textures) but that's not very relevant right now).
    Note: you can't set the sampler as a vertex attribute, so you will have to make sure you bound the correct samplers!

Tags for this Thread

Posting Permissions

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