Metal中的一些概念

坐标

1. Normalized device coordinate system

Vertex functions must provide position data in clip-space coordinates, which are 3D points specified using a four-dimensional homogenous vector (x,y,z,w). The rasterization stage takes the output position and divides the x,y, and z coordinates by w to generate a 3D point in normalized device coordinates. Normalized device coordinates are independent of viewport size.

顶点函数(Vertex functions)必须提供clip-space coordinates中的位置数据,这些数据是使用四维齐次向量four-dimensional homogenous vector (x,y,z,w)指定的3D点。光栅化阶段(rasterization stage)获取输出位置,并将x,y和z坐标除以w,以在**归一化设备坐标(Normalized device coordinates)**中生成3D点。 规范化的设备坐标与视口大小无关。

Figure 2 Normalized device coordinate system

Normalized device coordinates use a left-handed coordinate system and map to positions in the viewport. Primitives are clipped to a box in this coordinate system and then rasterized. The lower-left corner of the clipping box is at an (x,y) coordinate of (-1.0,-1.0) and the upper-right corner is at (1.0,1.0). Positive-z values point away from the camera (into the screen.) The visible portion of the z coordinate is between 0.0 (the near clipping plane) and 1.0 (the far clipping plane).
Metal中的一些概念_第1张图片

规范化的设备坐标使用左手坐标系,并将其映射到视口中的位置。 在图元坐标系中将图元裁剪到一个框,然后进行栅格化。

例子
Metal中的一些概念_第2张图片

2. texture coordinates

纹理坐标映射:将纹理图像上的位置映射到几何表面上的浮点位置。

For 2D textures, normalized texture coordinates are values from 0.0 to 1.0 in both x and y directions. A value of (0.0, 0.0) specifies the texel at the first byte of the texture data (the top-left corner of the image). A value of (1.0, 1.0) specifies the texel at the last byte of the texture data (the bottom-right corner of the image).

Metal中的一些概念_第3张图片

参考资料

【1】Using a Render Pipeline to Render Primitives. https://developer.apple.com/documentation/metal/using_a_render_pipeline_to_render_primitives?language=objc

【2】Creating and Sampling Textures. https://developer.apple.com/documentation/metal/creating_and_sampling_textures?language=objc

你可能感兴趣的:(Metal)