Search code examples
opengltexturesvulkan

Pass more than 4-channel data to OpenGL or Vulkan


I would like to pass the following values as a texture to the fragment shader:

  • Base R
  • Base G
  • Base B
  • Material switch (metal/dielectric)
  • Normal x
  • Normal y
  • Normal z
  • IOR (Only for dielectric)
  • Roughness

That is a lot of stuff. It looks like this would require three different textures in OpenGL. Questions:

  • Are there any extensions to OpenGL that makes it possible to pass this as one texture?
  • From what I have understood about Vulkan, GPU memory is more easily accessible. Does this mean that you can use generalized texture formats?

Solution

  • Even in Vulkan, you can not have more than a four channels for a texture. However, both in OpenGL and Vulkan, you could use a 32 bits by channels texture, and use something like packUnorm( https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/packUnorm.xhtml ). But it works only with integer texture and you will have to perform filtering by yourself

    Another way could be to use something like SSBO ou TBO. But I do not understand what the problem is by using 3 textures.