Advantages of compute shader over vertex fragment shaders in unity

Hi, suppose I have a velocityBuffer for all vertices. and I frequently change the position of each vertex with time as (velocityBuffer * Time). I can actually do this in vertex fragment shaders too (in vert), using material.setBuffer(velocityBuffer) in C#. But multiplying velocity and time can be done in compute shaders too and pass it to CPU and then pass it to vertex fragment shader for colors.

Which is advantageous here performance wise? using compute shaders and vertex fragment shaders, or only using vertex fragment shader?

If I have some complex calculation like using sin, cos etc., per vertex. Then is it advantageous to perform those computations in compute shader?

Thanks in advance !!

Any data that comes back to the CPU from the GPU is a significant performance bottleneck. Most of the time it’s faster to do the work on the CPU, or keep all the data on the GPU and never let the CPU see it.

The advantage compute shaders have is there are fewer expectations on what data they get and must output, as well as what else the GPU will do with that data. A vertex shader gets the data for one vertex at a time and must output the position of that vertex. A fragment only gets the interpolated data output from the vertex shader for a single pixel and must output a color value. A compute shader can have access to any data you pass to it and output anything you want.

Generally speaking if all you’re doing is multiplying two values per vertex, you’re probably fine just doing that in the vertex shader.

Thankyou !!