Starling-Framework
Starling-Framework copied to clipboard
Allow cheap ColorMatrix effects by specialized shader code
Add the option to the QuadBatch class to use a matrix to perform color matrix operations at rendering with just one additional AGAL instruction.
You mean similar to the "ColorTransform" option in classic Flash, right? Thanks for the suggestion — I'll think about it! Would definitely be useful.
This feature would save a lot of texture memory on mobile device for a lot of effects (lighten, darken, posterise, b&w..).
Not ColorTransform, that is just linear equations that operate on each channel individually. I mean a full matrix where every channel can affect every other channel. Look at flash.filters.ColorMatrixFilter to see what I mean.
And while the example is a "filter", I am asking for this not as a heavy starling.filters.ColorMatrixFilter, but as a simple property on the DisplayObject class. Using a filter is overkill for something that can be done in the normal shader that draws real textures directly to the back buffer, no need for intermediary render textures here.
Yeah, I understand — that's what I meant, having something directly on display objects, just as the color transform class (but more versatile).
The key point here is to avoid the extra costs involved with the filter. No additional draw pass, no RenderTextures, just a shader variant that does the job.
Yes, I totally understand what you mean. I'm currently considering a more flexible rendering system, and this would most probably become possible then, too.
I'm sorry to ask but do you have any timeframe on that specific feature? I could try to do it myself but I'm really not good at agal stuff.
That's hard to say, but it will probably not be very soon. My plan is to finish the Sprite3D feature, then probably implement Stencil Masks, and after that the rendering system overhaul could start, which would make this possible.
[Sorry for the late reply, I was on a vacation!]
My description from the previous post turned out to be rather accurate, actually! 1.5 years later, you can now finally achieve that with the help of Starling's new "MeshStyles". Here's an implementation that shows you how to create such a style: ColorOffsetStyle
- It's not default. Code that you need to dig out from online examples is not good enough, it needs to come with the library itself.
- It's not the full matrix. It is only a linear transform on each of the channels. This was for a full matrix multiplication so that you get things like hue shifting.
Okay, fair enough! It's planned to add such a class to future releases.