TMX AndEngineExample issue

  ... in the unlikely case you discovered a bug, post it here.

TMX AndEngineExample issue

Postby Kalagaraz » Tue Jul 27, 2010 5:27 pm

When running the TMXTileMap example from the andengineexamples on my droid X, black lines will flicker vertically between each tile when player is walking left and right, and will flicker horizontally between each tile when player is walking up and down.

I'd show you a video of it if I knew how to capture video from my phone.
Kalagaraz
 
Posts: 58
Joined: Tue Jul 20, 2010 4:46 pm

Re: TMX AndEngineExample issue

Postby Mimminito » Tue Jul 27, 2010 5:30 pm

You will have to use an actual Camera to video the application on your phone.
---------------------------------------
Adam Goodchild
Your AndEngine Forum Moderator!
My Tutorials List
http://www.adam-goodchild.co.uk
---------------------------------------
Mimminito
 
Posts: 360
Joined: Wed Jul 21, 2010 3:08 pm
Location: Chelsmford, UK

Re: TMX AndEngineExample issue

Postby Nicolas Gramlich » Tue Jul 27, 2010 5:39 pm

(I usually make the videos with another camera.)

Interesting, that example uses:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private static final int CAMERA_WIDTH = 480;
  2.         private static final int CAMERA_HEIGHT = 320;
Parsed in 0.012 seconds, using GeSHi 1.0.8.4

what means that on both the Droid X and my Nexus, the limiting size is the Height, what then means, exactly the same pixels are being drawn :|

I can assume the reason for this is the for rounding-issues or so when the texture is being drawn.
Unfortunately the background behind the TMXTiledLayers black, as the lines between the tiles of the TileSet:
Image

So could you do us a favor and run the same examples with this texture instead (simply replace it):
desert_tiled.png
desert_tiled.png (29.2 KiB) Viewed 2838 times


So we could see if this is the Background shining through or the or problem with the Textures. :)

Thanks in advance.

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: TMX AndEngineExample issue

Postby Kalagaraz » Tue Jul 27, 2010 6:07 pm

Yep pink lines show up when walking with the new image. Interestingly, it didn't do this when I ran it before you did the properties update.
Kalagaraz
 
Posts: 58
Joined: Tue Jul 20, 2010 4:46 pm

Re: TMX AndEngineExample issue

Postby Nicolas Gramlich » Tue Jul 27, 2010 6:41 pm

Erm... I actually didn't change anything of the drawing code. :roll:

So this is probably a little bug in the rounding of texture-coordinates. Very strange that it doesn't happen on my Nexus :(

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: TMX AndEngineExample issue

Postby badlogicgames » Tue Jul 27, 2010 7:49 pm

Hi,

this is not strange but depends on how filtering is implemented (which will differ from device to device) as well as whether you use a pixel perfect orthographic projection or a scaled one. Given the viewport dimension above i can see where the problem is, it's not a pixel perfect projection thus bi-linear filtering will kick in sampling the black edges of each tile. The solution is to offset the texture coordinates for each tile inwards by a pixel.

Mario
badlogicgames
 
Posts: 19
Joined: Sat Jul 10, 2010 5:27 pm

Re: TMX AndEngineExample issue

Postby Nicolas Gramlich » Tue Jul 27, 2010 8:46 pm

A full pixel or just a half pixel each side ?

Btw the "TextureOptions" used are GL10.GL_NEAREST, GL10.GL_NEAREST . I had read only GL_LINEAR would cause such problems. :?

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: TMX AndEngineExample issue

Postby badlogicgames » Wed Jul 28, 2010 1:29 am

Yes, nearest filtering should also solve the problem. If you already have nearest filtering (which will look like crap when zoomed in/out) you calculate the texture coordinates wrong. Probably by a small amount like one pixel.

When offseting use a complete pixel.
badlogicgames
 
Posts: 19
Joined: Sat Jul 10, 2010 5:27 pm

Re: TMX AndEngineExample issue

Postby Nicolas Gramlich » Wed Jul 28, 2010 5:07 pm

NEAREST filtering was already used in the Example.
While I assume that insetting a full pixel would have fixed this, I can't really imagine this is the perfect solution :? Or do you mean that an inset by a full pixel with the LINEAR-filtering wouldn't make us actually lose the outermost pixels :?:

Finally I was able to reproduce this on my Tattoo, by making the camera size 800x480 (5x more pixels that it actually has btw)

I didn't make a screenshot of this as it wouldn't have been to easy, because the lines were just flashing in "randomly".

I've seen a couple of things that might lead to a solution and tried most of them.
The change that lead to the biggest improvement is to make the camera only move to integer coordinates:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. new BoundCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT){
  2.         @Override
  3.         public void onApplyMatrix(GL10 pGL) {
  4.                 GLHelper.setProjectionIdentityMatrix(pGL);
  5.  
  6.                 GLU.gluOrtho2D(pGL, (int)this.getMinX(), (int)this.getMaxX(), (int)this.getMaxY(), (int)this.getMinY());
  7.         }
  8. };
Parsed in 0.011 seconds, using GeSHi 1.0.8.4

Doing this in addition with small inset of the texture-coordinates by sth small like 0.05 pixels makes the the lines completely disappear. See:
fixed_with_NEAREST_NEAREST.png
fixed_with_NEAREST_NEAREST.png (20.89 KiB) Viewed 2810 times


Without the small inset of the Texture it only showed when the player was moving upwards on the right:
fixed_with_NEAREST_NEAREST_without_texture_inset.png
fixed_with_NEAREST_NEAREST_without_texture_inset.png (23.2 KiB) Viewed 2810 times


When using LINEAR and a small inset, the lines visible all the time but at least not 100% black.
fixed_with_LINEAR_LINEAR.png
fixed_with_LINEAR_LINEAR.png (34.83 KiB) Viewed 2810 times


When using LINEAR and a inset of one full pixel, it also works, but as expected the result is significantly blurry. (Screenshot scaled up by 400%):
fixed_with_NEAREST_NEAREST_with_1px_texture_inset.png
fixed_with_NEAREST_NEAREST_with_1px_texture_inset.png (6.82 KiB) Viewed 2810 times


Obviously the inset of the texture can only be applied to the TMX-Layers, as other sprites with sharp 1px borders almost totally lose those borders.

I'm pretty much not with any of these solutions :(
Did I maybe do sth wrong or is there just no better solution to this :?:

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: TMX AndEngineExample issue

Postby Nicolas Gramlich » Wed Jul 28, 2010 8:36 pm

Ok, I looked up how the people with Cocos2D are handling this. Its as simple as it could be ... :lol:

Back when my tool is finished :)

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Next

Return to Bugs

Who is online

Users browsing this forum: No registered users and 7 guests