WebGL顶点着色器属性的有效类型是什么? [英] What are the valid types for a WebGL vertex shader attribute?

查看:217
本文介绍了WebGL顶点着色器属性的有效类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下属性似乎不错:

attribute vec4 coord;

以下属性抱怨属性不能为布尔值或整数":

The following attribute complains that an attribute "cannot be bool or int":

attribute int ty;

以下属性抱怨语法错误":

The following attribute complains of a "syntax error":

attribute uint ty;

这些结果似乎很武断.我找不到顶点着色器属性的有效类型列表. 在WebGL中属性类型是否有效的规则是什么?

These results seem quite arbitrary. I can't find a list of the valid types for vertex shader attributes. What are the rules for whether an attribute type is valid in WebGL?

推荐答案

OpenGL ES阴影语言1.00规范,第36页,第4.3.3节:属性" :

attribute限定符用于声明从每个顶点从OpenGL ES传递到顶点着色器的变量.在除顶点着色器之外的任何类型的着色器中声明属性变量是错误的.就顶点着色器而言,属性变量是只读的.属性变量的值通过OpenGL ES顶点API或作为顶点数组的一部分传递到顶点着色器.它们将顶点属性传达给顶点着色器,并且期望在每次运行顶点着色器时都会发生变化. attribute限定符只能与数据类型floatvec2vec3vec4mat2mat3mat4 一起使用.属性变量不能声明为数组或结构.

The attribute qualifier is used to declare variables that are passed to a vertex shader from OpenGL ES on a per-vertex basis. It is an error to declare an attribute variable in any type of shader other than a vertex shader. Attribute variables are read-only as far as the vertex shader is concerned. Values for attribute variables are passed to a vertex shader through the OpenGL ES vertex API or as part of a vertex array. They convey vertex attributes to the vertex shader and are expected to change on every vertex shader run. The attribute qualifier can be used only with the data types float, vec2, vec3, vec4, mat2, mat3, and mat4. Attribute variables cannot be declared as arrays or structures.

这篇关于WebGL顶点着色器属性的有效类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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