2
\$\begingroup\$

I was working on a game in MonoGame, which I have been doing for quite some time now. As I was implementing UI, I was noticing some sort of weird scanlines. Investigating further, to my surprise my whole scene was covered in it!

Issue

Notice how the texture when zoomed in has almost a JPEG squared compressed feel too it. I have no idea what is causing this.

We were using a RenderTargetTexture instead of the backbuffer, so figured I try it without, but the same happens. I checked if we were doing any weird Matrix transformations, we did not, in fact, I disabled them just to test it out. After that I thought "half pixel offset" (even though it should not really apply anymore post DX9), but also that did not solve a thing. Last but not least I thought maybe a MipMapping issue, but that would be weird since the exact same thing happens with the normal backbuffer.

My Question: Does anyone here recognize this "effect", and have any clue what might be causing it?

I'm basically just rendering a 1920x1080 image to a 1920x1080 backbuffer, but I can assure its not the image. When I for example draw a cursor and make it follow the mouse, the points where pixels "go missing", even the cursor texture deforms.

Issue

Might not be as clear in this picture, but notice how both the cursor and the orange curve basically "skip" a row of pixels, when I move the cursor to another location, it turns back to normal.

\$\endgroup\$
3
  • \$\begingroup\$ Another things that crossed my mind was that I was maybe drawing textures a few pixels bigger than they were, pulling it out of proportions. But that does not make sense since the cursor, which is a 32x32 texture on the filesystem and also drawn as such, simply deforms when it gets near such a place on the screen. \$\endgroup\$ Apr 27, 2016 at 2:15
  • \$\begingroup\$ It looks like maybe you are doing non uniform scaling (different scaling on x and y axis) and that your are using nearest neighbor texture sampling. I'm not sure details of monogame but if you can use bilinear texture sampling, that ought to help things. \$\endgroup\$
    – Alan Wolfe
    Apr 27, 2016 at 3:49
  • \$\begingroup\$ @AlanWolfe Thanks! Not sure what I did last night, but without any scaling to the rendertarget, it did look normal after all. So I followed your lead and checked if our aspect ratio calculation for the rendertarget downscale was correct, and to my surprise, it was 2 pixels off! Meaning there was indeed a non-uniform scaling happening. After fixing that, the issue resolved itself. If you put your comment in an answer, I'll tag it as accepted :) \$\endgroup\$ Apr 27, 2016 at 20:13

1 Answer 1

2
\$\begingroup\$

It looks like the issue is that you are doing non uniform scaling (different scale on x and y axis) and using nearest neighbour texture sampling.

If you switch to using uniform scaling and/or bilinear texture sampling (or better, like bicubic) the problem should go away.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .