SFML community forums

Help => Graphics => Topic started by: Nafffen on May 14, 2023, 04:11:54 pm

Title: Blur WITHOUT shader
Post by: Nafffen on May 14, 2023, 04:11:54 pm
Hello,
What is the best and efficient way to apply gaussian blur without shaders ? (because I want to play on android later)
Is drawing on RenderTexture and CPU compute blur the best way ? It seems too expensive to me
Thank you
Title: Re: Blur WITHOUT shader
Post by: eXpl0it3r on May 14, 2023, 05:33:16 pm
Depends a bit what you want to use it for. Maybe you don't need proper (gaussian) blur, but can live with something much simpler that has a similar effect?
Title: Re: Blur WITHOUT shader
Post by: Nafffen on May 14, 2023, 08:14:00 pm
Yes gaussian blur is the kind of result I would like, box blur could give also good result
Sorry to re-open the topic on the handle of shader with android, but can I wait for it or I really need to find another slotution with that ?
Title: Re: Blur WITHOUT shader
Post by: Hapax on May 15, 2023, 09:22:17 pm
I guess drawing the same thing multiple times at slight offsets with a lower opacity (or darker with addition) wouldn't suffice? Seems a bit of an intensive way to do it :(



Another option, however, is to draw a lower resolution version scaled up (and smoothed).

You could use either a lower resolution texture or draw the full resolution texture scaled down on a render texture and then draw that scaled back up.

Of course, remember to turn on texture smoothing.


EDIT:
Here's an example of a test I just made for you :) :
(https://i.imgur.com/JTNYUKa.png)
Here, the right-side sprite is drawn to a render texture at an 1/8th of its size and then scaled back up with texture smoothing and drawn to the left-side.
Title: Re: Blur WITHOUT shader
Post by: Nafffen on May 16, 2023, 04:05:30 pm
Oh yes I didn't think about that !
Thank you for the little example I am going to try this  :D
Title: Re: Blur WITHOUT shader
Post by: Hapax on May 16, 2023, 08:29:01 pm
Hope it goes well for you!

Remember it's really just pixelation with smoothing so it's quite boxy but it is blurry, I guess ;D