Skip to content

Instantly share code, notes, and snippets.

@deakcor
Created January 8, 2021 12:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deakcor/e2c96a404550b7f022281780dd6342ce to your computer and use it in GitHub Desktop.
Save deakcor/e2c96a404550b7f022281780dd6342ce to your computer and use it in GitHub Desktop.
Color replacement shader for Godot Engine
/**
* Replace a color by another one.
* License: CC0
* https://creativecommons.org/publicdomain/zero/1.0/
*/
shader_type canvas_item;
uniform vec4 remove_color: hint_color;
uniform vec4 replace_color: hint_color;
void fragment(){
vec4 col = texture(TEXTURE, UV);
if (col.rgb == remove_color.rgb){
col = replace_color;
}
COLOR = col;
}
@deakcor
Copy link
Author

deakcor commented Jan 8, 2021

Example with green color replaced by transparent one.
104005521-8c494d80-51a5-11eb-905f-2458703f4c22
104005525-8e131100-51a5-11eb-86ba-bb237aab4fef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment