user464230
user464230

Reputation: 876

Shaders' Performance (Vertex VS Fragment)

Is ALWAYS better make the hard calculations inside the Vertex Shader rather than in Fragment Shader? Even to high mesh models, with more than 100.000 polygons (assuming there are a bunch of unique vertices)?

Upvotes: 5

Views: 2127

Answers (1)

kvark
kvark

Reputation: 5351

No it's not always better.

The best way to select the proper place of calculations is an experiment. Try both and see what is better for your constraints and hardware.

Theoretically though, you can estimate the number of fragments processed and compare it to the number of vertices. Modern GPUs use the same processing units for vertex and fragment shaders, so looking at these numbers will give you an idea of where to do the calculus.

Advices to do everything in vertex shader (if not on CPU) come from the idea that your pixel-to-vertex ratio of the rendered 3D model should always be high. There is no need for geometry detail if you see an object at a very high distance, that's what geometry Levels Of Detail (LODs) are used for. So if you do it in the "good" way - you'll need to calculate on a vertex level. If you don't follow it - you are on your own.

Upvotes: 5

Related Questions