Shader reuse/referencing by Sprites

So I am new to shaders so this question might not be possible but wanted to ask in case I am missing something. I noticed that when I have a large number of Sprites that all have shaders that performance degrades as more Sprites are added. Is it possible to somehow reuse the reference to a single instance of a shader and just update the uniform for each Sprite as it is rendered? I have tried reusing a single instance of my shader in each Sprite by trying to update the uniform for each Sprite with events for render and enter frame but that doesn’t seem to work. I don’t understand the pipeline and it just seems that the shader gets called once for all the Sprites and whatever the uniform is at the time that is what I get. The use case is a glowing shader for a bunch of sprites that I redraw quite frequently with the graphics class.

May I take a look at your shader?

Usually only a single shader is needed, not multiple.

To help illustrate my question I created a bare bones bunny mark demo that uses your OutlineShader as an example. Currently the project uses a single instance of the OutlineShader that is initialized in the Main. Performance is great even with 10000+ tiles. The problem is that because I am referencing a single OutlineShader for all the bunnies they outline all the same color. You will notice I try and update the color for each bunny in the update method but I don’t know where to actually hook in to the rendering pipeline. This is probably to be expected but I was wondering if there is a way to reuse the shader to keep the performance high. If however in the Bunny class you uncomment the code to initialize a new OultineShader the outlines are different colors as expected but performance starts to drop pretty quickly as bunnies are added, at least on Mac using hxcpp. The idea is to determine what is the most efficient way to have shaders on lots of tiles without impacting performance if possible.

Need to use @:attribute and @:varying
I think Tilemap does not support attributes. If it does, the parameters of each object can be passed through attributes.