blurymind / Godot-Gradient-Shift-Shader

A simple shader that shifts between colors based on a gradient, to create palette-cycle-like animations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Godot Gradient Shift Shader

A very simple shader that lets you achieve the effect of palette cycling. Using this shader is extremely cheap for performance.

Basic usage

You need 2 images: base image, which is grayscale, and a palette, which is a single-row texture. The shader will map the colors from palettte to their grayscale equivalents (specifically, it uses red channel as value) and cycle the colors from the palette. With a proper distribution of colors, you can achieve effects like waterfalls, conveyor belts etc. Here's example:

Caveats

To achieve the best effect, the textures need to meet these criteria:

  • the grayscale texture must have filter import option disabled
  • the color count in the original texture and the palette should be the same
  • shades of gray in the original texture need to have equal increments in their value (e.g. 0.333, 0.666, 1.0, but not 0.2, 0.5, 1.0)

If you want more flexibility at the cost of some performance, check out my palette swap shader.

About

A simple shader that shifts between colors based on a gradient, to create palette-cycle-like animations

License:MIT License


Languages

Language:GLSL 100.0%