Skip to main content
gamedev.net
🔒 Locked

Texture Mapping Alpha Artifacts

Started by RegularKid Oct 2, 2008 at 7:01 PM 0 replies 700+ views
Original Post
RegularKid
RegularKid
Hi! I'm trying to render a quad using a texture of a ring. The ring has some alpha fading around the edges to smooth it out. Great. However, when I try to render it I get some weird artifacts where the alpha pixels are. They render much darker than they should creating some dark spots around the edge of the ring. I've debugged it down to the min / mag filter I'm using ( GL_LINEAR ). This seems to be the culprit. However, when I try changing it to GL_NEAREST...the problem goes away but the image is now super blocky and very ugly looking :( Does anyone have a way to fix this problem? Any help would be great! Here is my gl setup code ( the important ones ):

glShadeModel( GL_SMOOTH );
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
glClearDepth( 1.0f );
glDisable( GL_DEPTH_TEST );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
glEnable( GL_TEXTURE_2D );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );

And when I load a texture in:

glGenTextures( 1, &textureId );
glBindTexture( GL_TEXTURE_2D, textureId );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
glBindTexture( GL_TEXTURE_2D, NULL );

Thanks!
RegularKid
RegularKid
Ah! Figured it out :)

The alpha in my image ( where nothing was drawn around the outside of the ring ) had a value of (0,0,0,0). Changing it to (255,255,255,0) fixed it!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.