Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If i have a vertex shader that manage some movements and variations about the position of some vertex in my OpenGL context, OpenGL is smart enough to just run this shader on only the vertex visible on the screen?

This part of the OpenGL programmable pipeline is not clear to me because all the sources are not really really clear about this, they talk about fragments and pixels and I get that, but what about vertex shaders?

If you need a reference i'm reading from this right now and this online book has a couple of examples about this.

share|improve this question
up vote 10 down vote accepted

Pretty much the vertex shader has to run on all the vertexes you provide to the pipeline. The reason is simply because the vertex shader can alter the position of the vertex. Before the vertex shader runs the renderer will have no idea whether the vertex is in or out of the frustum. I suppose more correctly it doesn't even know what a position is until told via glPosition; prior to this point the pipeline has no knowledge whatsoever where the vertexes are -- thus it couldn't possibly filter them.

The fragment shader will of course not be called if none of it vertexes lie within the display (this isn't guaranteed of course, but we assume the card is at least half-intelligent).

So if your question really is do you have to do your own culling of vertexes, the answer is yes.

Of course there may be extensions which could alter this flow, but I think this covers the general case.

share|improve this answer
I was expecting an answer like this one, but at least i have tried . – user827992 Aug 29 '12 at 6:24
@edA: "Of course there may be extensions which could alter this flow, but I think this covers the general case." FYI: there are not. – Nicol Bolas Aug 29 '12 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.