I’ve poked around a bit but haven’t uncovered anything yet, so I figured I’d ask here while I continue to search. Is there some feature (or trick that people know of) to change pixels on a sprite? Basically, imagine the following graphic.
During runtime, I need to change the colour of the blue pixles (so the blue cube) to be red, but without touching any of the other pixels on the sprite. Before anyone says, I’m aware I could just use two cube game objects, but the use-case is actually a lot more advanced, this is just the basic concept I’m after.
I don’t mind if I have to explicitly define which pixels are modified on the sprite and loop through them all setting them one by one (even though that’s gross). Any thoughts/ideas?
Is this only for display purposes? If so, you could consider doing it in the fragment shader. If you actually want to alter the pixels values in memory, it’s unfortunately not yet possible.
If it is only one color you could also put those pixels as white in a separate sprite and tint that sprite. That would be simpler but less flexible than using a shader.
Can you explain more about what you want to do? You want to selectively set the color of certain color ids within sprites? Maybe for customizing the color of armor elements (paint by number style?) or something like that? A shader to do this would be pretty easy, but would need more info about the exact needs/usage.
I managed to get something figured out, sorry I didn’t update the post about it, I’ve been lost in code. The idea was to re-colour certain parts of sprites based on in-game variables. I went down the route of writing some custom shader code to achieve this.