Skip to content
forked from averne/Fizeau

Color management on the Nintendo Switch (libultrahand rebuild)

License

Notifications You must be signed in to change notification settings

ppkantorski/Fizeau

 
 

Repository files navigation

Fizeau

Adjust the color of the screen of your Nintendo Switch.

Features

  • Modify the color temperature, saturation and hue of the display.
  • Selectively apply corrections to color channels, filter to one single component.
  • Tone mapping with programmable contrast, gamma, luminance, and color range.
  • Schedule settings to be applied at dusk/dawn, with smooth transitions.
  • Configurable screen dimming.

Images

Installation

Download the latest zip from the release page, unzip it to the root of your sd card (be careful to merge and not overwrite folders), and reboot.

Only the latest version of the Atmosphère CFW is supported.

If you want to use the overlay, you will need to set up Tesla (install Tesla-Menu and ovlloader). This isn't supported on firmware versions prior to 9.0.0.

Supported firmwares

Firmware versions 9.0.0 and later are supported. If you encounter an issue running this software on a particular version, please create an issue.

Usage

You can refer to the built-in help. Navigate with either the touchscreen or the D-pad buttons.

Settings

Settings are saved at /switch/Fizeau/config.ini and /config/Fizeau/config.ini (in order of priority), which you can also edit.

Building

  • Compiling requires a working devkitA64 installation, with package switch-glm installed. You also need rsync to be available (it should be by default on all major operating systems).
  • Clone this repository recursively (git clone --recursive https://github.com/averne/Fizeau)
  • Navigate to its directory (cd Fizeau).
  • Run make dist.
  • You will find the output file in out/.

How it works

This software uses the CMU (Color Management Unit) built into the Tegra GPU of the Nintendo Switch. The purpose of this unit is to enable gamma correction/color gamut changes.

The CMU works in 3 passes:

  • the first pass converts 8-bit sRGB data into a 12-bit linear colorspace, using a LUT (look-up table). Therefore, it also increases the precision of the color data.
  • the second pass is a dot product between the CSC (Color Space Correction) matrix and the RGB data, as illustrated below.

  • the third pass maps the 12-bit linear, now corrected color data back into 8-bit sRGB, using another LUT. Hence the precision after this pass is decreased. Moreover, this LUT is split into two parts: the first 512 entries map [0, 32), while the 448 other represent [32, 256). This allows greater precision for darker color components, which the human eye is more sensitive to.

Overview of the CMU pipeline:

More detail can be found in the TRM (Tegra Reference Manual), section 24.3.14 (Display Color Management Unit).

Official software use the CMU for multiple purposes (the following images were generated using a script found here, with data dumped from running official software):

  • Represented below is the default CMU configuration. No correction is applied:

  • Color inversion is applied using the LUT2, which is simply inverted:

  • Grayscale is implemented with the CSC, using the luminance function Y = 0.2126 * R + 0.7152 * G + 0.0722 * B on each component (the actual coefficients being 0.2109375, 0.7109375 and 0.0703125 due to the limited precision of CSC components which are 10-bit signed Q1.8 numbers):

  • Lastly, luminance correction, here with a luma=1.0 (color range correction is very similar):

In addition, the color range of the external display is restricted using the HDMI AVI (Auxiliary Video Information) infoframe.

Official software uses precalculated default gamma ramps, and apply modifications to those (the relevant function can be found at .text + 0x05c70 in 6.0.0 nvnflinger). However here gamma ramps are generated at runtime, which is both more elegant and easily enables non-default gamma. The generated LUT1 is byte-for-byte identical to the official one.

Credits

About

Color management on the Nintendo Switch (libultrahand rebuild)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 74.4%
  • Makefile 12.2%
  • C 7.0%
  • Python 4.9%
  • GLSL 1.5%