上QQ阅读APP看书,第一时间看更新
Vertex Attributes
We will start by defining two attributes in the vertex shader. Every vertex will have the following code:
in vec3 aVertexPosition;
in vec3 aVertexNormal;
Attributes
Remember that attributes are only available to use inside the vertex shader.
Remember that attributes are only available to use inside the vertex shader.
If you're curious as to why in is used instead of the attribute qualifier, we will cover this shortly. Right after the in keyword, we find the type of the variable. In this case, it is vec3, as each vertex position is determined by three elements (x, y, z). Similarly, the normals are also determined by three elements (x, y, z). Please note that a position is a point in three-dimensional space that tells us where the vertex is, while a normal is a vector that gives us information about the orientation of the surface that passes along that vertex.