Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

Tile Drawing not looking right..

This topic is 4474 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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??

Share this post


Link to post
Share on other sites
Advertisement
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#?

Share this post


Link to post
Share on other sites
here's the draw routine


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[][]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!