Cg shader version of the HQx pixel art upscaling filter

Overview

HQx-shader

Cg shader version of the HQx pixel art upscaling filter.

How to use

Load the preset files for the desired upscale factor in an emulator that supports it such as RetroArch.

Integration

If you want to implement support for this shader in an emulator you will need to support loading an additional texture for the shader besides the game output texture. The texture that needs to be loaded can be found in the resources directory.

After you have added support for additional textures you can integrate the single-pass shader which can be found in the single-pass/shader-files directory.

Additionally, for better performance you can support multi-pass shaders that will reduce redundant computation and thus preform a lot faster than the single-pass variant. The multi-pass variant can be found in the shader-files directory and are used by the preset files by default.

Implementation

Like the original HQx filter this shader requires a lookup table. In HQx this lookup table contains the weights used for interpolating the pixels through a weighted average. More information on the original algorithm can be found in the documentation.

The HQx algorithm interpolates the original pixel (w5) with its 8 neighbours.

//   +----+----+----+
//   |    |    |    |
//   | w1 | w2 | w3 |
//   +----+----+----+
//   |    |    |    |
//   | w4 | w5 | w6 |
//   +----+----+----+
//   |    |    |    |
//   | w7 | w8 | w9 |
//   +----+----+----+

All pixels are compared in the YUV color space and the weights for the detected pattern are retrieved from the look-up texture. The pixels we want to use for the interpolation are also selected by these weights (the weights of the other pixels are set to zero).

Each entry in the look-up texture has four components to store the weights. The weights are then applied through a simple matrix-vector multiplication. The pixels in this matrix will differ based on which upscaled pixel we're processing relative to the original pixel. For example, if we're in the top-left quadrant relative to the original pixel we will only ever need to interpolate the pixels w1, w2, w4 and w5.

Credits

Maxim Stepin and Cameron Zemek for the original C implementation.

Hyllian (author of xBR) for helping me out during the implementation.

Hunter K. for his support.

You might also like...
Plugin for connecting MetaEditor with Pixel Streaming (Unreal Engine)

metaplugin-pixel-streaming Plugin for connecting MetaEditor with Pixel Streaming (Unreal Engine) Links: Documentation Compiled version (Win64) Source

Make CVE-2020-0668 exploit work for version < win10 v1903 and version >= win10 v1903
Make CVE-2020-0668 exploit work for version win10 v1903 and version = win10 v1903

CVE-2020-0668 Made CVE-2020-0668 exploit work for version win10 v1903 and version = win10 v1903 Diaghub Exploit ( v1903) powershell exploit works

Modified version of srlua for MSVC using version 5.4 of Lua

Modified version of srlua for MSVC using version 5.4 of Lua. Quote from the original README: This is a self-running Lua interpreter. It is meant to be

Fractal Art on the Pico

Mandlebrot Set generator Draws the Mandelbrot set to a 240x240 ST7789 display connected as in the pio/st7789 pico example. The fractal slowly zooms in

A fast fetch written in C, with the ppfetch Ascii Art.
A fast fetch written in C, with the ppfetch Ascii Art.

Redfetch A fast fetch written in C, with the ppfetch Ascii Art. Dependencies wmctrl A C compiler (such as clang or gcc) make Installation Build: git c

This is a simple filter that will block any attempt to access streams beginning with

Triggering the notification only requires that you visit a particular path on an NTFS volume.

Comparing the performance of Wave Digital Filter implementations

WDF Bakeoff Comparing performance between Wave Digital Filters implemented in C++ and Faust. Building First clone the repository and submodules: git c

Simple sensor filter chain nodes and nodelets

sensor_filters This package is a collection of nodes and nodelets that service a filters::FilterChain for message types from sensor_msgs package. Each

High Quality DeNoise 3D is an AviSynth port of the MPlayer filter of the same name

High Quality DeNoise 3D is an AviSynth port of the MPlayer filter of the same name. It performs a 3-way low-pass filter, which can completely remove high-frequency noise while minimizing blending artifacts.

Comments
  • Unexpected HQX results, possibly from the LUT texture

    Unexpected HQX results, possibly from the LUT texture

    I am getting this result after implementing the HQX filter in a MonoGame solution:

    Actual

    I think it has something to do with the LUT texture that is being loaded, I'm just unsure how to solve it.

    This is how the image is configured in the MonoGame pipeline:

    LutConfig

    I've tried the following variations of the LUT texture with no luck:

    • Normal
    • Normal Rotated 90
    • Normal Rotated 180
    • Normal Rotated 270
    • Horizontal Flip
    • Horizontal Flip Rotated 90
    • Horizontal Flip Rotated 180
    • Horizontal Flip Rotated 270
    • Vertical Flip
    • Vertical Flip Rotated 90
    • Vertical Flip Rotated 180
    • Vertical Flip Rotated 270
    • Horizontal Flip then Vertical Flip
    • Horizontal Flip then Vertical Flip Rotated 90
    • Horizontal Flip then Vertical Flip Rotated 180
    • Horizontal Flip then Vertical Flip Rotated 270
    • Vertical Flip then Horizonal Flip
    • Vertical Flip then Horizonal Flip Rotated 90
    • Vertical Flip then Horizonal Flip Rotated 180
    • Vertical Flip then Horizonal Flip Rotated 270

    I've also tried all of these with and without mipmaps. Any ideas as to why this isn't working?

    opened by altmoola 8
  • Hqx shaders not working

    Hqx shaders not working

    Hi there, I try to use your hqx shaders in my project. Unfortunately they just produce the original image. Returning a solid color instead of the calculated one works, so the shader itself is used. I found that changing the weights value does not change anything beside setting it to vec4(0). So I can use any constant there instead or even use a changing values like vec4(vTexCoord[0].x) there and it still looks like the original.

    Any ideas about it? Do these shaders work?

    opened by Pyrdacor 1
Owner
Jules Blok
Jules Blok
A pixel art tool with infinite canvas

compfy paint a pixel art tool with infinite canvas. CONTROLS: use left mouse button to select colors and press on the grid to place them. you can z

dumb 7 Aug 12, 2022
Animated sprite editor & pixel art tool (Windows, macOS, Linux)

Aseprite Introduction Aseprite is a program to create animated sprites. Its main features are: Sprites are composed of layers & frames as separated co

Aseprite 19.7k Jan 2, 2023
Animated sprite editor & pixel art tool -- Fork of the last GPLv2 commit of Aseprite

LibreSprite Introduction LibreSprite is a free and open source program for creating and animating your sprites. Real-time animation previews. Onion sk

null 2.9k Dec 31, 2022
A cross platform shader language with multi-threaded offline compilation or platform shader source code generation

A cross platform shader language with multi-threaded offline compilation or platform shader source code generation. Output json reflection info and c++ header with your shaders structs, fx-like techniques and compile time branch evaluation via (uber-shader) "permutations".

Alex Dixon 286 Dec 14, 2022
Shader Playground is a website for exploring shader compilers.

Shader Playground is a website for exploring shader compilers. Visit website Supported backends Compilers ANGLE Clspv DXC FXC Glslan

Tim Jones 445 Dec 30, 2022
Shader cross compiler to translate HLSL (Shader Model 4 and 5) to GLSL

XShaderCompiler ("Cross Shader Compiler") Features Cross compiles HLSL shader code (Shader Model 4 and 5) into GLSL Simple to integrate into other pro

Lukas Hermanns 345 Dec 9, 2022
Pixel 4/XL kernel.

Linux kernel ============ This file was moved to Documentation/admin-guide/README.rst Please notice that there are several guides for kernel develop

Sultan Alsawaf 80 Dec 11, 2022
A simple on-screen pixel meter

QRuler A simple on-screen pixel meter. Dependencies Under Debian based systems: cmake qtbase5-dev qttools5-dev Build cmake -B build -DCMAKE_BUILD_TYPE

redtide 2 Nov 21, 2022
Blu_spark kernel for Pixel 6/Pro

How do I submit patches to Android Common Kernels BEST: Make all of your changes to upstream Linux. If appropriate, backport to the stable releases. T

null 15 Dec 5, 2022
A simple, funky, horrible fluid simulator, made possible by OLC's Pixel Game Engine

flOwie A simple, funky, horrible fluid simulator, made possible by OLC's Pixel Game Engine! Not meant for usefulness. The big O is in the name because

null 1 Jan 21, 2022