“almost” done because I’ve faced with problem of performance. Overall it works, but…
When I’ve applied shader to 1 sprite only it’s 60fps, but when I’ve tested like in real situation with just 20 sprites on the scene I’ve got ~10fps only on my device iPod Touch 5G. I’m testing my games on this old device and it should works 60fps ideally on it. Otherwise, it’s not so fast to be used, because it will be slow on most android devices.
Can that shader be improved? Read from “Extension to the answer”. I’m using last shader.
Also, there are solution to “Modify the texture on the CPU”, but I don’t understand how I can modify at runtime all my sprites, without re-creating them. Probably sprite->getTexture()->updateWithData( can help? Any ideas? How can I modify already created Sprite object? Modify it texture to modify it colors? Maybe this logic is wrong and this can be done in some other way…?
For sure I’m using sprite sheets, so my Sprites created from one big sheet and probably the is a way to modify it and so changes will affect to all sprites created from it? @zhangxm Minggo can you please advice anything?
You should confirm it’s batching and if not figure out how to use only a single uniform value (or send per-sprite data inside the 4 float setColor). Also, iTouch 5G is a very old and slow device. Any game release today can target a much higher-end device.
So I’'m looking for a some other solution. Maybe improve shader(this is looks like most ideal way) or re-color texture for loaded Sprite’s. I don’t know if it possible?
auto batching can work with some limitations. The sprites should be drawn one by one, can not insert other Nodes between them, or it may break the batching.
Finally, using a shader to find and re-color pixels gives me some problems on different devices.
I’m looking for some other solution. What I’m thinking… I can create a grayscale image and so can I somehow colorize it to exactly fit my target image?
For example, I have this image:
-> colorized to:
-> and also to:
It’s very important for me to get same RGB values for every triangle.
Is there way to implement this? @Joseph39@stevetranby@zhangxm