WebGL 顶点着色器属性的有效类型是什么?
What are the valid types for a WebGL vertex shader attribute?
以下属性似乎没问题:
attribute vec4 coord;
以下属性抱怨属性 "cannot be bool or int":
attribute int ty;
以下属性抱怨 "syntax error":
attribute uint ty;
这些结果似乎很武断。我找不到顶点着色器属性的有效类型列表。 属性类型在WebGL中是否有效的规则是什么?
OpenGL ES Shading Language 1.00 specification, page 36, section 4.3.3: "Attribute":
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.
以下属性似乎没问题:
attribute vec4 coord;
以下属性抱怨属性 "cannot be bool or int":
attribute int ty;
以下属性抱怨 "syntax error":
attribute uint ty;
这些结果似乎很武断。我找不到顶点着色器属性的有效类型列表。 属性类型在WebGL中是否有效的规则是什么?
OpenGL ES Shading Language 1.00 specification, page 36, section 4.3.3: "Attribute":
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. Theattribute
qualifier can be used only with the data typesfloat
,vec2
,vec3
,vec4
,mat2
,mat3
, andmat4
. Attribute variables cannot be declared as arrays or structures.