Problem about shader overlapping

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dethland

Hi,

I am learning shader this week and I am trying to make my sprite glowing.
However, when the sprite overlapped with each other, some of their parts go transparent (I don’t know the word to describe it).

I am using the fragment method to add color to the untransparent part to make a glow effect.

My shader code is down below.

shader_type canvas_item;

uniform vec4 glow_color : hint_color  = vec4(1.0);
void fragment() 
{

vec4 current_color = texture(TEXTURE,UV);

if(current_color.r > 0f)
{
	COLOR = current_color + glow_color /2.0
}
else
{
	COLOR = current_color
}
}

Does anyone know the name of the problem?
Thank you for your help :slight_smile:

:bust_in_silhouette: Reply From: albinaask

It would be incredibly helpful with an image showing when it works and when things break, but it might have to do with the fact that you modify the "COLOR"s alpha value try the following:

shader_type canvas_item;

uniform vec3 glow_color : hint_color  = vec3(1.0);
void fragment() 
{

vec4 current_color = texture(TEXTURE,UV);

if(current_color.r > 0f)
{
    COLOR.rgb = current_color.rgb + glow_color.rgb /2.0;
    COLOR.a = current_color.a;
}
else
{
    COLOR = current_color;
}
}