Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Wierd Alpha Blending problem

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2003
    Posts
    8

    Wierd Alpha Blending problem

    I have this image with a circular alpha channel in the middle



    and when i load it in with some alpha blending it looks like this

    [IMG] http://www.redbrick.dcu.ie/~creech/wierd.jpg
    [/IMG]

    i use the following to blend it:
    Code :
    		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    		glEnable(GL_ALPHA_TEST);
    		glAlphaFunc(GL_GREATER, 0);
    and this is my init code

    Code :
    	glEnable(GL_TEXTURE_2D);
    	glShadeModel(GL_FLAT);							// Enable Smooth Shading
    	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);				// Black Background
    	glClearDepth(1.0f);									// Depth Buffer Setup
    	glDepthFunc(GL_LESS);								// The Type Of Depth Testing To Do
    	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
    	//glEnable(GL_CULL_FACE);
    	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
    i know that its fading out to black because of the clear colour but what is with the banding?? And can i stop it from fading to black at all? and actually use the alpha channels?

    [This message has been edited by weebull (edited 03-22-2003).]

    [This message has been edited by weebull (edited 03-22-2003).]

  2. #2
    Guest

    Re: Wierd Alpha Blending problem

    I'm not certain, but I expect it's fading out to black because you haven't enabled blending with glEnable(GL_BLEND).

    Don't know why the banding appears. What is the pixel depth of the display surface?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Dec 2002
    Location
    Espoo, Finland
    Posts
    599

    Re: Wierd Alpha Blending problem

    Hi,

    I'd say the banding is because your texture gets loaded as 16bit for some reason. Propably your display is set to 16bit colors. 16bit alpha textures look bad, because you only have four bits per color channel. Certain drivers load all textures as 16bit by default, to improve your changes to get 32bit textures, use GL_RGBA8 internal format.

    The black edge is propably there, because you draw the circle on a black background with depth test enabled, and after that you draw the background, which gets behind the pixels that have already been blended with a black background. Always draw opaque objects first, and then the transparent ones, preferably with depth writes disabled and sorted back to front.

    -Ilkka

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2003
    Posts
    8

    Re: Wierd Alpha Blending problem

    ah nice one justhanging it was because i was drawing it first n opengl was doing its wierd blending!!

    though now i have to sort out the issue of drawing the hud stuff last and getting it to billboard and move with the camera

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •