20 lines
580 B
Plaintext
20 lines
580 B
Plaintext
shader_type canvas_item;
|
|
|
|
// Parameters
|
|
uniform float alpha_threshold : hint_range(0.0, 1.0) = 0.1; // below this = fully transparent
|
|
uniform float alpha_modifier : hint_range(0.0, 1.0) = 1.0; // global alpha multiplier
|
|
|
|
void fragment() {
|
|
// Sample the texture
|
|
vec4 tex_color = texture(TEXTURE, UV);
|
|
|
|
// Use the texture's alpha channel directly
|
|
float alpha = tex_color.a < alpha_threshold ? 0.0 : tex_color.a;
|
|
|
|
// Apply global modifier
|
|
alpha *= alpha_modifier;
|
|
|
|
// Preserve original RGB, apply computed alpha
|
|
COLOR = vec4(tex_color.rgb, alpha);
|
|
}
|