How and when to use fragment stage patch? optimizing shaders

Hi guys, recently I had a bit of a mountain to climb in regards to optimizing my animated shaders.
Multiple looping animations really hurt performance.
So I just made the animations in a script, used just 4 of them to feed like 90 materials. so thats good and done.

But I thought what if I know how to use fragment stage patch? does it help?
have the impression it has something to do with what chip will end up running the calculations up to a certain point, but maybe I am wrong on this one.
haven’t seen it applied many times either, so no examples to educate myself, and the official reference on this is not enough either

Do you guys have a particular motive to use it? where would it help?

It all runs on the GPU, but the vertex stage is generally much faster since it operates on vertices and not pixels. For example, you have a mesh with 5k vertices, and a texture with 1048576 pixels (1024*1024) - the vertex stage runs much faster because it has less points to work on.

The vertex stage runs faster, but you can only assign colors at each vertex. If you have a plane with 4 vertices, it will only sample color at the 4 corners and then interpolate between them in the space on the plane. You’ll end up with very smooth / blurry colors in that case.

A general rule of thumb is to not use fragment stage unless you need it (do a visual check to determine if quality drops when removing it), but I think Spark’s shader compiler will automatically kick you into the fragment stage based on what operations you are using.

3 Likes

ok! I see, so its on reverse to what I thought, instead of going cheaper, its a way to achieve a better quality at the expense of multiplying a ton the calculations