Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes

I want to make the shader opacity more transparent so that we can still see the elements below it. Does anyone know how to do that?

asked in CSC380Jan2024 by (2.6k points)

4 Answers

+5 votes

If your shader has a certain color that you are using you can set the alpha variable of the color to be lower so that the color has some transparency, if not how does your shader work?

answered by (2k points)
+4 votes

You could use this:

shader_type canvas_item;

void fragment() {

// Get the current color with alpha
vec4 color = texture(TEXTURE, UV);

// Modify the alpha channel to make the shader more transparent
color.a = 0.5; // Set alpha to 0.5 for 50% transparency

// Output the modified color
COLOR = color;


answered by (3k points)
+4 votes

Thank you guys, I got it. My shader is a black and white noise (like the old television). And this is what I did

float saturation = 0.5;
float contrast = 1.2;
if (discolor)
    // Saturation
    vec3 greyscale = vec3(text.r + text.g + text.b) / 3.;
    text.rgb = mix(text.rgb, greyscale, saturation);
    // Contrast
    float midpoint = pow(0.5, 2.2);
    text.rgb = (text.rgb - vec3(midpoint)) * contrast + midpoint;

// Reduce the opacity of the color by modifying the alpha component
text.a *= 0.5; // Adjust the value

COLOR = text;
answered by (2.6k points)
0 votes

Adjusting the opacity of a shader in Godot can be done by modifying the alpha value of the color in the shader code

answered by (1.1k points)