Tile Drawing not looking right..
That's a screen shot. As you can see, you can clearly tell where the tiles are due to that annoying lines separating them... That only happens when i have the whole map move, but when it's stationary it's fine... is there a reason for this?? maybe a setting i can set??
Can you provide a little more information(maybe a snippet of code) as to how you are loading/drawing your texture? Are your tiles extracted from a tileset image? Are each tiles from the set separated by a 1 pixel border?
Are you developing your game using C++ or C#?
Are you developing your game using C++ or C#?
here's the draw routine
i'm extracting each tile from a tileset image loaded and the data for each tile is in the 2d variable m_TileData[][]
for (unsigned long i=0 ; i<m_lLayerRow ; i++) { for (unsigned long j=0 ; j<m_lLayerCol ; j++) { // Top-right glTexCoord2d(((m_TileData[j] % m_lTexCol + 1) * m_lFrameWidth * 1.0f) / texwidth, ((m_TileData[j] / m_lTexCol) * m_lFrameHeight * 1.0f) / texheight); glVertex3f(((float)j + 1.0f) * width, -(float)i * height, 0.0f); // Top-left glTexCoord2d(((m_TileData[j] % m_lTexCol) * m_lFrameWidth * 1.0f) / texwidth, ((m_TileData[j] / m_lTexCol) * m_lFrameHeight * 1.0f) / texheight); glVertex3f((float)j * width, -(float)i* height, 0.0f); // Bottom-left glTexCoord2d(((m_TileData[j] % m_lTexCol) * m_lFrameWidth * 1.0f) / texwidth, ((m_TileData[j] / m_lTexCol + 1) * m_lFrameHeight * 1.0f) / texheight); glVertex3f((float)j * width, -((float)i + 1.0f) * height, 0.0f); // Bottom-right glTexCoord2d(((m_TileData[j] % m_lTexCol + 1) * m_lFrameWidth * 1.0f) / texwidth, ((m_TileData[j] / m_lTexCol + 1) * m_lFrameHeight * 1.0f) / texheight); glVertex3f(((float)j + 1.0f) * width, -((float)i + 1.0f) * height, 0.0f); } }
i'm extracting each tile from a tileset image loaded and the data for each tile is in the 2d variable m_TileData[][]
If you have texture filtering turned on it uses texels outside the tile, I had same fragments in lightmap. Try to "correct" UV coordinates.
original coords:
U[x1, x2]
V[y1, y2]
correction:
correct_value = 0.01f
U[x1+correct_value, x2-correct_value]
V[y1+correct_value, y2-correct_value]
experiment with correct_value, to get best result.
I hope that will help.
original coords:
U[x1, x2]
V[y1, y2]
correction:
correct_value = 0.01f
U[x1+correct_value, x2-correct_value]
V[y1+correct_value, y2-correct_value]
experiment with correct_value, to get best result.
I hope that will help.
there has to be some way of fixing it with a specific thing, i don't want to have to estimate.. i want something exact..
While ladik-BigBoss's explaination is about right, the actual implementation leaves something to be desired.
What you need to do is pull the texture coords 'inwards' towards the center of the tile by half a texel, so that the filtering doesn't interpolate to values outside of the actual tile.
The size of a texel for any given texture is:
texelWidth = 1f / textureWidth;
texelHeight = 1f / textureHeight;
What you need to do is pull the texture coords 'inwards' towards the center of the tile by half a texel, so that the filtering doesn't interpolate to values outside of the actual tile.
The size of a texel for any given texture is:
texelWidth = 1f / textureWidth;
texelHeight = 1f / textureHeight;
You can't use texture clamping if you're storing multiple tiles in a single texture atlas. Texture clamping only applies to the outside edge of a texture.
Quote:Original post by OrangyTang
You can't use texture clamping if you're storing multiple tiles in a single texture atlas. Texture clamping only applies to the outside edge of a texture.
Oh sorry. Didn't see that.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement