Sub-pixel accuracy

What is sub-pixel accuracy – a very simplistic overview.

Sub pixel-accuracy is just that, values between individual pixels.

On a normal screen you’ll have your pixel grid:

Notice how your colors are aligned to the blocks in the grid. Now imagine this:

See how the red pixel is in the middle of (0, 1), (0, 2), (1,1), (1,2)? The position of that pixel is roughly (0.5, 1.5f) x (1.5f, 2.5f). That’s a sub-pixel. Now you’re saying, “but the screen isn’t divided into 0.5 pixels!” No, it’s not, that’s why Direct 3D has to do mapping between the texture-sub-pixel and the pixel data. And that is beyond the scope of this page. You can find out more about that from


And this is why…

Gorgon uses floating point values for drawing positioning and sizing. This is very helpful in making pixel by pixel motion appear very smooth instead of looking like your object is “jumping” between pixels. ┬áThere is a caveat however. Let’s define the first box with a size of (2,1) and the right with (2.125f, 1)

Notice that the second box has a fattened right edge? This is because it is being interpolated to the nearest pixel and thus you get some distortion (sizing values that are floating point values tend to suffer most from this). It’s an unfortunate artifact, but it can be corrected if you clamp the values to integer values. For example:

BoxSprite.SetSize((int)someFloatingPointSize.X, (int)someFloatingPointSize.Y);

This will correct the issue. However, you will lose sub-pixel accuracy in this case.


Another solution is the same as the sprite filtering solution, in that you can pad your sprite image with pixels that have an alpha component of 0.


Of course, if you have any better suggestions for dealing with this, you’re welcome to edit this page (especially if the terminology is incorrect or definitions are incorrect).

Leave a Reply