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).
在这里插入图片描述

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

例子
在这里插入图片描述

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).

在这里插入图片描述

参考资料

【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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值