意外的结果实施Libgdx简单的运动模糊 [英] Unexpected results implementing simple motion blur in Libgdx

查看:233
本文介绍了意外的结果实施Libgdx简单的运动模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这两个附加的图片中,libgdx功能的桌面截图预期。从我的Galaxy Nexus的屏幕截图是不幸的是并不如预期。我试图创建一个简单的运动模糊或追踪效果。

渲染如我所料我的桌面上。

不呈现如我所料对我的Galaxy Nexus的。

圆纹理渲染过程中绘制一个for循环,效果是实现了与使用0的RGBA,0,0像素映射,0.1F是圆之前绘制。

screenClearSprite创作

 像素图screenClearPixmap =新的像素图(256,256,Format.RGBA8888);
screenClearPixmap.setColor(Color.rgba8888(0,0,0,0.1F));
screenClearPixmap.fillRectangle(0,0,256,256);
screenClearTexture =新的纹理(screenClearPixmap);
screenClearSprite =新的Sprite(screenClearTexture);
screenClearSprite.setSize(屏幕宽度,screenHeight);
screenClearPixmap.dispose();
 

渲染

  batch.begin();
font.draw(批次fps的:+ Gdx.graphics.getFramesPerSecond(),0,20);
screenClearSprite.draw(批);
的for(int i = 0; I< circleBodies.size();我++){
    tempPos = circleBodies.get(ⅰ).getPosition();
    batch.draw(circleTexture,(tempPos.x * SCALE)+ screenWidthHalf
             -  circleSizeHalf,(tempPos.y * SCALE)+ screenHeightHalf
             -  circleSizeHalf);
}
batch.end();
 

所以,我做了什么错?也许有一个更好的方式来获得运动的运动模糊效果?

解决方案
  

也许有一个更好的方式来获得的运动模糊效应   运动?

为了使运动模糊在我的游戏我用另一种approch的粒子效果它工作真的我没问题,我没有安卓/桌面的问题或与不同的Andr​​oid设备

所有你需要做的就是用Libgdx的粒子效果编辑器,让你的效果,然后将其加载您的项目终于在同一位置绘制你画你的对象(和ALOS绘制的对象)

提示做出正确的效果文件Paticle编辑:

  • 设置(使用)的对象要进行模糊处理的粒子效果的运动相同的图像

  • 尽量限制在计数:颗粒的最大数量允许

  • 禁用速度和角 参数

粒子效果帮助做运动的影响 希望这将帮助别人!

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 create a simple motion blur or trail effect.

Rendering as I expected on my desktop.

Not rendering as I expected on my Galaxy nexus.

The circle textures are drawn in a for loop during rendering and the effect is achieved with a pixmap using the RGBA of 0, 0, 0, 0.1f that is drawn before the circles.

screenClearSprite creation

Pixmap screenClearPixmap = new Pixmap(256, 256, Format.RGBA8888);
screenClearPixmap.setColor(Color.rgba8888(0, 0, 0, 0.1f));
screenClearPixmap.fillRectangle(0, 0, 256, 256);
screenClearTexture = new Texture(screenClearPixmap);
screenClearSprite = new Sprite(screenClearTexture);
screenClearSprite.setSize(screenWidth, screenHeight);
screenClearPixmap.dispose();

Render

batch.begin();
font.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond(), 0, 20);
screenClearSprite.draw(batch);
for (int i = 0; i < circleBodies.size(); i++) {
    tempPos = circleBodies.get(i).getPosition();
    batch.draw(circleTexture, (tempPos.x * SCALE) + screenWidthHalf
            - circleSizeHalf, (tempPos.y * SCALE) + screenHeightHalf
            - circleSizeHalf);
}
batch.end();

So, what did I do wrong? Perhaps there is a better way to get the 'motion blur' effect of movement?

解决方案

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 !

这篇关于意外的结果实施Libgdx简单的运动模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆