Question

I am developing a game for iPhone using OpenGL ES as drawing api. I am drawing a whole big world in a single draw element. The object is visible according to the frustum.

I want to know what happens to the other part of the object, Is it drawn? Does it affect the FPS?

Était-ce utile?

La solution

For any vertex of the scene, the vertex shader has to be ran, so that their coordinates are transformed from model space to clip space.

After that, primitives which aren't contained in the clipping volume (which means that in clip space they're either outside of the screen or too far or too near) are clipped, so that they aren't processed further and pixel shader won't be ran for them.

This is the same for OpenGL and OpenGL ES. You can find the details in the OpenGL ES spec (2.13 Primitive Clipping) or in the OpenGL spec (same headline).


This means that having lots of geometry, of which most is outside of the frustum, will affect your rendering time a bit, but much less than if all the geometry was actually rendered. Only per-vertex transformations need to be done; rasterization and per-pixel operations (fragment shader, actual write to framebuffer) won't be executed for them.

This also implies that if you do many per-vertex operations and less per-pixel operations, then it may be more important to write an additional visibility tests for your scene.

Autres conseils

OpenGL processes all primitives that you tell to draw. That's why you have to determine what to draw yourself. It is really hard problem, as the starting point read this.

The geometry pipeline transforms vertex coordinates to window coordinates; at that point out-of-window polygons can be discarded. But too many innecesary geometry is processed, and performance is hit.

Consider using some kind of frustum culling: divide your scene in smaller parts or tiles, and evaluate, before drawing, if the tile is fully outside the view frustum, thus drawing only tiles which could lay inside the frustum.

Even with a simple partition, the difference should be noticeable.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top