Search code examples
opengl-esfrustum

Is the geometry outside of OpenGL ES Frustum also rendered?


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?


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.