RED与RGBA在处理非纹理数据时的WebGL纹理存储方面的比较

huangapple go评论42阅读模式
英文:

RED vs RGBA for WebGL texture storage when dealing with non-texture data

问题

在处理非纹理数据时,使用RED还是RGBA用于WebGL纹理存储更好/更高效?更具体地说,当谈论“非纹理数据”时,我指的是不仅仅用于渲染的数据,而是从GPU中读取作为其他用途的信息。例如,可以使用1D纹理来存储房间中灯光的数组。我想知道在用于此目的时,是更倾向于使用RED还是整个RGBA纹理更有效。请注意,数据存储在比纹理使用的值更大的多个单元中,无论是int、byte还是float,所以我需要进行多个查询和一些位移操作来使一切就绪。

英文:

Is it preferred/more efficient to use RED or RGBA for WebGL texture storage when dealing with non-texture data. More specifically, when talking about "non-texture data" I mean data that isn't meant to just be rendered, but rather read from the GPU as information to use for something else. For instance a 1D texture could be used to store an array of the lights in a room. I was wondering whether or not it's preferred/more efficient to use RED or the whole RGBA texture when using textures for this purpose. (Please note that the data is stored within multiple units themselves, which are larger than the value used by the texture whether it be int, byte, or float, so I'll have to do multiple queries and some bitshifts to get things in place.)

答案1

得分: 1

纹理查询与其他着色器计算相比较昂贵。获取一个RGBA样本比获取四个单独的RED样本要快。如果您只需要一个单独的浮点数,那么从RED获取会比获取RGBA并提取所需值要快。听起来您对第一种情况感兴趣(1个RGBA与4个RED的比较)。

英文:

Texture queries are rather expensive compared to other shader calculations. It's faster to fetch one RGBA sample rather than four individual RED samples. The equation would change if you needed only a single float number -- then fetching from RED would be faster than fetching RGBA and extracting the intended value. From the sound of it you're interested in the 1st case (1 RGBA vs 4 REDs).

huangapple
  • 本文由 发表于 2023年7月17日 21:16:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76704871.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定