Jump to content
  • Advertisement
Sign in to follow this  
X Abstract X

GLSL Textures and Alpha Blending

This topic is 3047 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

EDIT: I fixed this. I was using SDL_DisplayFormat() to convert some surfaces before creating textures and apparently it messes up their alpha value or something. Fixed by using SDL_DisplayFormatAlpha() or SDL_CreateRGBSurface().

Yesterday I made a post about having some alpha blending issues and I think I might have found the problem to be in my GLSL fragment shader. My problem was, when I used glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) all of my geometry would disappear. None of the other blending functions seemed to work properly either.

My Fragment Shader

#version 130

uniform sampler2D colorMap;

in vec4 frag_texCoord;
in vec4 frag_color;

out vec4 out_color;

void main() {
vec4 texel = texture2D(colorMap, frag_texCoord.st);
out_color = vec4(texel.rgb * frag_color.rgb, frag_color.a);
//out_color = frag_color * texel;

So, the line I commented out above was what I had before, when I had problems with alpha blending. Was my shader wrong before, or is it wrong now? Can someone explain this to me, doesn't the texel have an alpha component?

[Edited by - X Abstract X on July 19, 2010 9:17:41 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!