Texture Bleeding With Celled Image maps
by Ray Gebhardt · in Torque Game Builder · 03/06/2005 (12:32 pm) · 7 replies
I have ran into an issue where i get a weird video artifact with tilemaps. I am getting these weird bars and lines on the edges of tiles. I have also tested the fxStaticSprite2D and it also has the same rendering problem. You can look at a screenshot of the issue at www.phillyband.com/images/tilemapIssue.png .
Basically I have a celled image map that I am using for tiles in a map layer. There is no spacing between tiles, because they have to be flush with each other in the game. The actual image file and datablock for the image map were triple checked for accuracy.
It looks like a texture bleeding issue to me, but but of course i didn't look at the code to make sure. I had the same problem with my own 2D engine i made about 6 months back. I used texture coordinates to select which tile I would want to render in my engine. The problem is I had, was if the tiles were tightly packed, they would always "bleed" over to the other tile.
I did research this a little on the net, trying to figure out a good solution to it. If you adjust the texture coordinates slightly, you can usually get the bleeding to go away. The problem with doing it that way, is it can cause some other rendering artifacts (like one lines of pixels in the tile may be squashed a little).
There was another technique that I read about that seemed interesting. Essentially what you do, is break up the image maps into separate textures. Each cell would have its own texture. Now if you render that newly generated texture, there will be no bleeding artifacts.
I know I could work around this rendering issue, by using a separate image for each tile. I would still have some issues doing animated tiles though. In addition I am not sure if there is a way to work around this issue for sprites.
Basically I have a celled image map that I am using for tiles in a map layer. There is no spacing between tiles, because they have to be flush with each other in the game. The actual image file and datablock for the image map were triple checked for accuracy.
It looks like a texture bleeding issue to me, but but of course i didn't look at the code to make sure. I had the same problem with my own 2D engine i made about 6 months back. I used texture coordinates to select which tile I would want to render in my engine. The problem is I had, was if the tiles were tightly packed, they would always "bleed" over to the other tile.
I did research this a little on the net, trying to figure out a good solution to it. If you adjust the texture coordinates slightly, you can usually get the bleeding to go away. The problem with doing it that way, is it can cause some other rendering artifacts (like one lines of pixels in the tile may be squashed a little).
There was another technique that I read about that seemed interesting. Essentially what you do, is break up the image maps into separate textures. Each cell would have its own texture. Now if you render that newly generated texture, there will be no bleeding artifacts.
I know I could work around this rendering issue, by using a separate image for each tile. I would still have some issues doing animated tiles though. In addition I am not sure if there is a way to work around this issue for sprites.
#2
03/06/2005 (1:04 pm)
I can't help with the issue... just wanted to say that that knight is freaking adorable.
#3
03/06/2005 (1:09 pm)
Yeah my artist is amazing. You should see what the knight looks like with all his animations ;). Is there a way to set the filtering type from script? or is it something I will need to do in C++?
#4
fxImageMapDatablock2D.cc - Line 135
I just added the last line in the code above. Now like I said it does work, but there are still a few issues. The first is that if the a tile or sprite is scaled up or down to any extent, it looks really ugly (like this screenshot www.phillyband.com/images/nearestFiltering.png. Its even more noticable when the graphics are in motion.
Another issue is that I had to disable antialiasing on my video card. I know that is a given, but my users might just load the demo for my game and say "this sucks" before considering that they need to disable those features on their card.
The last issue, is that every once in a while, I would get a blink of the bleeding textures. That last issues is probably just a bug in my video driver though, so its not that big of a deal.
03/06/2005 (1:59 pm)
I tried that, and it did work. I did the following:fxImageMapDatablock2D.cc - Line 135
// Load Texture. mImageMapTextureHandle = TextureHandle( mTextureName, BitmapKeepTexture, true ); mImageMapTextureHandle.setFilterNearest();
I just added the last line in the code above. Now like I said it does work, but there are still a few issues. The first is that if the a tile or sprite is scaled up or down to any extent, it looks really ugly (like this screenshot www.phillyband.com/images/nearestFiltering.png. Its even more noticable when the graphics are in motion.
Another issue is that I had to disable antialiasing on my video card. I know that is a given, but my users might just load the demo for my game and say "this sucks" before considering that they need to disable those features on their card.
The last issue, is that every once in a while, I would get a blink of the bleeding textures. That last issues is probably just a bug in my video driver though, so its not that big of a deal.
#7
03/06/2005 (7:32 pm)
Heh...not quite...I have a Trinitron across the room though ;).
Torque 3D Owner Pat Wilson