Unity 场景在三维空间中表示游戏对象。由于观察者的屏幕是二维屏幕,Unity 需要捕捉视图并将其“平面化”以进行显示。它使用摄像机来实现这一点。在 Unity 中,您可以通过将一个 Camera 组件添加到游戏对象来创建摄像机。
摄像机所看到的内容由它的变换和 Camera 组件来定义。变换位置定义了视点,其向前的 (Z) 轴定义视图方向,向上的 (Y) 轴定义屏幕的顶端。Camera 组件的设置还定义了视图中区域的大小和形状。通过设置这些参数,摄像机能够显示其在当前屏幕上“观察”到的内容。当游戏对象移动和旋转时,显示的视图会随之移动和旋转。
现实世界中的摄像机(实际相当于人眼)在观察外界事物时,物体距离视点越远,看起来越小。这种众所周知的_透视_效果在艺术和计算机图形领域广泛应用,对于创建现实场景至关重要。当然,Unity 支持透视摄像机,有时需要专门在没有这种效果的条件下渲染视图。例如,需要创建一种与真实世界的对象不完全相同的地图或信息显示效果。显示的对象不随距离变远而缩小的摄像机称为正交摄像机;Unity 摄像机也有这样的选项。在透视和正交模式下观察场景称为摄像机投影。(上述场景来自于 BITGEM)
对于从当前位置能“观察”的最远距离方面,透视和正交摄像机都存在一定的限制。该限制由垂直于摄像机向前 (Z) 方向的平面定义。此平面称为远裁剪面,因为与摄像机距离较远的对象将被“裁剪”(即,不在渲染范围内)。摄像机附近还有一个相应的近裁剪面;可观察的距离范围位于这两个平面之间。
在非透视模式下,无论距离远近,对象大小不变。这表示,正交摄像机的视体由两个裁剪面之间的长方体定义。
使用透视摄像机时,对象会随其与摄像机的距离增大而缩小。这表示场景中可视部分的宽度和高度随着距离的增大而增大。因此,透视摄像机的视体不是一个长方体,而是金字塔形状,其顶点位于摄像机位置而底部位于远裁剪面。不过,该形状并不是严格的金字塔形,因为顶部被近裁剪面截断了;这种被截断的金字塔形状称为_视锥体。由于视锥体的高度并非常量,视锥体由其宽度与高度之比(称为_宽高比_)以及顶部与底部之间在顶点处的夹角(称为_视野_即 FOV_)定义。请参阅关于了解视锥体的页面,了解更多详细说明。
You can set what a camera does with the background you see in the empty areas between objects, before it renders the scene.
例如,您可以选择在背景上渲染场景之前采用纯色填充背景,或者绘制天空或远处的背景,甚至保留前一帧的内容。有关配置此设置的信息,请参阅 Camera Inspector 参考中的 Background 属性。有关绘制天空的信息,请参见天空。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.