正在起草前到后的必要的优化渲染? [英] Is drawing front-to-back necessary for optimizing renders?

查看:187
本文介绍了正在起草前到后的必要的优化渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过偶尔文章认为,从最近订购的顶点从相机发送到OpenGL的(任何的OpenGL的变体)时,最远。通过这个建议的理由是,OpenGL的将不能完全处理/呈现一个顶点,如果它是背后已经呈现另一个顶点

I've seen the occasional article suggest ordering your vertices from nearest to furthest from the camera when sending them to OpenGL (for any of the OpenGL variants). The reason suggested by this is that OpenGL will not fully process/render a vertex if it is behind another vertex already rendered.

由于通过深度排序顶点是任何项目的一个昂贵的部件,因为通常这种排序变化频繁,如何共同的或必要的是这样的设计?

Since ordering vertices by depth is a costly component of any project, as typically this ordering frequently changes, how common or necessary is such design?

我有previously认为的OpenGL会看在所有提交的顶点和处理自己的深度缓冲他们,不管他们的订单,的的渲染整批。但是,如果实际上是一个顶点获取呈现之前另一个屏幕上,然后我可以看到排序可能受益的性能。

I had previously thought that OpenGL would "look" at all the vertices submitted and process its own depth buffering on them, regardless of their order, before rendering the entire batch. But if in fact a vertex gets rendered to the screen before another, then I can see how ordering might benefit performance.

时的图纸从前到后必要的优化渲染?

Is drawing front-to-back necessary for optimizing renders?

推荐答案

在原始的栅格化,它的Z值可以用来做一个早期Z轴杀,而跳过运行片段着色器。这是最主要的原因,以使前端到后端。提示:当你有透明的(阿尔法网纹)多边形,你必须使后端到前端。

Once a primitive is rasterized, its z value can be used to do an "early z kill", which skips running the fragment shader. That's the main reason to render front-to-back. Tip: When you have transparent (alpha textured) polygons, you must render back-to-front.

OpenGL的规范定义了一个状态机和没有指定什么样的顺序呈现实际情况,只表示结果应该是正确的(在一定的公差范围内)。

The OpenGL spec defines a state machine and does not specify in what order the rendering actually happens, only that the results should be correct (within certain tolerances).

编辑为清楚起见:我想要上面说的是硬件可以为所欲为,只要原语显示以人为了得到处理

Edit for clarity: What I'm trying to say above is that the hardware can do whatever it wants, as long as the primitives appear to have been processed in order

然而,大多数的GPU是流处理器和他们的OpenGL驱动程序不批了几何,也许除了性能方面的原因(最小DMA尺寸等)。如果在多边形A,继以多边形B饲料,然后将它们送入后,其他的管道之一,并彼此独立地进行处理(在大多数情况下)。如果有A和B之间的多边形足够数量的,然后有一个很好的机会,A,B完成之前,如果B为背后的一个,它的碎片将通过早期Z轴杀被丢弃。

However, most GPUs are streaming processors and their OpenGL drivers do not "batch up" geometry, except perhaps for performance reasons (minimum DMA size, etc). If you feed in polygon A followed by polygon B, then they are fed into the pipeline one after the other and are processed independently (for the most part) of each other. If there are a sufficient number of polys between A and B, then there's a good chance A completes before B, and if B was behind A, its fragments will be discarded via "early z kill".

编辑为清楚起见:我想要上面说的是,由于硬件不批了几何,它不能做前端到后端自动排序

这篇关于正在起草前到后的必要的优化渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆