libretro/common-shaders logo

libretro/common-shaders

Free

Collection of commonly used Cg shaders. These shaders are usable by either HLSL and/or Cg runtime compilers. The cg2glsl script will translate most of these into GLSL shaders.

FreeFree tier
Type
Open Source

About libretro/common-shaders

This repository contains a collection of pixel shaders written in the Cg language, intended for use in old school emulators. The shaders are compatible with both OpenGL and D3D backends and follow a strict specification for vertex and fragment entry points, texture coordinates, and uniform parameters. Known implementations include RetroArch, SNES9x, and OpenEmu. The collection covers a wide range of effects such as CRT simulation, anti-aliasing, blur, dithering, scalers (hqx, xbr, xbrz, eagle, etc.), NTSC/PAL artifacts, motion blur, and more. A cg2glsl script is provided to translate most shaders into GLSL for broader compatibility.

Key Features

Pixel shaders for old school emulators
Written in Cg language, compatible with OpenGL and D3D
Standardized entry points: main_vertex and main_fragment
Top-left oriented texture coordinates with black border mode
Uniforms for video_size, texture_size, output_size, frame_count, frame_direction
Includes shaders for CRT, anti-aliasing, blurs, dithering, scalers, NTSC/PAL, motion blur, and more
cg2glsl script for conversion to GLSL
Supported by RetroArch, SNES9x, and OpenEmu

Pros & Cons

Pros
  • Comprehensive collection of shaders covering many common effects
  • Open source and free to use
  • Well-documented specification for easy integration
  • Compatible with multiple popular emulators
  • Includes conversion tool for GLSL compatibility
Cons
  • Requires Cg runtime or HLSL, which may be deprecated or unavailable on some systems
  • Some shaders may not translate perfectly with the cg2glsl script
  • Power-of-two textures recommended for optimal quality
  • Top-left texture coordinate origin differs from typical GPU expectations
  • Active development may be limited; community-maintained

Best For

Retro game emulation with enhanced visual effectsAdding CRT scanlines and phosphor emulation to emulated gamesApplying anti-aliasing and sharpening to pixel artScaling low-resolution graphics using advanced algorithms (hqx, xbr, etc.)Simulating NTSC/PAL television artifacts for authenticity

FAQ

What emulators can use these shaders?
The shaders are known to work with RetroArch, SNES9x (Win32 port), and OpenEmu, following the spec described in the repository.
What programming language are the shaders in?
The shaders are written in Cg, a high-level shading language. They can be compiled with both HLSL and Cg runtime compilers.
Can these shaders be used on systems without Cg support?
The repository includes a cg2glsl script that translates most shaders into GLSL, allowing them to be used on platforms that support OpenGL.
What are the texture requirements?
Shaders work on texture unit 0 with 2D textures. Power-of-two sizes are recommended. The texture coordinate origin is top-left, and black border mode must be set.