https://github.com/williamd1k0/redmask
Tool to create palette swap mask/map.
https://github.com/williamd1k0/redmask
gimp godot krita palette python python3 shaders
Last synced: 2 months ago
JSON representation
Tool to create palette swap mask/map.
- Host: GitHub
- URL: https://github.com/williamd1k0/redmask
- Owner: williamd1k0
- License: other
- Created: 2017-08-01T04:10:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T19:44:49.000Z (over 1 year ago)
- Last Synced: 2025-01-31T20:13:56.415Z (3 months ago)
- Topics: gimp, godot, krita, palette, python, python3, shaders
- Language: Python
- Homepage:
- Size: 71.3 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#  redmask
A simple tool to create palette swap mask## How palette swap mask works
A palette swap mask is an image used to map a palette using a gradient scale.
The tool will generate a red gradient image because green and blue values are useless for the mask.
Full explanation about palette mask: [https://www.youtube.com/watch?v=u4Iz5AJa31Q](https://www.youtube.com/watch?v=u4Iz5AJa31Q)

## Using the generated mask
The mask can be used in a palette swap shader.
Example shader in Godot Engine 3.x.x:
```glsl
shader_type canvas_item;uniform sampler2D palette;
uniform int palette_colors = 1;
uniform float color_step = 1.0;void fragment() {
vec4 new_color = texture(TEXTURE, UV);
if (new_color.a > 0.0){
vec2 palette_uv = vec2((new_color.r * 255.0) / float(palette_colors) / color_step, 0.0);
new_color = texture(palette, palette_uv);
}
COLOR = new_color;
}
```## Install
```sh
pip install redmask
```## Basic usage
```sh
redmask
# generate a mask using default color step (1)redmask -s 10
# generate a mask using 10 as color stepredmask -a
# apply a palette (paint the mask) using default color step (1)
```You can test using images in the `tests` directory.
Also, you can view usage info using the `-h/--help` command.
---
> Example art made by [Yomieda](https://twitter.com/yomieda).