简体   繁体   English

在 OpenGL 中处理多个纹理的最快方法?

[英]Fastest way to deal with multiple textures in OpenGL?

For each type of texture (ambient, diffuse, specular, etc) assimp will return a list of textures.对于每种类型的纹理(环境、漫反射、镜面反射等),assimp 将返回一个纹理列表。 How do we deal with that many textures?我们如何处理这么多纹理?

It seems that the number of texture binds for every model may increase drastically.似乎每个 model 的纹理绑定数量可能会急剧增加。 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?如果我们能够将纹理类型的每个列表转换为单个纹理数组或 map 会很有趣,这可能吗?

Just so you can visualize, in my code I have this Material class:只是为了让你可以想象,在我的代码中我有这个材料 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.所以我试图将纹理列表转换为与其类型相对应的单个 map。

Texture Atlases (mentioned by @BDL in a comment) are one option.纹理图集(@BDL 在评论中提到)是一种选择。 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.另一个是纹理 arrays,它适用于 1D 和 2D 纹理,但是 - 根据您的情况 - 具有强制所有图像使用相同格式的缺点。

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 ultima ratio 将是无绑定纹理,您只需将纹理的 64 位 ID 传递给着色器而不将其绑定到纹理单元: https://www.khronos.org/opengl/wiki/Bindless_Texture

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM