分享

在Unity游戏引擎中创建平行的立体相对实现被动立体(转)

 勤奋不止 2018-03-27
 In the following I will outline one way of creating stereo pairs within the Unity game engine. Since Unity does not support quad buffer stereo (also known as frame sequential stereo) the approach here is suited to dual projector stereoscopic projection, most commonly this would be a polaroid or Infitec based stereoscopic systems. The technique outlined below involves parallel cameras (as opposed to toe-in) and as such creates optimal stereo pairs without vertical parallax.

在这篇文章中我将概要的描述在unity游戏引擎中创建立体相对的方法。尽管Unity不支持四重缓冲立体(也叫帧序列立体),这里的方法适用于双投影仪立体投影,大多数情况下这是基于偏振或者光谱立体的立体系统。下面描述的方法包括平行相机(而不是前倾的),用这种方法创建没有垂直视差的最优立体相对。

The reader is assumed to be moderately familiar with Unity3D, screen shots are provided along with each step discussed. The reader is also assumed to be familiar with the basic theory required to generate "easy on the eye" stereoscopic pairs, this includes the relationship between eye separation and the distance to zero parallax. The method here requires render to texture and as such Unity-Pro is required. The example adds stereoscopic support to the demo environment that ships with Unity.


The first step is to create two cameras, one for each eye. In the following, one of the cameras of the standard first person controller is duplicated. Each camera is offset horizontally about the central position of the original camera (in this case by +-0.03 units). Two render textures are created and the cameras set to render to each one. The stereo projection system is XGA (1024x768) so 1K render textures are adequate. An open question is what eye/camera separation to use. For strictly correct stereoscopic projection a knowledge of the viewing screen is required, for this more casual setup one commonly used strategy is to choose a zero parallax distance that is equal to the distance of the camera to the groundThe eye separation then is typically (a common standard) 1/30 of this zero parallax distance. In order to give the most realistic sense of depth the field of view of the two game controller cameras should be close to the field of view of the players eyes to the bounds of the real stereoscopic display.

第一步创建两个相机,每只眼睛一个。接下来,复制一个标准第一人称控制器(standard first person controller)的其中一个相机(里面本来就有一个相机)。每个相机相对于中心相机(指的是SFPC自带的那个相机)水平地偏移(这里是+-0.03单位)。创建两个渲染纹理,给每个相机绑定一个。由于立体投影系统是XGA(1024x768)的,所以1K的渲染纹理就足够了。有一个问题是,使用多大的视间距。严格来说,对于正确的立体投影必须知道正在看的屏幕;比较随意的一个做法通常是选择一个零视差距离,该距离和相机到地面的距离是相等的。然后视间距通常是零视差距离的1/30(通用标准)。为了实现最优真实感的深度,两个相机视野的夹角应该和玩家眼睛视野的夹角接近,和真正立体显示的范围接近

在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体
Click on any of the images for a larger version

 

The two render textures are applied to side by side square planes. These are both placed on a separate layer so they can be precluded from the first person controller cameras, and can have independent lighting applied. While not strictly necessary, a parallel light is also applied to the "stereo" layer, this provides additional control over brightness and even can apply colour (mood) effects.

把这两个渲染纹理放到并排的正方平面上,并把这两个渲染纹理放在一个单独的图层上,防止第一人称控制器对它们渲染,并且具有独立的光照。然而并非必要的是,可以给“立体”图层加一个一个平行光,这样就能对亮度进行额外的控制,甚至能使用颜色特效。
在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体

 

Finally an orthographic camera is positioned centered on the two render texture planes. It is set to cull all layers except the stereo layer. The zero parallax is controlled by trimming columns from the left of the left image and off the right of the right image, this is described here. This trimming is controlled by the "orthographic size". However, the relationship between the player window aspect ratio and the correct orthographic size (for a particular zero parallax distance) is somewhat convoluted due to some "magic" in the choices made by Unity. The solution is simply to place an object like a small sphere temporarily in front of the camera rig at the desired zero parallax distance and adjust the orthographic size until it is indeed appears to be at zero parallax. Note that the game window below is not filled with the stereo pairs, this is because it doesn't have the right aspect ratio of 8:3 (2048x768).

然后在两个渲染纹理平面的中间位置放置一个正射投影的相机,然后设置其只渲染立体图层。我们通过去掉左侧图像的左边部分和右边图像的右边位置来控制零视差,在这里有介绍(另外一篇博文)。这种修边处理可以通过正射投影的范围大小来控制。但是,玩家的窗口比例和正确的正射投影范围大小(对一个特殊的零视差距离来说)之间的关系有些令人费解,因为Unity所做选择中的一些“magic”。解决方法是,在相机前面临时放一个类似小圆球的东西来调整想要的零视差距离,并调整正射投影的范围大小,直到出现了零视差。要注意的是,下面的游戏窗口没有填满立体相对,这是因为窗口没有正确的8:3宽高比(2048x768)。

在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体

 

The following shows the left and right image side by side. The left hand image is sent to the left eye projector and the right hand image sent to the right eye projector. In this case the splitting effect is accomplished by using the Matrox dualhead2go cards to give the desired 2048x768 pixel buffer.

在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体

 

The two images overlaid with 50% transparency shows how the parallax increases with distance and the front posts are at the intended zero parallax distance, and there is no vertical parallax.

在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体

 

In order to avoid excessive negative parallax for objects that approach the cameras one may choose to increase the front cutting plane of the two controller cameras to be some reasonable fraction of the zero parallax distance. This depends on the ghosting of the projection system, for polaroid systems this cutting plane may conservatively be set to 1/2 the zero parallax distance, this ensures that the maximum negative parallax equals the maximum positive parallax. For lower ghosting systems such as Infitec the cutting planes can be set closer to the camera.



The authors stereoscopic viewing system, rear projection linear polaroid.


在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体

 

Photographs of the display.

在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体在Unity游戏引擎中创建平行的立体相对 <wbr><wbr>实现被动立体

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多