Learn OpenGL 笔记2.8 - Coordinate Systems

基础知识:

1.Coordinate Systems(坐标系)

顶点着色器,把坐标们转换为 normalized device coordinates (NDC) 标准化设备坐标,然后把这些坐标提供给rasterizer光栅化器,进行转换为屏幕上的 2D 坐标/像素。

  • Local space (or Object space)  本地空间(或对象空间)
  • World space 世界空间
  • View space (or Eye space) 视空间(或眼空间)
  • Clip space 剪辑空间
  • Screen space 屏幕空间

 2.The global picture

为了将坐标从一个空间转换到下一个坐标空间,我们将使用几个转换矩阵 

 

  1. Local coordinates are the coordinates of your object relative to its local origin; they're the coordinates your object begins in.本地坐标是对象相对于其本地原点的坐标;它们是您的对象开始的坐标。
  2. The next step is to transform the local coordinates to world-space coordinates which are coordinates in respect of a larger world. These coordinates are relative to some global origin of the world, together with many other objects also placed relative to this world's origin.下一步是将局部坐标转换为世界空间坐标,这是相对于更大世界的坐标。这些坐标与世界的某个全局原点有关,还有许多其他对象也相对于这个世界的原点放置。
  3. Next we transform the world coordinates to view-space coordinates in such a way that each coordinate is as seen from the camera or viewer's point of view.接下来,我们将世界坐标转换为视图空间坐标,这样每个坐标都是从相机或观察者的角度看到的。
  4. After the coordinates are in view space we want to project them to clip coordinates. Clip coordinates are processed to the -1.0 and 1.0 range and determine which vertices will end up on the screen. Projection to clip-space coordinates can add perspective if using perspective projection.在坐标进入视图空间后,我们希望将它们投影到剪辑坐标。剪辑坐标在 -1.0 和 1.0 范围内进行处理,并确定哪些顶点将出现在屏幕上。如果使用透视投影,投影到剪辑空间坐标可以添加透视。
  5. And lastly we transform the clip coordinates to screen coordinates in a process we call viewport transform that transforms the coordinates from -1.0 and 1.0 to the coordinate range defined by glViewport. The resulting coordinates are then sent to the rasterizer to turn them into fragments.最后,我们在一个称为视口变换的过程中将剪辑坐标转换为屏幕坐标,该过程将坐标从 -1.0 和 1.0 转换为由 glViewport 定义的坐标范围。然后将生成的坐标发送到光栅化器以将它们转换为片段。

 3.Local space

局部空间是对象的局部坐标空间.

4.World space

相机空间

5.Clip space

剪辑空间,一个三角形在裁剪体积之外 OpenGL 会将三角形重建为一个或多个三角形以适合裁剪范围内。

6.Orthographic projection

正交投影

7.Perspective projection

透视投影

顶点坐标离观察者越远, w 分量就越高。 一旦坐标被转换到裁剪空间,它们就在 -w 到 w 的范围内(这个范围之外的任何东西都会被裁剪)。

 注意矩阵乘法的顺序是颠倒的(记住我们需要从右到左读矩阵乘法)。 然后将生成的顶点分配给顶点着色器中的 gl_Position,然后 OpenGL 将自动执行透视分割和裁剪。

8.Right-handed system右手系统 

沿正 y 轴伸展右臂,手向上。
让你的拇指指向右边。
让你的食指朝上。
现在将中指向下弯曲 90 度。

9.Z-buffer (z 缓冲区)

 OpenGL 将其所有深度信息存储在 z 缓冲区中,也称为深度缓冲区。  深度存储在每个片段中(作为片段的 z 值),每当片段想要输出其颜色时,OpenGL 都会将其深度值与 z 缓冲区进行比较。 如果当前片段在另一个片段之后,则将其丢弃,否则将被覆盖。 这个过程称为深度测试,由 OpenGL 自动完成。

不开这个就会出现这种情况,因为先渲染的多边形总在前面:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值