Godot Palette-Based Dithering Shader Demo
CONTROLS:
Pause Scene : Space
Switch Palette : Shift
----------------------------------------------------------------
A demo of a Godot dithering shader I adapted and modified from http://alex-charlton.com/posts/Dithering_on_the_GPU/.
It runs as a post-processing effect and it can remap a scene to any arbitrary palette, and only the colors in that palette.
Dithered Scene:
The scene drawn using the dithering shader with the SLSO8 palette applied. Each pixel is only 1 of 8 colors.
Default Scene:
The scene drawn normally, with no post processing.
Palettes used (in order of appearance):
- SLSO8 (https://lospec.com/palette-list/slso8) (8 Colors)
- AAP-64 (https://lospec.com/palette-list/aap-64) (64 Colors)
- Minty Fresh (https://lospec.com/palette-list/minty-fresh) (4 Colors)
- Pico-8 (https://lospec.com/palette-list/pico-8) (16 Colors)
- Amaryllis Garden 8 (https://lospec.com/palette-list/amaryllis-garden-8) (8 Colors)
As the demo illustrates, it works well enough with just about any palette.
HOW TO USE:
- Import the two downloadable files into your project ("palette_dither_post_processing.shader" and "dither_shader_palette_precomputer.gd").
- Create a "Viewport Container" node at the root of a tree.
- Set the container layout to "Full Rect" (not required, but helpful).
- Enable stretching on the container if you want it to adjust to the window size.
- Add a viewport as a child of the container. Adjust it's size to your needs (if you want it to fill the window, set it to your project setting's window size).
- Add whatever scene you want to render as a child of the viewport. In the demo it's a spatial node, but it can be anything. Your scene tree should look like this:
- Create a new Shader Material on the Viewport Container, and assign "palette_dither_post_processing.shader" to the shader slot.
- Attach "dither_shader_palette_precomputer.gd" as a script to the viewport container. This automatically adjusts parameters on the shader for the palette and converts it to HSL color space.
- Assign any texture to the "Palette Texture" slot. Smaller images can be processed more quickly.
- Viola! You should now see the viewport getting recolored and dithered to the palette of your texture!
The models were made by me while following this excellent course by Miziziziz:
Status | In development |
Category | Other |
Platforms | HTML5 |
Author | stonebruin |
Tags | Godot, Lo-fi, Retro, Shaders |
Leave a comment
Log in with itch.io to leave a comment.