1
\$\begingroup\$

Shimmering

I understand shimmering in textures is caused by sub-pixel accuracy aliasing against the regular grid of pixels on the screen when drawn. I have a good example of it here, whereby I'm attempting to scroll/pan a 2d texture by modifying the texture coordinates rather than by moving some actual geometry. The texture is "wrapped" and my idea was to fill in the bit falling off the left (or right), filling it in on the other side, to effect a single scrolling/panning surface of (almost) infinite size.

Unfortunately with random noise on the texture, when I'm zoomed all the way out the shimmering is kind-of horrific. When I zoom in a bit it seems OK, which is kind-of confusing to me.

But anyway, is there a filter of some kind I can put into my shader to prevent this shimmering? I'm at something of a loss here.

(To complicate matters my texture is actually just L16 luminance and I'm palettising it in the shader - the L16 is sampled with LINEAR, the palette texture is POINT, though I'm pretty sure this makes little difference to the shimmering).

Please note that with the video, YouTube has done its absolute best to remove any detail from it, meaning it's difficult to see the shimmer under the encoding artifacts.

\$\endgroup\$
  • \$\begingroup\$ Why are you sampling with LINEAR? It interpolates nearby luma values which will cause weird things in your palette. This is probably the reason. Also, what is the result that you're looking for? \$\endgroup\$ – Mokosha Mar 5 '14 at 18:59
  • \$\begingroup\$ The luminance texture is sampled with linear, which is fine as the palette is sampled POINT. It shimmers regardless as I've tried it every which way. The issue I think is the sub-pixel shift during the scroll. What I want is a nice smooth scrolling/panning surface. I'm thinking perhaps I should generate some geometry (2 quads) and move those instead of shifting texture coordinates, swapping them over when one scrolls off screen. But I hoped there might be a filtering technique to help with the scrolling as this is the simpler method. \$\endgroup\$ – Robinson Mar 6 '14 at 10:01
1
\$\begingroup\$

The standard solution to this type of texture shimmer in games is mipmapping.

When you are zoomed out far enough that the source texels are smaller than your screen pixels, you start rendering from a scaled-down version of the source, which has had this excess high-frequency detail removed.

You can cover the transition with trilinear filtering, so the excess detail fades out smoothly instead of popping. (If your view is orthographic as in the example vid, then you shouldn't need anisotropic filtering)

GPUs support mipmapped textures natively, although I'd need to know a bit more about the environment you're working in to describe exactly how to enable them.

Using mipmaps also has performance benefits due to being friendlier on the texture cache.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Thanks Gregory. I don't have mipmaps and there would be some complexity involved in creating them. One thing I did notice is that because I was using random noise (unstructured), the eye had nothing to track when the screen scrolled. When I changed it to Perlin noise, even at quite high frequency, the scrolling looked perfectly smooth. So I think I might have discovered a psychological effect as well as a compute graphics one. My actual data will be semi-structured, i.e. there will be features in it, so I'm optimistic I won't need mips. \$\endgroup\$ – Robinson Mar 7 '14 at 10:21
  • \$\begingroup\$ A number of environments will let you auto-generate a mip chain when loading a texture, though they don't usually give control over the downsampling method. \$\endgroup\$ – DMGregory Mar 7 '14 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.