I am developing an engine for my game and a large majority of the way things are drawn to the screen is directly dependent upon the ability to set the fill color of parts of the sprite programmatically.

I've posted about it before, but I'll reiterate for clarity. If a character has brown hair, the shade of brown is the midtone, which is determined mathematically. An overlay of black set to approximately 33% opacity gives the shadows and another overlay of white with the same opacity gives the highlights.

The reason I want to split things up into layers like this is so I can make the character editor highly flexible while relying on the smallest quantity of reusable graphic elements as possible. In other words, I don't want to have characters with a million sprite resources or only two supplied colors to choose from.

I have already developed and nearly finalized a class that allows the user to select virtually any color using a hue, saturation, value hexagonal color swatch, so the range of colors and how to acquire them isn't an issue.

The trick is at render time. I'm already certain that I could apply the adjustments once, then use them for the lifespan of the sprite. What I want to do is use simulated lightmaps and compositing to place my characters into the scenery.

How would I go about doing this? Imagine a simple example of a character standing beneath a tree in a sunny field. If I wanted to simulate patches of light poking through the canopy and falling on my character who is otherwise in shadow, how would I achieve this? The graphic resources of the sprite would have to remain untainted somehow and simply merged with other layers to create this end result, but would that dictate the necessity of using multiple synchronous focusRects on every layer of the final render, then blending them all per frame to get the expected result?

If so, what's the cap on layers I can merge before it starts to choke?
Keep in mind, I'm probably only going to be using bitwise operations, maybe threshold (if that) when it comes to filters.

I'll find out once I start getting into things. For now, I don't want to get geared up in the wrong direction, then have to rewrite most of my engine because I didn't prepare first.