目录索引
译文
在我们正式开始实现光照之前,我们需要先理解什么是“向量”,并了解它是如何应用在计算机图形学中的。
向量本身必须被视为一条线或一个箭头,具有大小和方向。
![图片[1]-《Unity着色器圣经》5.0.2 | 向量-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-78-1024x398.jpeg)
上图中的网格系统是用来测量向量大小的,这些值可以表示标量或向量的大小。标量值对应的是单个值,即单位值类型的数字,例如 [n] 公斤、[n] 小时、[n] 度等,作为变量的“n”代表一个给定的标量,是一个特定单位的唯一值。另一方面,向量大小除了单位值之外,还需要一个方向和空间位置,例如:[n] km/h 速度朝北、[n] N 力向下等等。
因为向量具有方向性,所以我们可以知道向量有起点和终点两个概念,并且这两点也包含在三维坐标系中。
模型的法线也是向量,因为法线具有长度(在大多数情况下等于 1)和可以在三维空间中测量的方向。同样,切线和副切线也是向量,它们具有与法线相似的性质。
![图片[2]-《Unity着色器圣经》5.0.2 | 向量-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-77-1024x399.jpeg)
顶点是一个标量值,因为它们代表几何中的点。现在,如果我们尝试计算模型中心与某个顶点之间的距离,我们就会得到一个向量大小,因为根据定义我们的单位值现在在空间中有了方向和位置。
![图片[3]-《Unity着色器圣经》5.0.2 | 向量-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-76-1024x359.jpeg)
在计算机图形学中,标量表示为一维变量(如 float、half、fixed),而向量表示为多维变量(如 float2、float3 等)。
原文对照
Before we start implementing lighting in our programs, we must first understand what a vector is and how it works in Computer Graphics.
A vector itself must be seen as a line or an arrow, possessing a magnitude and a direction.
![图片[1]-《Unity着色器圣经》5.0.2 | 向量-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-78-1024x398.jpeg)
In the example above, a grid has been used as a measurement system to determine the vector magnitude. These values can be measured in both scalar and vector magnitudes. Scalar magnitudes correspond to a single value; to a unit-value type number, e.g., [n] kilos, [n] hours, [n] degrees, etc. In this case, “n”, which is a variable, represents a given scalar magnitude containing a unique value of a specific unit. On the other hand, vector magnitudes; in addition to the unit-value, need a direction and a position in space, e.g., [n] km/h north, [n] N force down, etc.
Because vector magnitudes have direction, we can conclude that they have a starting point and an endpoint, and are also included within a three-dimensional coordinate system.
The normals of an object are vector magnitudes, why? Because they have a length (which equals one in most cases) and a direction in space that is measured in three dimensions. Likewise, tangents and binormals because they have similar properties to a normal.
![图片[2]-《Unity着色器圣经》5.0.2 | 向量-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-77-1024x399.jpeg)
Vertices, on the other hand, are scalar magnitudes since they represent points of intersection in geometry. Now, if we try to calculate the distance between the center of the object and the position of a vertex, we will obtain a vector magnitude, since, by definition, our unitvalue would now have a direction and a position in space.
![图片[3]-《Unity着色器圣经》5.0.2 | 向量-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/image-76-1024x359.jpeg)
In computer graphics scalar magnitudes are represented as one-dimensional variables (e.g. float, half, fixed), while vector magnitudes are represented as variables of more than one dimension (e.g. float2, float3, etc.).
暂无评论内容