On RGB displays, subpixel rendering can be an interesting topic.
Here is a small sample picture, made small for your convenience (still 111 kilobytes).
No, don't zoom it, for it must be viewed at 1:1 pixel correspondance to the original image.
It contains the same scene twice. Each frame, it scrolls 1:3 pixels towards the left. The top part is rendered at subpixel precision; the bottom part is rendered at whole pixel precision.
At least on my TFT display, the top part (especially the ground) appears to scroll considerably smoother than the bottom part, without noticeable artifacts. (Wait for the file to load completely first!)
I was wondering about applications for this in NES emulator development.
- Subpixel-precise image scaling
- Rendering of NTSC artifacts at subpixel resolution
General information: Subpixel rendering is a tradeoff: It gives 3 x improved horizontal resolution, but because each subpixel is monochromous, it produces color artifacts. It works best when the subpixel details are whole pixel wide, only offseted, and relatively unsaturated (grayscale).
Train of thought: NES can render pixels at three subpixel positions. A pixel may be in its place, or shifted 1/3 pixels to the side, or 2/3 pixels to the side. Coincidentally, TFT has the same architecture. We can shift the entire screen losslessly sideways by 1/3 pixel increments! How about applying it for NTSC rendering?
Your thoughts?
Topic: Ultra-fast NTSC filtering.
Left: No subpixel rendering. Right: Yes subpixel rendering.
(Note: The rightside image appears to jitter more, because it brings more NTSC artifacts forth. The leftside image is 3x more aliased compared to the rightside one.)
EDIT: The pictures above were produced with a buggy algorithm. Below, fixed versions.
Left: No subpixel rendering; Middle: Subpixel interval 2 half-clocks; Right: Subpixel interval 2⅔ half-clocks.
Subpixel components are sampled as follows, depending on the subpixel interval:
Topic: Super Mario Bros. title screen, lanczos-scaled to proper aspect ratio.
Left: At 292x240. Right: At 876x240 (subpixel).
Topic: Same deal, Wizards & Warriors title screen.
Left: original title screen for comparison. Midde & right: The same title screen, shifted 1/3 and 2/3 pixels to the left respectively. Click here to see an animated progression of these three images.
It is easy to observe that the subpixel-scaled version does better job at capturing the sharpness of the original picture, but at the cost of some color artifacts at the edges of details.
Source code of ultra-fast NTSC filtering (old buggy versions: DgDsvnu6)
Here is a small sample picture, made small for your convenience (still 111 kilobytes).
No, don't zoom it, for it must be viewed at 1:1 pixel correspondance to the original image.
It contains the same scene twice. Each frame, it scrolls 1:3 pixels towards the left. The top part is rendered at subpixel precision; the bottom part is rendered at whole pixel precision.
At least on my TFT display, the top part (especially the ground) appears to scroll considerably smoother than the bottom part, without noticeable artifacts. (Wait for the file to load completely first!)
I was wondering about applications for this in NES emulator development.
- Subpixel-precise image scaling
- Rendering of NTSC artifacts at subpixel resolution
General information: Subpixel rendering is a tradeoff: It gives 3 x improved horizontal resolution, but because each subpixel is monochromous, it produces color artifacts. It works best when the subpixel details are whole pixel wide, only offseted, and relatively unsaturated (grayscale).
Train of thought: NES can render pixels at three subpixel positions. A pixel may be in its place, or shifted 1/3 pixels to the side, or 2/3 pixels to the side. Coincidentally, TFT has the same architecture. We can shift the entire screen losslessly sideways by 1/3 pixel increments! How about applying it for NTSC rendering?
Your thoughts?
Topic: Ultra-fast NTSC filtering.
Left: No subpixel rendering. Right: Yes subpixel rendering.
(Note: The rightside image appears to jitter more, because it brings more NTSC artifacts forth. The leftside image is 3x more aliased compared to the rightside one.)
EDIT: The pictures above were produced with a buggy algorithm. Below, fixed versions.
Left: No subpixel rendering; Middle: Subpixel interval 2 half-clocks; Right: Subpixel interval 2⅔ half-clocks.
Subpixel components are sampled as follows, depending on the subpixel interval:
Code:
0123456789ab0123456789ab0123456789ab0123 <- halfclock modulo 12
0000000011111111222222223333333344444444 <- pixels as generated by PPU (8 halfclocks per pixel)
No subpixel rendering (8,0,0):
............rrrrrrrrrrrr <- NTSC signal sampled for each rendered pixel
............gggggggggggg
............bbbbbbbbbbbb
Subpixel interval 2 (4,2,2):
............rrrrrrrrrrrr
............gggggggggggg
............bbbbbbbbbbbb
Subpixel interval 2⅔ (2,3,3):
............rrrrrrrrrrrr
............gggggggggggg
............bbbbbbbbbbbb
0000000011111111222222223333333344444444 <- pixels as generated by PPU (8 halfclocks per pixel)
No subpixel rendering (8,0,0):
............rrrrrrrrrrrr <- NTSC signal sampled for each rendered pixel
............gggggggggggg
............bbbbbbbbbbbb
Subpixel interval 2 (4,2,2):
............rrrrrrrrrrrr
............gggggggggggg
............bbbbbbbbbbbb
Subpixel interval 2⅔ (2,3,3):
............rrrrrrrrrrrr
............gggggggggggg
............bbbbbbbbbbbb
Topic: Super Mario Bros. title screen, lanczos-scaled to proper aspect ratio.
Left: At 292x240. Right: At 876x240 (subpixel).
Topic: Same deal, Wizards & Warriors title screen.
Left: original title screen for comparison. Midde & right: The same title screen, shifted 1/3 and 2/3 pixels to the left respectively. Click here to see an animated progression of these three images.
It is easy to observe that the subpixel-scaled version does better job at capturing the sharpness of the original picture, but at the cost of some color artifacts at the edges of details.
Source code of ultra-fast NTSC filtering (old buggy versions: DgDsvnu6)