0
\$\begingroup\$

I found that the vertex shaders are sometimes very useful, especially because they can generate geometries and extract and use a lot of informations from just 1 image.

The problem is that my project still isn't that big and looking to bigger project or just to commercial games, seems like the vertex shaders are rarely used.

Am I wrong or the pixel shaders are much more used than the vertex shaders?

This has something to do with performance issues and compatibility issues? What about some possible bottleneck like the memory controller/CPU ?

\$\endgroup\$
5
  • 3
    \$\begingroup\$ I'm not sure if you're understanding the difference between fragment and vertex shaders. They are used for different things. So one being used much more than the other doesn't imply anything about the usefulness of the other. \$\endgroup\$
    – House
    Aug 9, 2012 at 18:30
  • \$\begingroup\$ @Byte56 no, the point is about what should i adopt for future uses, the fact that the vertex shaders are useful is not a doubt for me, even more, since i understand their usefullness i don't get why they aren't used that much. I want to discuss possible performance issues rather than if they are useful or not. \$\endgroup\$
    – user827992
    Aug 9, 2012 at 18:33
  • 2
    \$\begingroup\$ Vertex shaders can't generate geometry. Geometry shaders can, but that comes with a cost. \$\endgroup\$ Aug 9, 2012 at 18:35
  • 1
    \$\begingroup\$ They aren't used as much because they serve a different purpose, not because of performance. And if you're doing a side by side comparison of some effect that can be implemented either on vertex or pixel shader (such as texture scrolling) then the vertex shader will actually be faster because it's executed far less times (per vertex vs per pixel). \$\endgroup\$ Aug 9, 2012 at 18:39
  • \$\begingroup\$ @LaurentCouvidou, vertex shaders can generate geometry just fine. Here's an entire website of vertex shader generated geometry and although this question old that site is using nothing but GLSL ES 1.0 shaders, a spec from 2007. \$\endgroup\$
    – gman
    Nov 17, 2020 at 19:19

1 Answer 1

11
\$\begingroup\$

This seems like a big misunderstanding on your part, and I think the comparison doesn't make much sense because in general they serve different purposes:

  • Vertex shaders are executed once for every vertex in the geometry, and are used to modify or add new information to those vertices. For example, they can be used to slightly modify the position of the vertex, or calculate a light value for that vertex.

  • Pixel shaders on the other hand are executed once for every pixel/fragment that covers that geometry, and are used to determine what the final color for that fragment should be.

It might be true that pixel shaders are used a lot more than vertex shaders, but that's because there are a lot of effects that require that extra control over the color of each fragment that are only possible with pixel shaders, e.g. things such as bump mapping, or any full screen post processing effect. Vertex shaders have different uses, and are used mostly for other types of effects such as creating waves in the ocean, and other types of distortions.

As for your performance question, if you can implement the exact same effect, with same visual quality either on vertex shader or pixel shader, then I think the vertex shader version will probably be a lot faster, because the number of vertices will usually (always?) be a lot smaller than the number of pixels covered by the primitive.

\$\endgroup\$
3
  • \$\begingroup\$ your answer is really interesting, but the problem is that probably i misunderstood the difference between vertex shaders and geometry shaders, and in reality, i was writing and thinking about the geometry one. I probably should open another Question ... sorry for that, but at least i have understood the difference with your post, thank you. \$\endgroup\$
    – user827992
    Aug 9, 2012 at 18:41
  • 2
    \$\begingroup\$ In high-end games on iOS devices, I often had to balance calculations between vertex shaders and fragment shaders. Vertex shaders are run once per vertex, and fragment shaders are once per fragment which passes a depth test. On devices with low resolution displays (iPhone3, etc), it was often faster to put the calculations on the fragments, since if you were clever about sorting your draw operations, high-triangle-count objects would often have fewer visible pixels than vertices. (Of course, that would then hurt performance on retina devices, where there were heaps more pixels to draw) \$\endgroup\$ Aug 10, 2012 at 0:11
  • \$\begingroup\$ @TrevorPowell Thanks for the input, I figured there might be some edge cases like that but couldn't think of a real scenario :) \$\endgroup\$ Aug 10, 2012 at 10:49

You must log in to answer this question.

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