Texture partially off screen - performance difference

吃可爱长大的小学妹 提交于 2019-12-04 05:18:26

问题


On the picture is an example of two situations, where a textured polygon is being rendered. All done by Opengl ES2.

A) the polygon is partially off the viewport B) the polygon is completely inside it

My question:

Is situation 'A)' going to consume less system/gpu resources*, because the texture is partially off screen, or will it perform just the same as if i rendered it inside of the viewport and why?

*"Resources" - meaning speed, not memory.

I know that opengl does calculate vertices first, before rendering texture and if the vertices are off screen/viewport, it skips any further calculations, but is that the same case with textured object that is partially off screen? Will it omit the part of the texture that is not visible?


回答1:


Situation A should be faster. Vertex processing will be the same. After that, clipping to the view volume is applied. In situation A, part of the polygon will be clipped, while the whole polygon goes through in situation B. After that, the polygon is rasterized, and the resulting fragments go into fragment processing. Since there are fewer fragments in situation A, there's less work to do in this stage. The fragment shader does the texture sampling, so only the visible parts of the texture will be sampled in this case.

Clipping can also happen after the fragments are generated, but I would always expect it to be done before the fragment shader.

While there will always be less work in situation A, this doesn't necessarily mean that you'll see a speed difference in the rendering. You could have bottlenecks in other parts of the pipeline, or in your app code.



来源:https://stackoverflow.com/questions/23186192/texture-partially-off-screen-performance-difference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!