Handmade Hero»Forums»Code
55 posts
Textured quadrilaterals - subpixel position
Edited by elle on
For a while I've been searching why there's a similar artifact in my version of the rendering code as in HH here Textured Quadrilaterals. For me, however, after introducing the code as Casey shows later in the video, it still had the same effect when slowly moving a texture in the y direction, with a horizontal line seemingly moving through the image.

Has anyone else noticed this too, or is this a bug in my version?
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Textured quadrilaterals - subpixel position
Hmm - if you're doing bilinear, you shouldn't generally see a line, although keep in mind that bilinear only helps you if you are scaling a texture between 0.5x and 2.0x because it only samples a 4-pixel square. So if you scale an image by more than that, you can easily get into a situation where you produce artifacts even though you are doing the bilinear properly.

- Casey
Livet Ersomen Strøm
163 posts
Textured quadrilaterals - subpixel position
elle


Has anyone else noticed this too, or is this a bug in my version?


No, it seems to me it should be perfectly smooth at "any" scale(1, 2, 3, 3.5,-5.5, 15, 25 tested) because it is always upscaling a "same fraction" proportional part of the sourcepixels, and smoothly maps it across all of the destpixels. Look at it this way: We are calculating a different _part_ of the 4 source-sub-pixels at EVERY destpixel. So as long as you got enough resolution(precicion), you should see a supersmooth image, that actually seems to not degrade much in quality, at even significant scale. If there is precision errors, or other stuff, you may see banding-like behaviour or "waves" moving over the image, or even pixelating. I had all of those until I got it right.

But note also I use an "integerlerp" and a lookup so my implementation is not the same. But that shouldn't give me any advantages. For the subpixel tu, tv I use floats.