11

渲染时我应该一直使用这种方法吗?它在坏显卡上会减慢很多吗?

如果最终结果不会有很多剔除的面孔,那我应该使用这种方法吗?

4

3 回答 3

22

如果您的所有模型都定义正确(凸的,具有一致的顶点缠绕),那么剔除永远不会影响性能,并且几乎总是有助于性能。

想象一下,您正在渲染一个立方体,并且禁用了剔除。立方体背面(远侧)的面被渲染为背对您,并且您选择的任何背面材质属性都会被应用。然后渲染立方体正面的面:由于刚刚渲染的背面是立方体的内部,因此它们被正面 100% 遮挡。

如果立方体的方向不同,正面可能会先被光栅化,但背面仍将被处理,然后碎片被 z 缓冲区拒绝。

最终结果:您根据需要栅格化了 2 倍的片段。这对于大量的多边形或复杂的像素着色器来说是一件大事。面部剔除可让您完全避免光栅化您知道不会出现的面部。

如果您的角色模型具有约 100,000 个多边形,则面部剔除将像素硬件每帧必须完成的工作量减半。如果你有大的表面着色器,这是一个很大的节省。

如果您正在使用小型模型并且没有着色器,那么这些天剔除真的无关紧要。但无论如何,启用它是一个好习惯。

于 2010-03-06T18:07:05.437 回答
6

Enabling face Culling (usually back-face) has a significant impact on the rendering performance.

Now the question to be answered is then "why isn't culling enabled by default or why isn't used always?" there are several factors which determine whether enabling culling is feasible or not. One is the model being rendered and how it is viewed.

For every polygon in the model, if only one face either front or back is visible (when the model is viewed from all possible angles) then we can cull the other face.

For Ex: "Cube", no matter if you are looking from inside or outside of it, when rotated, you can see only one side of every 6 polygons which make-up the cube.

Another Ex: "Sails of a ship Model" as in my Sea-Wars(3d) game, the sails of a ship model is a surface built with several flat polygons. When a boat moves around in the water, one can see both sides of the sail. In this case culling either of the faces is not desirable.

Hence culling can be enabled for all the models in the scene which follow cubes semantics and disabling for all other models.

P.S. Face Culling should be used whenever possible.

于 2011-01-15T00:25:37.867 回答
0

这取决于您要渲染的内容。一般来说,剔除是可取的。我可以想象不使用它的唯一原因是渲染具有可见背面的模型。另一种可能不需要剔除的情况可能是模型建模不佳的模型,其中顶点的定义顺序错误。

于 2010-03-06T17:43:36.910 回答