2

For each type of texture (ambient, diffuse, specular, etc) assimp will return a list of textures. How do we deal with that many textures?

It seems that the number of texture binds for every model may increase drastically. It would be interesting if we were able to convert every list of a texture type into just a single texture array or map, is that possible?

Just so you can visualize, in my code I have this Material class:

class Material {
     private:
        Shader* shader;

        Texture* diffuseMap;
        Texture* specularMap;
        Texture* emissiveMap;
        
        float shineness;
    public:
        [...]
};

So I am trying to convert a list of textures into a single map corresponding to its type.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Ariel
  • 21
  • 4
  • Putting multiple texture is one is called a "Texture Atlas". Note, that you have to adjust the uv coordinates and you might have to handle clamping/repeating yourself. – BDL Feb 27 '21 at 11:49
  • I see, thank you. Gonna search about this, do you have any good source or suggestion to where I can go look for it? – Ariel Feb 27 '21 at 12:28
  • The only reference I remember is a [whitepaper from NVIDIA](http://download.nvidia.com/developer/NVTextureSuite/Atlas_Tools/Texture_Atlas_Whitepaper.pdf). There is also a [talk from SIGGRAPH 2014](https://mrelusive.com/publications/presentations/2012_siggraph/Virtual_Texturing_in_Software_and_Hardware_final.pdf) although it is about a more sophisticated method than just pasting images together. – BDL Feb 27 '21 at 12:54
  • Thanks! I gave a quick reading on the NVIDIA paper and it looks like what I am looking for. I will see if I can understand and try to implement it. Hopefully I will get it to work and then I will come back here to update the post. – Ariel Feb 27 '21 at 16:45

1 Answers1

3

Texture Atlases (mentioned by @BDL in a comment) are one option. Another would be texture arrays, which exist for 1D and 2D textures, but – depending on your circumstances – have the drawback of forcing the same format upon all images.

The ultima ratio would be bindless textures, where you just pass a 64 bit ID for the texture to the shader without binding it to a texture unit at all: https://www.khronos.org/opengl/wiki/Bindless_Texture

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Mm, you mean that bindless textures provide more performance than the other 2 approaches? It seems that it is only supported on nvidia cards right? Also looks a bit complicated lol. Texture Atlases seem to me a easier way to go. And thank you for your time! – Ariel Feb 27 '21 at 16:54
  • @Ariel: Bindless textures are supported through an ARB extension which is cross plattform. As far as performance goes: It depends. With well scheduled texture binding one can easily outperform badly bindless access pattern. But in the general case, bindless carries a lot less overhead and thus has the potential to yield the best performance. – datenwolf Feb 27 '21 at 21:13