1.0.1 | 多邊形物體的屬性

目錄索引

本系列與知乎同名翻譯同步更新,原文鏈接:https://zhuanlan.zhihu.com/p/645883222
如有任何翻譯錯誤,歡迎在評論區(qū)踹我:)!
原文對照
Years ago, when I was just starting my studies about shaders in Unity, it was challenging to understand much of the content I found in the books for several factors. I still remember that day of studies, wishing to understand the operation of the semantics POSITION[n]; however, when I managed to find its definition, I found the following statement:
Vertex position in object-space.
At that moment, I asked myself, what is the vertex position in object-space? Then I understood that there was previous information that I had to know before starting to read about this subject.
In my experience, I have been able to identify at least four fundamental areas that facilitate the understanding of shaders and their structure, such as properties of a polygonal object, the structure of a render pipeline, matrices, and coordinate systems.
1.0.1 | Properties of a polygonal object.
The word polygon comes from Greek and is composed of poly (many) and gnow (angles). By definition, a polygon refers to a closed plane figure bounded by line segments.

A?primitive?is a three-dimensional geometric object formed by polygons and is used as a predefined object in different development software. Within Unity, Maya or Blender, we can find other primitives. The most common are: Spheres, Boxes, Quads, Cylinders and Capsules. These objects are different in shape but have similar properties; all have vertices, tangents, normals, UV coordinates and color, which are stored within a data type called “mesh”.
We can access all these properties independently within a shader and keep them in vectors (e.g. float4 pos: POSITION [n]). It is beneficial because we can modify their values and thus generate exciting effects. To understand this concept much better, we will give a small definition of the properties of a polygonal object.


譯文
許多年前,當(dāng)我剛開始學(xué)習(xí) Unity 中的著色器時,有幾個原因?qū)е挛译y以理解書本上的內(nèi)容。我仍然記得有一天,我希望理解語義 POSITION[n] 的操作,但關(guān)于它的介紹只有短短一句:
物體空間中的頂點位置。
什么是物體空間中的頂點位置?這時我意識到,在開始學(xué)習(xí)之旅前我必須先了解一些基礎(chǔ)知識。
根據(jù)我的經(jīng)驗,至少有四個基本方面有助于理解著色器及其結(jié)構(gòu),如多邊形物體的屬性、渲染管線的結(jié)構(gòu)、矩陣以及坐標(biāo)系。
1.0.1 | 多邊形物體的屬性
多邊形(polygon)一詞來自希臘語,由“多”(poly)和“角”(gnow)組成。根據(jù)定義,多邊形是指平面的封閉幾何圖形,由大于2條線段組成,且首尾相連劃出的形狀。

基本體(primitive)是由多邊形構(gòu)成的三維幾何對象,在諸如Unity、Maya、Blender等不同的開發(fā)軟件中用作預(yù)定義對象。最常見的基本體有球體、正方體、四邊形、圓柱體和膠囊體等。這些物體雖然形狀各異,但屬性相似:它們都有頂點、切線、法線、UV 坐標(biāo)和顏色,這些屬性被存儲在一種名為 "網(wǎng)格(mesh)"的數(shù)據(jù)類型中。
我們可以在著色器中獨立訪問所有這些屬性,并將它們保存在向量中(例如 float4 pos: POSITION [n])。這樣做的好處是我們可以修改它們的值,從而編寫出令人興奮的效果。為了更好地理解這一概念,我們將給出關(guān)于多邊形物體屬性的定義。
