I'd like to have sprites with program-defined colors. One way I could do this is import the sprite and generate variant textures on the CPU, then swap out the texture on the sprite as needed. However, as I understand it, then I won't benefit from batched rendering, which seems like an unnecessary de-optimization. If I could just stick some of my own uniforms and a fragment shader onto the sprite pipeline I'd be set, but I can't see a way to do that. Am I msising something?
#Dynamically colored sprites
5 messages · Page 1 of 1 (latest)
Fragment shaders are definitely the way to go about this.
This example is a good start
https://bevyengine.org/examples/shaders/animate-shader/
then you would need to sample the pixel data of your texture and draw stuff depending on that (that part might be the hardest, I think people have already made shaders for sprite)
I didn't think you'd lose batching with this, but I guess you do, though it shouldn't matter much. Graphics Performance is rarely a problem for 2d games these days (exceptions apply).
https://www.reddit.com/r/bevy/comments/132zyl6/additive_blending_of_sprites_in_2d/
This is an example for working with sprites