Hello,
I’m currently experimenting with shader-based animation of 2D-objects. One of that objects is supposed to have multiple animation-options with the possbility to switch between them on runtime. Thats all fine and stuff my question now is:
Does it make sense (in consideration of performance and code-design) to wirte a sperate shader-pair (vert & frag) for each animation in constrast to writing a single shaderprogram and abstract the uniforms/attribs to a higher level (so they fit for all the different animations).
Note that in my case no textures are involved. Procedural only!
With my limited experiance I see these points on each side:
Single program:
- no switching between programs (performance?)
- less efforts client-sided due to standardized structures for uniforms/attribs
- (significant) more complex and confusing shader-code
- possibly unnecessary uniforms/attribs (certain animations might not need all the “space”)
Multiple programs:
- clean shader-code
- less uniforms/attribs in each shader
- switching between programs necessary
- possibly more efforts on client-side needed
What do you think?
greenOwl