什么是“uniform samplerXX iChannel0..3"?在这个着色器中? [英] What is "uniform samplerXX iChannel0..3" in this shader?

查看:17
本文介绍了什么是“uniform samplerXX iChannel0..3"?在这个着色器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰巧在着色器玩具上看到了这个着色器.

I happened to see this shader on shader toy.

https://www.shadertoy.com/view/ldf3W8

我想知道什么:

uniform samplerXX iChannel0..3; 

是吗?

我试图查看顶点着色器,但我没有找到任何东西.

I tried to look at the vertex shader, but I don't find any thing there.

另外,如何将音频波转换为纹理?(这里正在做)

Also how can I convert audio waves to a texture? (which is being done here)

推荐答案

我想知道iChannel0..3统一samplerXX是什么;是吗?

I wanted to know what uniform samplerXX iChannel0..3; is?

uniforms 是外部设置的变量,在图元绘制期间调用着色器具有相同的值(为图元组成的每个顶点调用一个顶点着色器,为每个绘制的片段(大致转换为像素)调用片段着色器到原语).

uniforms are externally set variables that have the same value for invocations of the shader during a primitive draw (a vertex shader gets called for each vertex a primitive consists of, fragment shaders for each fragment (which is roughly translates to pixels) drawn to by the primitive).

采样器是 OpenGL 将纹理单元绑定到着色器的方式.在实际的 OpenGL 程序中,您使用 glGenTexturesglActiveTextureglBindTextureglTexImage(以及一堆其他函数,但那些是重要的)并将使用 glActiveTexture 选择的纹理单元绑定到采样器制服.

samplers are OpenGL's way of binding texture units to a shader. In the actual OpenGL program you're loading the texture using glGenTextures, glActiveTexture, glBindTexture, glTexImage (and a bunch of other functions, but those are the important ones) and bind the texture unit selected with glActiveTexture to a sampler uniform.

还有如何将音频波转换为纹理?

Also how can I convert audio waves to a texture?

纹理只是插值查找表.您可以将任何您喜欢的数据放在 LUT 中.大多数情况下,纹理用于图像数据,但您也可以将 PCM 样本放入其中.因此,您只需从音频 API 获取 PCM 数据并将其作为数据传递到纹理中.

Textures are just interpolated lookup tables. You can place any data you like in a LUT. Most of the time a texture is used for image data, but you can loac PCM samples into it just as well. So you simply fetch PCM data from the audio API and pass it into a texture as data.

这篇关于什么是“uniform samplerXX iChannel0..3"?在这个着色器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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