Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Transformation vs. stretched buffer - image quality

This thread is locked; no one can reply to it. rss feed Print
Transformation vs. stretched buffer - image quality
Frank Drebin
Member #2,987
December 2002
avatar

When I found this article
https://wiki.allegro.cc/index.php?title=Achieving_Resolution_Independence
I tested both approaches - using a stretched buffer and using transformations - in a simple test program that draws a line and shows an image. I noticed a difference in image quality of the results (see attachement). When using transformations the edges look quite a bit smoother compared to the result using a stretched buffer. Any ideas?

Audric
Member #907
January 2001

As the article says, transformation is best if your game mostly uses primitives (lines, rectangles...)
From looking a screenshot you may think it's also better visual quality for sprite, but in an actual game it will cause graphical artifacts which are sometimes jarring.
The issue accurs when several sprite bitmaps are supposed to be exactly side-to-side (sokoban player pushing a crate) or overlayed ("damaged variant" of a building, landscape composed of several layered images...) There will be a 1-pixel inaccuracy, and it's very visible if things are scrolling/rotating/zooming as the elements will "float" within a 1-pixel distance of the ideal position, instead of staying stuck together.

Stretched buffer doesn't have this issue because integers match exactly the coordinates and sizes of elements in the original referential, so the computations are pixel-perfect.

3D rendering systems don't have this issue because the system will keep track of all coordinates with decimal precision, and takes the entire scene into account when rasterizing.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Frank Drebin
Member #2,987
December 2002
avatar

Edgar, I tried adding these flags, however, the image looks more blurry then but not as nice as with the transformation (see attachement #2). Maybe there is a hidden filter applied when transformations are used?

Audric, I did not know that. In fact I found for example this thread where it sounds like people actually prefer transformations over a stretched buffer because it is less GPU/memory intense because the GPU will do scaling anyway. But if you say that this could yield in a 1-pixel inaccuracy this would be a big disadvantage (at least for me) :o

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Frank Drebin
Member #2,987
December 2002
avatar

OK guys thanks for your help. I found that pixel inaccuracy may occur indeed (see attachment #3) when using transformation (especially non-integer scaling) so I think I'm gonna stick with the stretched buffer... 8-)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Transformations only affect the underlying data. If your vertices are off, there's nothing you can do. There should not be a conflict between using transformations and drawing textures. How do you think all those 3D games are super seam less and all that? There's something else going on.

EDIT
I seem to recall that al_draw_scaled_bitmap uses a transform underneath it all anyway, so you're doing the exact same thing.

Frank Drebin
Member #2,987
December 2002
avatar

OK this makes sense indeed...

I'll try to figure out where that 'inaccuracy' may come from...

Go to: