Skip to content

Instantly share code, notes, and snippets.

@erodozer
Created September 27, 2018 01:43
Show Gist options
  • Save erodozer/1387b79776b2055a633fb4dd32533daf to your computer and use it in GitHub Desktop.
Save erodozer/1387b79776b2055a633fb4dd32533daf to your computer and use it in GitHub Desktop.
Transition Clamping Shader
shader_type canvas_item;
render_mode blend_mix;
uniform float transition: hint_range(0, 1);
float val(vec3 color) {
return max(max(color.r, color.g), color.b);
}
void fragment() {
vec4 sample = texture(TEXTURE, UV.xy);
if (val(sample.rgb) < transition) {
COLOR = vec4(0,0,0,0)
} else {
COLOR = vec4(0,0,0,1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment