Godot-Gradient-Shift-Shader icon indicating copy to clipboard operation
Godot-Gradient-Shift-Shader copied to clipboard

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

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 node with shader should have texture_filter set to Nearest
  • 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.


You can find all my addons on my profile page.

Buy Me a Coffee at ko-fi.com