Search code examples
glsllwjgl

Function to add mix with alpha


#version 140

in vec2 textureCoords;

out vec4 out_Color;

float alpha = 0.5;

uniform sampler2D guiTexture;

void main(void){

    out_Color = texture(guiTexture,textureCoords);

}

I am pretty (very) new to GLSL.

I want to basically add a transparency value (float) to the following code above (don't bother running it I just had to get it in). The value float should be the float a (4th component) in the out_Color variable. However due to the code currently in there which is 4 components I am not sure how to. Is there a function that will allow me to do this.


Solution

  • You should take a look at pretty much any basic GLSL tutorial

    out_Color = vec4(texture(guiTexture,textureCoords).rgb, alpha);