libgdx tiledmap闪烁与最近的过滤 [英] libgdx tiledmap flicker with Nearest filtering

查看:456
本文介绍了libgdx tiledmap闪烁与最近的过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个平铺的地图上有一个奇怪的文物,滚动的相机夹在播放器(谁是一个box2d身体)。



在得到这个问题之前,我使用了tiledmap的线性过滤器,防止这些奇怪的工件发生,但导致纹理出血(我直接从.tmx文件加载tiledmap没有填充瓦片)。



但现在我使用最近的过滤器,而不是排除出血,但当滚动地图(通过走字符与凸轮夹对他)它接缝像很多像素闪烁。闪烁的结果可以变得更好或更差,取决于相机的缩放值。
但是当我使用libgdx-Utilities中的OrthoCamController类时,它允许通过用鼠标/手指滚动来滚动地图,我根本不会得到这些工件。
我假设闪烁可能是由box2d-Body的位置接收到的错误的摄像机位置值引起的。
我应该添加一件事:游戏实例运行在1280 * 720显示模式,而我的游戏机只渲染800 * 480。文件我改变了gamecam的渲染到1280 * 720我不会得到那些文物,但然后瓦片太小了。



有人遇到这个问题或知道如何解决这个问题? :)

解决方案

我有一个类似的问题,发现这是由于相机的十进制值太小位置。



我想可能发生的是在tilemap渲染器中某些瓦片列/行的舍入。



我通过四舍五入到设定的精度修正这个问题,如下:

  camera.position.x = Math.round (player.entity.getX()* scalePosition)/ scalePosition; 

尝试各种值,但我使用tile size作为scalePosition值。 / p>

I am having strange artifacts on a tiledmap while scrolling with the camera clamped on the player (who is a box2d-Body).

Before getting this issue i used the linear filter for the tiledmap which prevents those strange artifacts from happening but results in Texture bleeding (i loaded the tiledmap straight from a .tmx file without padding the tiles).

However now i am using the Nearest filter instead which gets rid of the bleeding but when scrolling the map (by walking the character with the cam clamped on him) it seams like a lot of pixel are flickering around. The flickering results can get better or worse depending on the cameras zoom value. But when I use the "OrthoCamController" class from the libgdx-Utilities which allows to scroll the map by panning with the mouse/finger i don't get these artifacts at all. I assume that the flickering might be caused by bad camera-position values received by the box2d-Body's position. One more thing i should add here: The game instance runs in 1280*720 display mode while my gamecam renders only 800*480. Wen i change the gamecam's rendersolution to 1280*720 i don't get those artifacts but then the tiles are way too tiny.

Has anyone experienced this issue or knows how to fix that? :)

解决方案

I had a similar problem with this, and found it was due to having too small a decimal value for the camera position.

I think what may be happening is some sort of rounding with certain tile columns/rows in the tilemap renderer.

I fixed this by rounding to a set accuracy, like so:

camera.position.x = Math.round(player.entity.getX() * scalePosition) / scalePosition;

Experiment with various values, but I got it working by using the tile size as the scalePosition value.

这篇关于libgdx tiledmap闪烁与最近的过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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