Messy Tilemaps & alternatives to 1Tile : 1File
by Bob Dobbs · in Torque X 2D · 11/19/2010 (12:39 am) · 11 replies
I've been searching extensively on the forums all last night and today about the "lines" or "artefacts" that appear on tilemaps and at a bit of a loss as what to try next...Think a few have you have been throuigh this one so would appreciate your knowledge and wisdom on this one.
As they say a picture paints a thousand words, but a video paints a million.
In brief 1280X720 camera, topdown (slightly off about 80 degrees) with 326X326 animated sprites running round a tile map made up of 200X200 images (bit too big perhaps, tried 100's but just not getting the "look" I want). If you have a look at the video, planned on doing floors as "flat tilemaps" as well as "outer walls" then make "inner walls" as static sprites (so as with sort order I can hide behind walls, etc)
Strangely, the first tilemap I ever made I just took a 2D render of a 3D scene I made, cut it up into 100X100 slices, mapped it and it worked beautifully (maybe because the colours were quite muddy and dark the artefacts were unnoticeable). Now attempting to make a "building" with its inside and outside via tilemaps running into lots of problems like those listed in these threads-
Tile rendering lines - Tried the VSOutput SimpleVS edit, tidied up things a wee bit but still lingering "lines" or occasional "scraps" on movement....
Problem with image maps(solved) - Similar to above, but also gave the Matrix TranslationMatrix edit a go with the VSOutput, no dice. Hadnt tried Chris Perkin's "shader" as not sure exactly what's being done, plus material revert back to "simple material making it troublesome in the editor ><
TorqueX 2D Tilemap artifacts- Pretty similar to above but concludes similar to the above 2 threads with the "1 tile:1 file" recommendation, which for me I'm envisioning I will need 300 plus tiles for roads, paths,flooring, grass, pavements which could get darned heavy in the editor.
Anyone ever come up with workarounds or any thoughts ?
As they say a picture paints a thousand words, but a video paints a million.
In brief 1280X720 camera, topdown (slightly off about 80 degrees) with 326X326 animated sprites running round a tile map made up of 200X200 images (bit too big perhaps, tried 100's but just not getting the "look" I want). If you have a look at the video, planned on doing floors as "flat tilemaps" as well as "outer walls" then make "inner walls" as static sprites (so as with sort order I can hide behind walls, etc)
Strangely, the first tilemap I ever made I just took a 2D render of a 3D scene I made, cut it up into 100X100 slices, mapped it and it worked beautifully (maybe because the colours were quite muddy and dark the artefacts were unnoticeable). Now attempting to make a "building" with its inside and outside via tilemaps running into lots of problems like those listed in these threads-
Tile rendering lines - Tried the VSOutput SimpleVS edit, tidied up things a wee bit but still lingering "lines" or occasional "scraps" on movement....
Problem with image maps(solved) - Similar to above, but also gave the Matrix TranslationMatrix edit a go with the VSOutput, no dice. Hadnt tried Chris Perkin's "shader" as not sure exactly what's being done, plus material revert back to "simple material making it troublesome in the editor ><
TorqueX 2D Tilemap artifacts- Pretty similar to above but concludes similar to the above 2 threads with the "1 tile:1 file" recommendation, which for me I'm envisioning I will need 300 plus tiles for roads, paths,flooring, grass, pavements which could get darned heavy in the editor.
Anyone ever come up with workarounds or any thoughts ?
#2
Your tilemap artifacts are due to your tiles not being aligned with pixel boundaries in the game world. When you move the player around the game world it can move in sub-pixel amounts. The shader will then sample pixels and average them out - at the edges of the tile image this will mean sampling part of the sprites from a neighbouring tile image in the spritesheet.
To avoid this you either need one tile per file, or constrain the world movement to whole pixels (and optionally change the shader to point sampling[1]).
[1] scenes will always revert to using simple material when saved in the editor so you need to set it in code.
11/19/2010 (1:16 pm)
torque x does not have built in support for keyed sprite sheets.Your tilemap artifacts are due to your tiles not being aligned with pixel boundaries in the game world. When you move the player around the game world it can move in sub-pixel amounts. The shader will then sample pixels and average them out - at the edges of the tile image this will mean sampling part of the sprites from a neighbouring tile image in the spritesheet.
To avoid this you either need one tile per file, or constrain the world movement to whole pixels (and optionally change the shader to point sampling[1]).
[1] scenes will always revert to using simple material when saved in the editor so you need to set it in code.
#3
11/20/2010 (12:58 am)
Quote:torque x does not have built in support for keyed sprite sheets.Works for static and tilemaps at least, but haven't tried any animation with it. The way the texture splitter works is just rects and the splitting of the keyed image is done by the editor. However, it's not too well documented and the editor doesn't have support for using said frames in an animation.
#4
Re KEY - rather than use image mode key I just used Cell instead to achieve similar effect.It would be "nice" to have Key image mode but seems like a lot of extra work when I can just organise a cells into similar shapes and sheets.
It's really bizarre that in my first ever tile map (shown at the end of the video) I didn't get any artefacts or scraps at all; Could it be that it was because the tile size was smaller (100x106)? Quite strange dont you agree ? or perhaps this is due to the "muddiness" of the tilemap ?
I'm a bit shocked at the 1tile:1file "limit"; I had been preparing lots of "atlas" tile sheets for my scenery without implementing so far and now as I start noticing all the scraps and lining is a bit of a downer.
@Chris you said you had over come this problem with a shader in this post ?www.torquepowered.com/community/forums/viewthread/89999 how exactly did you implement this ? Is this within the core source ? I don't really understand how or where you would set this shader technique, would be very grateful if you coudl elaborate a little !
11/20/2010 (6:40 am)
@Duncan "constrain the world movement to whole pixels"... So unless I was moving my camera or player at a ratio as per the tile maps (ie by steps of 200) I would get scraps yes ? or do you mean something else ? how would I constrain "movement to whole pixels" ?Re KEY - rather than use image mode key I just used Cell instead to achieve similar effect.It would be "nice" to have Key image mode but seems like a lot of extra work when I can just organise a cells into similar shapes and sheets.
It's really bizarre that in my first ever tile map (shown at the end of the video) I didn't get any artefacts or scraps at all; Could it be that it was because the tile size was smaller (100x106)? Quite strange dont you agree ? or perhaps this is due to the "muddiness" of the tilemap ?
I'm a bit shocked at the 1tile:1file "limit"; I had been preparing lots of "atlas" tile sheets for my scenery without implementing so far and now as I start noticing all the scraps and lining is a bit of a downer.
@Chris you said you had over come this problem with a shader in this post ?www.torquepowered.com/community/forums/viewthread/89999 how exactly did you implement this ? Is this within the core source ? I don't really understand how or where you would set this shader technique, would be very grateful if you coudl elaborate a little !
#5
Pixel alignment: no, not steps of 200 - just whole pixels at a time.
11/20/2010 (1:17 pm)
If the adjacent images in the sprite sheet have similar edges then you won't see much artifacting as the oversampling will just be sampling similar texels anyway. That might be why your original worked. It's also something to bear in mind when laying your images out in the spritesheet.Pixel alignment: no, not steps of 200 - just whole pixels at a time.
#6
11/20/2010 (3:03 pm)
How would one restrict world movement to whole pixels at a time ?
#7
looks like it would do the trick or at least start you off in the right direction. In this case it's not movement that is fixed to whole pixels, but the positioning of scene objects; same end result - the textures render on whole pixel boundaries (assuming the objects' width and height are even numbers).
11/20/2010 (10:46 pm)
http://www.torquepowered.com/community/forums/viewthread/89999/1#comment-610145looks like it would do the trick or at least start you off in the right direction. In this case it's not movement that is fixed to whole pixels, but the positioning of scene objects; same end result - the textures render on whole pixel boundaries (assuming the objects' width and height are even numbers).
#8
I already gave that a stab, I've been messing around with different settings in the T2DSceneObject core and different tilemaps, just seems the type of map I'm using (lots of transparency) will cause a lot of bleeding; just sticking to Static sprites for walls and using better organised tilemaps for "flat" floor-y type surfaces. Not a perfect solution but seems "so-so"
Still curious as to where and how Chris P was implementing that shader tho
11/22/2010 (4:37 am)
Thanks !I already gave that a stab, I've been messing around with different settings in the T2DSceneObject core and different tilemaps, just seems the type of map I'm using (lots of transparency) will cause a lot of bleeding; just sticking to Static sprites for walls and using better organised tilemaps for "flat" floor-y type surfaces. Not a perfect solution but seems "so-so"
Still curious as to where and how Chris P was implementing that shader tho
#9
11/22/2010 (12:28 pm)
If your objects are pixel aligned and displayed at their native resolution then texture bleeding would not be an issue.
#10
I promise to take a closer read later.
11/22/2010 (4:53 pm)
Note: I'm sitting in a meeting at my day job, please forgive the fact that I haven't had time to read all of the above, but I had a similar problem in TGB/iTGB and wonder if maybe you have smoothing enabled in your imagemaps. If so, the edges of your images will get 'corrupted'.I promise to take a closer read later.
#11
Which reminds me: @Hoddie another way to do it is to have a one pixel border around yr images within the spritesheet and combine that with a custom material divider that knows about the one pixel border. That way when the edges are sampled beyond the edge of the tile's image it will just be sampling the same pixels so there won't be any bleed issues. (you could create a content pipeline processor to build the pixel borders automatically)
11/22/2010 (6:57 pm)
There's no smoothing setting in Torque X and no border option either.Which reminds me: @Hoddie another way to do it is to have a one pixel border around yr images within the spritesheet and combine that with a custom material divider that knows about the one pixel border. That way when the edges are sampled beyond the edge of the tile's image it will just be sampling the same pixels so there won't be any bleed issues. (you could create a content pipeline processor to build the pixel borders automatically)
Torque 3D Owner Bob Dobbs
13th Hour Studios
I was looking at the adventure kit and platformer kit graphic resources as my game is "semi" isometric and utilising a bit of both.Quite intrigued by the "key" image mode used in Adventure kit but try as I might I cant seem to get "key" images setup, looked up a few tuts on the manual and boards but to no avail, is Key image mode for materials working ok for TX ?
Ideally I would like to stick with tilemaps for the majority of the level design as worked out a good 3d Model -> 2D Render-> slice n dice -> to tilemap workflow