Question

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

enter image description here

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top