WebGL 中的最大纹理数? [英] Max number of textures in WebGL?

查看:98
本文介绍了WebGL 中的最大纹理数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在 WebGL 中有 8 个纹理的限制.

I know that there is a limit of 8 textures in WebGL.

我的问题是,8 是全局限制还是每个着色器/程序明智的限制?

My question is that, is 8 the limit globally, or per shader/program wise?

如果它是每个着色器/程序明智的限制,这是否意味着,一旦我将纹理加载到一个着色器的制服中,我就可以开始将这些插槽重用于其他着色器?假设我将 TEXTURE0 用于一种形状,我可以在另一种形状中使用 TEXTURE0 吗?

If it's per shader/program wise limit, does that mean, once I load the textures to uniforms of one shader, I can start reusing these slots for other shaders? Say I used TEXTURE0 for one shape, can I use TEXTURE0 in another shape?

推荐答案

限制是每次绘制调用.当您进行一次绘制调用并调用特定的着色器程序时,您会受到限制的约束,但您的下一次绘制调用可以在同一动画帧中使用完全不同的纹理.

The limit is per draw call. When you make a draw call, and invoke a particular shader program, you are constrained by the limit, but your next draw call can use completely different textures in the same animation frame.

此外,8 只是最低保证.系统需要支持至少八个才能被视为符合 WebGL.但更好的显卡支持超过八个.您可以像这样查询您所在平台的最大图像纹理数:

Also, 8 is just the minimum guarantee. Systems are required to support at least eight to be considered WebGL conformant. But nicer graphics cards support more than eight. You can query the max number of image textures for the platform you're on like this:

var maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);

您还可以查找顶点纹理:

You can also look for vertex textures:

gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)

或者两者结合:

gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)

您还可以使用像 WebGL 报告(免责声明,我是贡献者)之类的网站来查找此内容您所在平台的统计信息(在 Fragment Shader -> Max Texture Units 下).

You can also use a site like WebGL Report (Disclaimer, I'm a contributor) to look up this stat for the platform you're on (under Fragment Shader -> Max Texture Units).

当第一次写这个答案时,还有另一个有用的网站叫做WebGL Stats".这将显示各种浏览器中 WebGL 支持的聚合数据.可悲的是,该网站几年前在没有任何警告的情况下消失了.但即使在那时,大多数设备也至少支持 16 种纹理.

这篇关于WebGL 中的最大纹理数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆