r/godot • u/BasePersonal8220 • 11h ago
help how do i make this stupid shader transparent?
transparent in the sense that like, it will account for the transparency of the texture its on, cuz like look rn its just doing the whole mesh instead of just the texture its REDICULOUS.
shader_type spatial;
render_mode unshaded;
uniform sampler2D texture_albedo : source_color;
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
uniform float scale = 1.0;
uniform float alpha_value : hint_range(0.0, 1.0) = 0.5;
uniform int blend_mode : hint_range(0, 8, 1) = 0;
void fragment() {
vec2 screen_uv = SCREEN_UV * scale;
vec4 tex = texture(texture_albedo, screen_uv);
vec3 blend = tex.rgb;
vec3 base = texture(screen_texture, SCREEN_UV).rgb;
vec3 res = blend;
if (blend_mode == 0) {
res = blend;
} else if (blend_mode == 1) {
res = base * blend;
} else if (blend_mode == 2) {
res = 1.0 - (1.0 - base) * (1.0 - blend);
} else if (blend_mode == 3) {
res = min(base, blend);
} else if (blend_mode == 4) {
res = max(base, blend);
} else if (blend_mode == 5) {
res = abs(base - blend);
} else if (blend_mode == 6) {
res = base + blend - 2.0 * base * blend;
} else if (blend_mode == 7) {
res = base / max(vec3(1.0) - blend, vec3(0.0001));
} else if (blend_mode == 8) {
res = 1.0 - (1.0 - base) / max(blend, vec3(0.0001));
}
ALBEDO = res;
ALPHA = tex.a * alpha_value;
}

