6
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

10
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ I was expecting an answer like this one, but at least i have tried . \$\endgroup\$
    – user827992
    Aug 29, 2012 at 6:24
  • \$\begingroup\$ @edA: "Of course there may be extensions which could alter this flow, but I think this covers the general case." FYI: there are not. \$\endgroup\$ Aug 29, 2012 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .