Fastest way to deal with multiple textures in OpenGL?

Viewed 350

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.

1 Answers

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

Related