Skip to content

Woohyun-Kang/Sharp-Shimmerless-Shader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Sharp-Shimmerless-Shader

A Sharp, Shimmering-free Shader for RetroArch

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.

Existing Solutions and Their Limitations

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.

Interpolating Pixels as Rectangles

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!

Subpixel Shaders

rgb and bgr shaders are for horizontal subpixel layouts, and vrgb and vbgr shaders are for vertical subpixel layouts. It supports subpixel rendering by offsetting positions of output pixels per each color.

About

A Sharp, Shimmering-free Shader for RetroArch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages