Sign in to follow this  

Interpolation on tilemap causing float rounding errors

This topic is 3037 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

Simple as the title. When moving around in my game the player moves at 2.0f and even with interpolation on the tile map this is no problem. However at diagonals he moves roughly 1.414f (otherwise diagonals travel faster over distance before you suggest I remove that). On certain machines, mostly newer ones with higher fps, the tile map rips down the seams of the tiles revealing the black background that is the clear colour for rendering (so the tiles are rendering with a pixel wide gap). Only having moved diagonals it will possibly introduce this visible error and seems to me this happens only when moving. Removing interpolation seems to clear up the error. Intuition is telling me this is because the interpolation uses floats to take the maps position, maps velocity and interpolation at the point of drawing to come out with a smoother scrolling whatever your frame rate. It works this out and then simply translates using glTranslatef to exactly where it should be. My only current solution is to remove map interpolation and have it jitter. Does anyone have anything I could try?

Share this post


Link to post
Share on other sites
You should calculate the tile that is at point A, and render every other tile according to that. What I did to avoid any issues is to find Tile A (Top left of screen for me) and round to the nearest pixel and then I'd just move the position over or down X amount of pixels, where X is the dimension of the tile.

Share this post


Link to post
Share on other sites
Thanks for your reply

I had feared that was the case. I built it with opengls translate function in mind but I guess I'll have to do some jiggerypokery to get it going as you described

Share this post


Link to post
Share on other sites
Using glTranslatef for every tile is not a good idea, if that is what you are doing?
Instead create a grid of vertices for all the tiles, which will also remove this pixel gap problem.

Share this post


Link to post
Share on other sites
I dont use OpenGL, but for directx the sprite interface renders something based on screen position. Each one of my tiles is 64 pixels, so I calculate the top left one (usually off the screen mostly, except when moving up or to the left) and then loop through each tile, moving the position 64 pixels to the right or downward. This is pretty efficient so far, but there might be better ways of doing it.

I have no idea if OpenGL has anything like this, so I'm not sure if this was any help. Best of luck!

Share this post


Link to post
Share on other sites

This topic is 3037 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this