Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Blur WITHOUT shader  (Read 1904 times)

0 Members and 1 Guest are viewing this topic.

Nafffen

  • Newbie
  • *
  • Posts: 20
    • View Profile
Blur WITHOUT shader
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Blur WITHOUT shader
« Reply #1 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nafffen

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Blur WITHOUT shader
« Reply #2 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 ?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Blur WITHOUT shader
« Reply #3 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 :) :

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.
« Last Edit: May 15, 2023, 10:38:14 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Nafffen

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Blur WITHOUT shader
« Reply #4 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

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Blur WITHOUT shader
« Reply #5 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*