Posted by: EvilNando | July 16, 2008


If you happen to be into graphics programming you will know for sure that a pixel is indivisible , heck even if youre not into graphics programming you probably have realized that as well ( for example you cannot set your monitor’s resolution to 800.5 x 600.5 )

Ive always knew this as well, as a result when I have to deal with drawing to the screen I always stick to int (Int32) for assigning screen coordinates

But Ive learned from the internet that when you setup a camera component you should create one that manages float values, why? I dont know I just follow (if it works)

as you can see here is a clear example of what I’m talking about.

If you take the time to look around this example you will find that the camera component works on floating point values.

So when the time to implement a camera system into my game project came around I followed what Ive learned and implemented a floating point camera system as well, if I only knew the trouble that this would get me in:


My engine on a first glance appeared to render the scene correctly but as soon as I started to move the camera around I started to get the artifacts shown in the picture above.

I tried many many things to solve this problem, at first I thought it had to do with my tilesheet texture , I thought that not having a separation between tile and tile was the source of all problems.

So I spended the entire morning coding so that my tile editor could write a new texture, a texture that had each of its tiles separated by a margin (while harcoded this was variable and could be set to any Int32 number without problems)

so I tried with 1px of separation:

texture generator

The artifacts where still there so I tried a 2px gap and nothing!, well a 32px gap HAD to do it!


even with 32px gap the artifacts where still THERE!

After spending the whole day making editor features and some other crazy stuff (like texture wrapping inside the graphicsdevice) I just started to analize the problem and the thing that made me solve the entire problem what when I realized that the problem triggered ONLY WHEN MOVING THE CAMERA

I went back to the camera code and saw this many float and vector2 variables that were in charge of handling the camera’s coordinates, It was then that I remembered THE PIXEL

“How the hell I can move 0.0001 pixels in a render tick?” I said , of course it was impossible so I quickly changed all this stuff into Int32’s and BAM everything was smooth an easy

But at the end I was happy because I ended implementing a new (useless) feature into the editor and learned something as well



  1. Late comment, but I find the progress in your project interesting, so I’m curious about old posts aswell! 🙂

    The reason why cameras use floating point is smooth movement and making slow movement possible.
    When rendering, you’ll round the coordinates of the camera for the drawing routine (as a pixel is indivisible).
    However, if your camera moves with a movement speed of 0.5 to the right, it will never actually move if you use integers, so use floats internally 🙂

  2. gesehen

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: