SFML community forums

General => Feature requests => Topic started by: kfj on June 30, 2020, 10:16:38 am

Title: crossfading images
Post by: kfj on June 30, 2020, 10:16:38 am
I'm using SFML to write an image viewer. I'd like a simple way to crossfade from the current image to the next one. I haven't found a way to do this with SFML yet - if there is one, please let me know! I have the images as textures on the GPU and I'd like to use the GPU to produce the effect.

I think the simplest way to do this is to draw the new texture on top of the old one several times, increasing the new frame's alpha values every time until it's fully opaque, but touching every single pixel with the CPU just for that is too expensive. What I'd like is a function to globally change the transparency of a complete texture, or a blending mode to the same effect. I suppose this would be easy to do with a fragment shader, but I haven't worked with shaders so far and I'd prefer a simple prefabricated solution.

Kay
Title: Re: crossfading images
Post by: G. on June 30, 2020, 11:08:44 am
Set the color of the sprite you want to fade to a progressively more transparent white.
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Sprite.php#a14def44da6437bfea20c4df5e71aba4c
Title: Re: crossfading images
Post by: eXpl0it3r on July 06, 2020, 11:16:44 pm
For "effects" like this shader exist. ;)

SFML doesn't try to be an engine with lots of prefabricated stuff, we just provide a nicer and cross-platform API, so the users can implement their own things on top.