广告牌技术教程:引言

来源:互联网 发布:动画ppt软件下载 编辑:程序博客网 时间:2024/04/27 17:22

Billboarding is a technique that adjusts an object's orientation so that it "faces" some target, usually the camera. The wordfaces is in quotes since it can have several meanings, as the tutorial will show.

广告牌是这样一个技术,它通过调整物体的方向以使之正向面对某个目标物体,通常这个目标物体是照相机。这个单词"faces"之所以用引号是由于这个单词有好几个含义,正如接下来教程里面所展示的那样。

This technique is quite popular in games and applications that require a large number of polygons. Regardless of how fast graphic cards get (Thanks Nvidia!), it seems that it is never enough. Games take advantage of the hardware advances to push things further to the next level in complexity and detail (In turn hardware manufacturers try to keep up with games designers in a never ending cycle). 3D graphics programmers in general, and game programmers in particular, have a constant struggle with the amount of polygons that can be displayed with a decent frame rate.

这个技术在游戏里面以及使用大量多边形的应用软件里面很流行。不管显卡的速度能有多快(感谢英伟达公司),看起来 永远是不够的。游戏设计商可以利用硬件的优势进一步将物体推向更细腻更复杂的一个级别(作为回应,硬件制造商试图跟上游戏设计商的步伐,这似乎是永远没有尽头)。一般情况下3D图形编程者特别是游戏编程者,他们长期与用特定数目的帧率显示大量多边形的情形作斗争。

Billboarding can be used to cut back on the number of polygons required to model a scene by replacing geometry with an impostor texture. A classic example is a tree. Consider how many polygons would be required to get a decent representation of a tree (specially in the Spring!). Billboarding allows us to replace the geometry with a single texture applied on a quad (or two triangles). Billboarding guarantees that the texture is always facing the camera, therefore the user never realizes that the "tree" is in fact a flat texture quad, unless the user flies over it in which case the illusion is broken.

广告牌技术可以通过用冒名顶替的纹理替换几何物体的方式来减少组成物体的多边形的数量。一个经典的例子就是树木。试想一下如果要用一种优雅的方式显示一颗三维树木那得需要多少多边形啊(尤其是描绘春天的树木茂盛的样子)。广告牌技术可以保证纹理总是面向照相机,因此用户从来都不会发觉这个“树木”其实是一个平面的纹理四边形。除非用户从这个树木顶端飞过,在这种情况下假象将会被打破。

Beware that shading will not be correct if the same texture is used for all orientations. A 3D tree viewed from different locations will exhibit a different look assuming a fixed, or at least non-correlated light movement with the camera. For a 2D billboard, when using the same texture for all orientations, it will look as if the light is moving with the camera. It may be the case that the user won't notice this shading discrepancy, but be prepared for it. One possible solution is to have multiple textures taken from different views. However, unless a prohibitive number of textures is used, a popping effect will be noticeable when the texture changes. Blending may be a solution for this problem but this is outside the scope of this tutorial.

应该认识到渐变将不真实如果同一个纹理被应用于所有的方向。一颗3D树木从不同的方向观察时将呈现不同的面貌,假设照相机的一个固定的或者至少不相关的光源的移动

。对于一个2D广告牌,当所有方向使用同一个纹理的时候,看起来仿佛是光线在围绕着照相机移动。这种情况下用户可能不会意识到这种渐变的矛盾之处,但是我们要悠着点。一个可能的解决方案是在不同的视点使用不同的纹理。然而除非使用数目巨大的纹理,否则当纹理之间转换时会产生跳跃现象。ALPHA混合可能是一个解决跳跃现象的办法,但是这超出了这个教程的范畴。

Billboarding can be used to give the illusion of a 3D object without compromising the polygons budget. However billboarding is not limited to saving polygons. In general, the billboarding technique can be applied to make any object face a target, where the target may be the camera, another object, or simply a 3D location.

广告牌技术可以用来模拟3D的假象而不用为了多边形的数目而妥协。然而广告牌技术并不仅限于节约多边形的数目。通常广告牌技术可以用来使物体faces一个目标,而这个目标可能是一个照相机、其他物体或者一个简单的3D坐标。

In this latter scenario billboarding isn't used to save polygons but to achieve some goal related to the purpose of the application, for instance the enemy might always be facing you, or a football player is always facing the ball.

在接下来的方案中广告牌技术不是用来节约多边形的数量而是用来调整目标的方向,例如敌人总是面向你,或者一个足球运动员总是面对着足球。

Two types of billboarding are presented: cylindrical and spherical. In the spherical version there is no restriction to the orientation of the object, whereas in the cylindrical approach the rotation of the object is restricted to a vector, usually the positive direction of the Y axis.

两种广告牌技术将被展现:圆柱型和球体。在球体广告牌中对于物体的转向没有限制,而在圆柱体广告牌中物体的旋转轴被限制为一个向量,通常是Y轴正方向。

In this tutorial several techniques to implement billboarding will be covered. The first one is a very simple method but it doesn't provide a real billboard. It is a cheating approach that is very easy to implement. A faster approach for quad billboards that provides exactly the same results is provided afterwards. It is not as easy to implement but there can be a significant difference in speed when using a large number of quad billboards.

在这个教程里用来实现广告牌技术的几个技巧将被介绍。第一个技巧是一个非常简单的方法但是它并不是一个真正的广告牌。这是一个欺骗性质的方法非常容易实现。一个有同样效果并且实现广告牌技术更快的方法将会在后来介绍。这个后续版本不那么容易实现,但是当使用大量广告牌时他的速度的改观将会很明显。

Finally true billboards are presented. These methods allow you to set a billboard to face the camera. they can also be used to have an object face another object or point in space. In this sense they are more general than the cheating versions.

最终真正的广告牌将被呈现。这些方法允许你设置一个面向照相机的广告牌。他们也可用于是一个物体面向另一个物体或空间中的一个点。在这些场景中他们比欺骗性质的广告牌更通用。

 

原创粉丝点击