Camera Tricks 相机技巧 相机系列4

本文详细介绍了Unity中相机的工作原理,包括视图平截头体的理解、Dolly Zoom视觉效果的实现,以及如何通过相机射线进行交互。通过调整相机的视场角、裁剪平面以及使用Raycasting技术,可以创造出各种增强游戏体验的视觉效果。
摘要由CSDN通过智能技术生成

Camera Tricks 相机技巧

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.2版本
参考链接:https://docs.unity3d.com/Manual/CameraTricks.html

It is useful to understand how the camera works when designing certain visual effects or interactions with objects in the scene. This section explains the nature of the camera’s view and how it can be used to enhance gameplay.
在设计特定的视觉效果或与场景中的对象交互时,理解相机如何工作是很有用的。本节将解释相机视图的性质以及如何使用它来增强游戏玩法。

Understanding the View Frustum 理解视图平截头体

The word frustum refers to a solid shape that looks like a pyramid with the top cut off parallel to the base. This is the shape of the region that can be seen and rendered by a perspective camera. The following thought experiment should help to explain why this is the case.
frustum这个词指的是一个看起来像金字塔的立体形状,顶面与底面平行。通过一个透视相机可以看到渲染的区域形状。下面的思考实验应该有助于解释为什么会这样。

Imagine holding a straight rod (a broom handle or a pencil, for example) end-on to a camera and then taking a picture. If the rod were held in the centre of the picture, perpendicular to the camera lens, then only its end would be visible as a circle on the picture; all other parts of it would be obscured. If you moved it upward, the lower side would start to become visible but you could hide it again by angling the rod upward. If you continued moving the rod up and angling it further upward, the circular end would eventually reach the top edge of the picture. At this point, any object above the line traced by the rod in world space would not be visible on the picture.
想象一下,把一根笔直的杆子(比如扫帚柄或铅笔)一端放到相机镜头前,然后拍照。如果杆子在照片的中心,垂直于相机镜头,那么只有它的末端才能在照片上看到一个圆;它的其他部分将被掩盖。如果你向上移动它,下面的部分就会开始变得可见,但是你可以通过向上倾斜杆来隐藏它。如果你继续向上移动棒,并使它进一步向上倾斜,圆的结束将最终达到图片的顶部边缘。基于这一点上,任何物体在世界空间的杆子跟踪线以上将在图片上不可见。
在这里插入图片描述

The rod could just as easily be moved and rotated left, right, or down or any combination of horizontal and vertical. The angle of the “hidden” rod simply depends on its distance from the centre of the screen in both axes.
杆可以很容易地移动和左,右,或向下旋转或任何水平和垂直的组合。“隐藏”杆的角度取决于它与屏幕中心在坐标系下的距离。

The meaning of this thought experiment is that any point in a camera’s image actually corresponds to a line in world space and only a single point along that line is visible in the image. Everything behind that position on the line is obscured.
这个思考实验的意义在于,相机图像中的任何一点实际上都对应于世界空间中的一条直线,而这条直线上只有一个点在图像中可见。线上那个位置后面的一切都被覆盖了。

The outer edges of the image are defined by the diverging lines that correspond to the corners of the image. If those lines were traced backwards towards the camera, they would all eventually converge at a single point. In Unity, this point is located exactly at the camera’s transform position and is known as the centre of perspective. The angle subtended by the lines converging from the top and bottom centres of the screen at the centre of perspective is called the field of view (often abbreviated to FOV).
图像的外边缘由图像的每个角相对应的发射线定义。如果这些线被回溯到相机上,它们最终都会聚在一个点上。在Unity中,落点恰好位于相机变换的位置,被称为透视中心。由从屏幕顶部和底部的边中心汇聚到透视中心的线构成的夹角称为视场角(通常缩写为FOV)。

As stated above, anything that falls outside the diverging lines at the edges of the image will not be visible to the camera, but there are also two other restrictions on what it will render. The near and far clipping planes are parallel to the camera’s XY plane and each set at a certain distance along its centre line. Anything closer to the camera than the near clipping plane and anything farther away than the far clipping plane will not be rendered.
如上所述,任何落在图像边缘发射线之外的东西都不会被摄像机看到,但是对于它呈现的内容还有另外两个限制。近、远裁剪平面平行于相机的XY平面,每一个裁剪平面沿其中心线设置一定的距离。任何比近裁切面更靠近和远裁切面更远离的物体都不会被渲染。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值