Skip to main content

A simple tool to create palette swap mask

Project description

icon 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

palette-mask-tuto

Using the generated mask

The mask can be used in a palette swap shader.

Example shader in Godot Engine 2.1.x:

// fragment
uniform texture palette;
uniform float colors;
uniform float color_step;

if (COLOR.a != 0){
    COLOR = tex(palette, vec2((COLOR.r*255.0)/(colors-0.001) / color_step, 0));
}
// '0.001' part is a workaround to fix float precision issues.

Basic usage

# redmask = python redmask.py

redmask <input> <palette>
# generate a mask using default color step (1)

redmask <input> <palette> -s 10
# generate a mask using 10 as color step

redmask <generated-mask> <palette> -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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redmask-1.1.0.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

redmask-1.1.0-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page