纹理部分脱离屏幕 - 性能差异 [英] Texture partially off screen - performance difference

查看:179
本文介绍了纹理部分脱离屏幕 - 性能差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在图片上是两种情况的示例,其中渲染纹理多边形。全部由Opengl ES2完成。

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

A)多边形部分偏离视口
B)多边形完全位于其中

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

我的问题:

情况'A)'会消耗更少的系统/ gpu资源*,因为纹理部分偏离屏幕,或者是执行就像我在视口中渲染它一样,为什么?

*资源 - 意思是速度,而不是记忆。

*"Resources" - meaning speed, not memory.

我知道opengl在渲染纹理之前首先计算顶点,如果顶点在屏幕/视口之外,它会跳过任何进一步的计算,但是与纹理对象相同的情况是部分屏幕外? 是否会省略不可见的纹理部分?

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?

推荐答案

情况A应该更快。顶点处理将是相同的。之后,应用裁剪到视图体积。在情境A中,多边形的一部分将被剪裁,而整个多边形在情境B中经过。之后,多边形被光栅化,并且所得到的片段进入片段处理。由于情况A中的碎片较少,因此在此阶段的工作量较少。片段着色器执行纹理采样,因此在这种情况下只会对纹理的可见部分进行采样。

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.

虽然在情况A中总是会有较少的工作,但这并不一定意味着你会看到一个渲染速度差异。您可能会在管道的其他部分或应用程序代码中出现瓶颈。

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.

这篇关于纹理部分脱离屏幕 - 性能差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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