variables - 在 WebGL 中,属性、统一变量和变化变量之间有什么区别?

标签 variables types matrix webgl

在比较这些不同类型时,我能想到一个类比吗?或者这些东西是如何工作的?

此外,统一矩阵是什么意思?

最佳答案

直接复制自http://www.lighthouse3d.com/tutorials/glsl-tutorial/data-types-and-variables/ 。实际网站有更详细的信息,值得查看。

Variable Qualifiers

Qualifiers give a special meaning to the variable. The following qualifiers are available:

  • const – The declaration is of a compile time constant.
  • attribute – Global variables that may change per vertex, that are passed from the OpenGL application to vertex shaders. This qualifier can only be used in vertex shaders. For the shader this is a read-only variable. See Attribute section.
  • uniform – Global variables that may change per primitive [...], that are passed from the OpenGL application to the shaders. This qualifier can be used in both vertex and fragment shaders. For the shaders this is a read-only variable. See Uniform section.
  • varying – used for interpolated data between a vertex shader and a fragment shader. Available for writing in the vertex shader, and read-only in a fragment shader. See Varying section.

打个比方,const和uniform就像C/C++中的全局变量,一个是常量,一个是可以设置的。属性是伴随顶点的变量,如颜色或纹理坐标。不同的变量可以由顶点着色器更改,但不能由片段着色器更改,因此本质上它们是在管道中传递信息。

关于variables - 在 WebGL 中,属性、统一变量和变化变量之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17537879/

相关文章:

bash - Bash 中的动态变量名称

c++ - Opencl:确定最佳的 local_item_size

R:是否有一种简单有效的方法来取回 block 对角矩阵的构建 block 矩阵列表?

opencv - 在opencv中快速转置3D矩阵

haskell - Haskell 中的 () 到底是什么?

python - 从模块获取单个变量和单个函数而不执行模块?

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP

php - 用换行符分解字符串

types - 如何使用 Js.Dict.t 类型为 Js.Dict.get

python - Django - 异常类型 : NoReverseMatch