The Sharp-Shimmerless shader is a shader which guarantees minimum number of interpolated pixels, i.e., the sharpest rectangular pixels possible, while inducing NO aliasing/shimmering.
There already exist some attempts at achieving both sharp pixels and anti-aliasing, one of them being sharp-bilinear shaders. While they produce reasonably good image on modern high resolution screens, they fall apart on low-resolution screens often found in open-source handhelds.
Below is Cave Story, a 240p game, played on a 320p screen.
comparison.mp4 |
||
Sharp-Bilinear | Sharp-Shimmerless | Sharp-Bilinear-2x-Prescale |
Sharp-Bilinear shader on the left side results in a very blurry image. It is an expected behavior, since what sharp-bilinear shader does is integer pre-scaling followed by bilinear upscaling to screen - when scaling factor is less than 2, integer prescaling would do nothing. Sharp-Bilinear shader becomes a regular bilinear filter.
Sharp-Bilinear-2x-Prescale shader on the right side, at first glance, produces a nice-looking, sharp image. However, when the screen starts to scroll, you can notice vertical lines on the wall are badly shimmering. (Shimmering is also there on Sharp-Bilinear shader, but less noticeable due to the blurriness.)
It is a fundamental limitation for any kind of point sampling approach that it treats each pixel as a point with position but no area, whereas in retro gaming we want rectangular pixels.
Sharp-Shimmerless shader does not do any kind of point sampling, and instead treats input and output pixels as ideal rectangles, occupying each of their area on the grid that is screen.
It interpolates pixels based on how much area an input pixel would occupy on an output pixel.
- If an output pixel lies entirely on a single input pixel, there is no interpolation for the pixel.
- If an output pixel lies across multiple input pixels, the input pixels are interpolated proportionally to the area they occupy on the output pixel.
Hence, it achieves both minimal number of interpolated pixels and ideal anti aliasing, i.e. NO SHIMMERING!
Applies CRT-like curvature.
-curvature-grid
and curvature-scanlines
versions combines curvature and grid/scanline effects.
Applies grid or scanline effect.
-curvature-grid
and curvature-scanlines
versions combines curvature and grid/scanline effects.
-rgb
and -bgr
versions are for horizontal subpixel layouts, and -vrgb
and -vbgr
versions are for vertical subpixel layouts.
It supports subpixel rendering by offsetting positions of output pixels per each color.
Subpixel shaders need to sample input pixels three times per output pixel, and this could make them significantly slower than the basic shader.
This is the ideal way, but it requires four texture sampling per output pixel, making it slow.
All other versions leverage OpenGL bilinear filtering to interpolate colors in linear space in a single texture sampling.