Unexpected results implementing simple motion blur in Libgdx

前端 未结 2 1156
误落风尘
误落风尘 2021-02-19 04:31

In the two attached pictures, the desktop screenshot of libgdx functions as expected. The screenshot from my Galaxy Nexus is unfortunately not as expected. I am attempting to cr

相关标签:
2条回答
  • 2021-02-19 05:07

    Here is a different approach, where you clear your screen each time with solid color and no alpha.

    This means that you will have to modify your code some. The good thing about this, is that the way you are doing it has some flaws: It will blur everything in motion, not just the balls. And can quickly produce ugly results/artefacts unless you are careful.

    1. Do the same as you are doing now, but instead of drawing the balls to the batch, draw them onto a texture/bitmap/whatever. Then each frame add an alpha-blended image over the balls-image, and then draw the balls in their current position on top of that. Then add that image to your screen. Very much like you are doing now, except you draw to something else and keep it. This way you don't have to rely on the viewport you are drawing onto, and can keep everything separated. This method is similar to drawing to an accumulation buffer.

    2. Instead of doing it the way you are doing, you can keep track of the n latest positions of each ball. And then draw all of them each frame, with different alpha. This is very easy to implement. Can result in many drawing calls if you have many balls or a large n, but if it's not too much it shouldn't limit your fps and gives nice control.

    0 讨论(0)
  • 2021-02-19 05:20

    Perhaps there is a better way to get the 'motion blur' effect of movement?

    in order to make motion blur in my game i use another approch "The particle effect" it works realy fine with me and i didn't have Android/Desktop problems or with different android devices

    all you have to do is to use "Particle Effect Editor" of Libgdx and make your effect then load it in your project finally draw it at the same position you draw your object (and alos draw your object)

    Tips to make the right effect file with Paticle Editor :

    • set (use) the same image of the object that you want to blur it motion in the particle effect

    • try to limit the count : the max number of particle allowed

    • Disable the "velocity" and "Angle" parameter

    Particle effect help to do motion effect Hope this will help someone !

    0 讨论(0)
提交回复
热议问题