Difference between revisions of "CRT shaders"

From Emulation General Wiki
Jump to navigation Jump to search
(Added sections on CRT-Guest-Advanced and Sony Megatron)
(Begin work on section explaining phosphor mask emulation, part 1)
Line 84: Line 84:
 
==Future==
 
==Future==
  
===Shadow Mask Phosphor Emulation===
+
===Phosphor Mask Emulation===
Hypothetical shadow mask phosphor shaders such as PhosphorLUT and CRT-Royale are being developed. Due to the nature of the shadow mask screen, 4K resolution is likely needed to avoid significant downsampling of the phosphors.
+
At the frontier of CRT shader development has been phosphor mask emulation. As stated previously, there are three overarching mask types: aperture grilles, shadow masks and slot masks. Aperture grilles were used primarily by Sony TVs, professional displays and PC monitors (with a few other brands such as Mitsubishi releasing their own version after Sony's Trinitron patent expired in the late 90's), shadow masks by the majority of PC CRT monitors from the late 80's onwards, and slot masks by just about every non-Sony consumer-level CRT TV, the vast majority of arcade monitors, and very early home computer/PC monitors. A key part of CRT emulation, then, depends on accurately replicating the look of these masks.
 +
 
 +
However, even within each of these mask types, there is a lot of variance, as some CRTs were much sharper and were able to resolve a lot more detail than others. This is encapsulated in a specification known as TVL, or television lines, defined as the number of vertical white lines a mask can resolve along the horizontal dimension in a stretch equal to the height of the tube's viewable area (this means TVL is calculated by measuring the screen's height, then counting the number of resolved lines across a horizontal span equal to that height, not across the entire length of the screen). A higher TVL count is the result of higher phosphor density and results in a sharper, more detailed image, as well as more prominent scanlines in low-res content. Most consumer-level CRTs had a relatively low TVL count, whereas professional monitors such as Sony's PVM and BVM series had much higher TVL. In PC monitors, the usual specification to determine sharpness was instead dot pitch, or the distance between two phosphors of the same color. The lower the dot pitch, the sharper the monitor and the more detail it could resolve.
 +
 
 +
Taking into account the three mask types and the variance in TVL and dot pitch, then, along with many other variables, it is no wonder no two CRTs looked alike.
  
 
==External Links==
 
==External Links==

Revision as of 18:59, 11 July 2022

CRT-Geom-Flat, with default settings

CRT shaders are one of the most popular categories of shaders. While there had been many attempts to include some kind of CRT-esque filters in older emulators - usually involving little more than overlaying dark gray or black lines, colloquially referred to as scanlines, over the image - modern CRT shaders are much more complex and configurable.

Many of these replicate aperture grille CRTs (exemplified primarily by Sony TVs and monitors, though other manufacturers released their own versions of the technology later on), which have sharp images and strong scanlines. If you find that these shaders don't look a damn thing like your old TV, it's probably because you owned a slot mask-style CRT, which typically had less noticeable scanlines, or simply had a smaller set, which tended to be less sharp. The easiest way to tell the difference is to feel the curve of the screen; aperture grilles only curve horizontally if at all. Alternatively, look at the left and right sides of the glass against the frame - if the sides are curved, it's a slot mask; if they're straight, it's an aperture grille. Old TVs usually had slot masks, whereas monitors usually had shadow masks. While slot masks and shadow masks can be emulated to a certain degree even at 1080p, much higher resolutions like 4K or higher are better suited to the task. Aperture grilles are much easier to emulate, and can be satisfactorily replicated at 1080p, though it goes without saying even better results can be achieved with higher resolution.

It is advisable to use integer scaling when using CRT shaders. This means either using windowed mode (x2,x3,x4) or setting an integer scaling option in the video options. The reason is that non-integer scaled scanlines will result in uneven lines with artifacts, though some shaders use oversampling to try to avoid this. If the resulting letterboxing annoys you and you still want to fill up as much of your screen's real estate as possible, you can also try integer scale overscaling, which scales the image up by another integer to fill the vertical image space while still preserving integer scaling, at the expense of some of the image on the top and bottom being cut off. As an example, at 1080p, turning on overscaling would scale a typical SNES game running at 256x224 to 5x scale i.e. 1280x1120, cutting off twenty pixels from both the top and bottom of the image to reach 1080p. Before you fret, know that at 1080p and 4K the loss from overscaling is usually negligible and well within the area that would've been expected to be cut off on a real CRT anyway due to overscan, and developers almost always took this into account and made sure not to put any crucial game information there, so on many if not most older games, overscaling is completely safe.

Download

All official releases of RetroArch come bundled with a full set of slang and GLSL shaders, including CRT shaders, pulled from their shader repositories on Github, which are regularly maintained and updated. The simplest way to keep up to date with shader development is through RetroArch's built-in updater, though if you are only interested in the CRT shaders, you can alternatively grab them from the following repos:

slang shaders - For use with devices that support Vulkan, OpenGL 3.x, GLES3, and/or D3D10/11/12. This is the most current, regularly maintained repository.

GLSL shaders - For use with devices that only support up to OpenGL 2.x or GLES2. Largely deprecated, though still sporadically maintained.

Cg shaders - For use on platforms that only support Cg or HLSL runtimes, such as the PS3. Deprecated.

Types

CRT-Geom

Main article: CRT Geom

Simulates an aperture grille display (with the dot mask enabled). Very versatile and modifiable. One of the first popular CRT shaders. Visit the main article for more details.

CRT-Calagari

An older CRT shader similar to CRT-Geom but uses different methods to achieve its effects.

CRT-Easymode

A flat CRT shader whose settings are easier to understand. Similar to CRT-Geom in its effects.

CRT-Hyllian

Aims only for picture quality, so it avoids things that degrade the image just for accuracy. It, however, uses far less power to run, so it is possible to run this shader on lower end systems than CRT-Geom.

Another version, crt-hyllian-lq.cg is specifically aimed at even lower end systems.

CRT-Lottes

A newer CRT shader that uses a horizontal shadow mask pattern with blooming. The horizontal pattern works quite well at current resolutions, though it isn't entirely accurate to a true vertical slot mask pattern.

GTU

A CRT shader that focuses more on simulating blur and blending effects and color levels of CRT screens rather than the physical attributes like phosphors and curvature. Highly configurable, can be really sharp, or really blurry or anywhere in between, with optional scanlines and contrast and gamma settings. Settings are stored in a separate "config.h" file for easy editing. GTU-Famicom is a variant that takes an image from an NES with "raw" colors and processes it to output an NTSC image much like an actual NES PPU.

The test program is a program that can adjust various attributes, such as horizontal and vertical blur, scanlines, etc. It is useful for testing settings to use with the shader, and also to understand how CRT shaders work in general.

CRT-Royale

Main article: CRT-Royale
CRT-Royale, with default settings at 1080p (view original for full details)

A highly advanced multi-pass CRT shader that simulates almost every aspect of the CRT screen. There are tons of parameters to configure, such as phosphor type (aperture grille, slot mask, and EDP shadow mask) and size (i.e. dot pitch), convergence offests, scanline blooming and many others. Higher resolution is better for this shader, especially with EDP shadow mask phosphor layout and with smaller phosphor dot pitch values. This shader is really complicated compared to most other CRT shaders, reading the README and the documentation in the user-settings.h is a must.

CRT-Royale-Kurozumi

A preconfigured CRT-Royale made to look like a professional CRT monitor, specifically Sony's PVM/BVM line of monitors.

CRT-Guest-Advanced

This is quite possibly the most advanced, feature-rich CRT shader of all. It has just as if not more parameters to configure than CRT-Royale while being more optimized, and if greater speed is desired, there are several faster versions available, as well as variants that add other neat features such as NTSC emulation and better support for games that render at 480p or higher. It is also still in active development and continues to regularly gain features and optimizations. Take heed, however: it is also one of the only shaders without a central public Github repo, as its developer has opted for release bundles linked to in the libretro forums instead. While RetroArch does host a version of it in their shader repos, it is highly outdated, so it is recommended to update it using the latest release from the developer's dedicated libretro forum thread, linked above.

Sony Megatron

This shader is quite unique among CRT shaders, and shaders in general. It is currently the only shader that takes advantage of HDR support for greater color depth and brightness, allowing for highly accurate CRT emulation on HDR-capable displays, though it is also usable on regular SDR displays. Unlike other CRT shaders, its inner workings are actually fairly simple and it doesn't have many bells and whistles, focusing mainly on drawing scanlines and accurate phosphor masks as well as color correction, which coincidentally also makes it one of the fastest shaders featured on this page. As it is primarily meant for use on bright HDR-capable displays, it draws phosphor masks at full strength with no attempt at mitigating the resulting loss in brightness through parameters such as bloom, glow or mask strength typically seen in other CRT shaders, instead counting on the display to make up for it. On an SDR display, it is highly recommended to use it with the backlight turned up all the way, as otherwise the image will likely be too dim to view comfortably. There are presets emulating various CRT models and types, including several PVM models, certain arcade displays, and even PC monitors.

Future

Phosphor Mask Emulation

At the frontier of CRT shader development has been phosphor mask emulation. As stated previously, there are three overarching mask types: aperture grilles, shadow masks and slot masks. Aperture grilles were used primarily by Sony TVs, professional displays and PC monitors (with a few other brands such as Mitsubishi releasing their own version after Sony's Trinitron patent expired in the late 90's), shadow masks by the majority of PC CRT monitors from the late 80's onwards, and slot masks by just about every non-Sony consumer-level CRT TV, the vast majority of arcade monitors, and very early home computer/PC monitors. A key part of CRT emulation, then, depends on accurately replicating the look of these masks.

However, even within each of these mask types, there is a lot of variance, as some CRTs were much sharper and were able to resolve a lot more detail than others. This is encapsulated in a specification known as TVL, or television lines, defined as the number of vertical white lines a mask can resolve along the horizontal dimension in a stretch equal to the height of the tube's viewable area (this means TVL is calculated by measuring the screen's height, then counting the number of resolved lines across a horizontal span equal to that height, not across the entire length of the screen). A higher TVL count is the result of higher phosphor density and results in a sharper, more detailed image, as well as more prominent scanlines in low-res content. Most consumer-level CRTs had a relatively low TVL count, whereas professional monitors such as Sony's PVM and BVM series had much higher TVL. In PC monitors, the usual specification to determine sharpness was instead dot pitch, or the distance between two phosphors of the same color. The lower the dot pitch, the sharper the monitor and the more detail it could resolve.

Taking into account the three mask types and the variance in TVL and dot pitch, then, along with many other variables, it is no wonder no two CRTs looked alike.

External Links