CRT Scanline Shader Setup Guide for Retro Gaming
\nThis guide explains why CRT-style scanline shaders are used to recreate the look of retro game consoles and how to deploy them across desktop, mobile, and handheld platforms. It covers the basic cross-platform setup workflow, the trade-offs between resolution, scaling, and moiré patterns, how to read structured preset naming rules, key parameter tuning tips, and practical performance and stability advice for low-power devices.
\n## 1. Why Retro Graphics Need Shaders\n\nThe images of the retro console era were not just pixel grids. They were the combined result of pixel grids being modulated into analog video signals and then reconstructed by a CRT tube. Phosphor persistence, electron-beam scanning, shadow mask structure, signal bandwidth limits, and slight analog circuit distortion together created the “feel” that players remember. Modern LCD panels display images line by line with sharp pixel edges and pure colors, which loses that texture.\n\nA shader is a small program that runs on the GPU and performs one or more operations on each pixel before the final image is output. Scanline shaders work in two main steps: first reconstruct the pixel grid at the game’s native resolution, then overlay periodic dark bands vertically to simulate the gaps between electron-beam scanlines, while using a phosphor mask horizontally to simulate the arrangement of RGB phosphor dots. The combination produces both grain and visible line structure, closely resembling the display devices of that era.\n\nIt is important to note that these effects are extremely sensitive to input resolution. If the scaling factor is not an integer multiple, the pixel grid cannot map one-to-one to the physical screen pixels, causing uneven brightness and beat patterns known as moiré. Understanding this is the foundation for all later configuration decisions.\n\n## 2. Basic Cross-Platform Deployment Workflow\n\nDeployment differences across devices mainly come down to file access permissions and graphics driver capabilities.\n\nOn desktop platforms, the easiest path is a standalone shader host program. These tools capture the output of any window as a transparent overlay, apply a preset, and display the result. They require no filter support from the game itself, making them suitable for old games, emulators, and even local video playback.\n\nMobile and handheld platforms usually rely on a general-purpose emulation frontend. Three points need attention:\n\n1. Shader directory permissions. Some mobile or embedded systems restrict access to paths outside the app sandbox. You may need to change the shader search path to a user-writable directory in settings first.\n2. Directory structure differences. Some custom firmware rearranges the default shader directory hierarchy. In that case, locate the actual path yourself and copy the presets in the matching format into it.\n3. Format and driver matching. If the graphics backend supports a modern Vulkan-type interface, prefer the .slang format. If you can only fall back to a traditional OpenGL-type backend (common on entry-level handhelds), you can only use the older .glsl format. The two differ in syntax and available features and cannot be mixed.\n\nRecommended minimal working workflow:\n\ntext\n1. Settings → Video → Graphics backend: prefer modern Vulkan-type, fall back to GL-type on issues\n2. Settings → Video → Scaling: disable integer scaling, set ratio to "core provided" or custom\n3. Content → Import → create a playlist (for easier launching and unified management)\n4. Launch game → quick menu (commonly F1) → shaders → load preset\n5. Select .slangp / .glslp inside the target folder under shaders_slang or shaders_glsl\n6. Shader parameters → adjust intensity, opacity, color\n7. Save preset: for current game / current core / global\n\n\nThe scope choice in step 7 matters. Applying a preset to only one game avoids style contamination. Saving per core suits collections that emulate the same type of console. Saving globally is for a unified look. If scanlines make certain game elements (such as large subtitles or borders) hard to read, narrow the scope first rather than abandoning the effect.\n\n## 3. Resolution, Scaling, and Moiré Trade-offs\n\nScanlines are essentially a high-frequency periodic pattern. Once it does not divide evenly into the screen’s pixel grid, interference stripes appear. There are three practical approaches:\n\n- Integer vertical scaling. Make each scanline fall exactly on an integer number of physical rows. The cost is that the image may not fill the screen, leaving black bars.\n- Lower the scanline frequency or increase the mask grain size. When vertical resolution is only 2 to 3 times the game’s native resolution, no filter can fully remove the stripes. A more reliable approach is to drop scanlines and use enlarged phosphor grain to provide anti-aliasing and structure.\n- Force integer vertical scaling and increase scanline sharpness. On low-resolution screens (fewer than 5 times the game’s vertical resolution), a “hard scanline” approach can trade softness for clearer structural edges.\n\nPractical advice: determine the ratio of the target device’s physical resolution to the game’s native resolution first, then choose a strategy accordingly, instead of picking a preset and repeatedly testing.\n\n## 4. Reading Preset Naming Rules\n\nThese preset libraries generally use structured naming. Understanding the naming lets you quickly locate a file among dozens without loading each one to preview.\n\n1. The first letter is the primary category. The later it falls in alphabetical order, the more complex the pipeline and the higher the demands on screen resolution and GPU load.\n2. The first number after it is the secondary category. The larger the number, the more preprocessing stages (such as adaptive sharpening, deinterlacing, anti-aliasing, and color space conversion) are stacked in front.\n3. The second number does not indicate a different effect, only different parameter values. Presets sharing the same first letter and first number can be converted into each other by adjusting parameters, so there is no need to load them repeatedly.\n4. Common abbreviations: PL means phosphor scanlines; an x2 suffix means scanlines forced to 2x vertical resolution; Mask means mask only, no scanlines; H (Hard) means hard scanlines with forced integer vertical display.\n\nA practical selection order: first choose the letter tier based on screen resolution, then choose the first number based on whether preprocessing is needed, and finally fine-tune parameters instead of switching back and forth between the second numbers.\n\n## 5. Parameter Tuning Tips\n\n- Scanline intensity: controls the depth of the dark bands. Too high makes the overall image dark and loses detail. Start from a middle value.\n- Mask intensity and grain size: affect color separation and moiré tendency. Larger grain is more stable.\n- Brightness/gamma compensation: scanlines reduce average brightness and need reverse compensation, otherwise dark scenes become nearly unreadable.\n- Color and saturation: the CRT color gamut and response curve differ from a panel. Moderately reducing saturation is closer to the original look.\n- Blend and opacity: used to balance “authenticity” and “playability.” For long sessions, lean conservative.\n\nAfter tuning, always save the preset and note its scope. After upgrading the emulation frontend or switching the graphics backend, return to defaults and recalibrate once, because different backends differ in default color management and texture filtering behavior.\n\n## 6. Performance and Stability\n\nShaders operate per pixel, so load is roughly proportional to output resolution, and multiple preprocessing stages amplify the cost further. The general strategy on low-power handhelds is to lower output resolution, reduce preprocessing layers, and avoid enabling multiple high-precision blur filters at the same time. If frame rate drops or screen tearing appears, switch the graphics backend first to check whether it is a driver issue, then disable nodes in the shader chain one by one to locate the bottleneck. Fixing verified configurations as presets, together with unified directory management, can significantly reduce maintenance costs in multi-device environments.
