Results 1 to 3 of 3

Thread: Bug with gl.blendFunc?

  1. #1
    Junior Member
    Join Date
    Oct 2010

    Bug with gl.blendFunc?

    In the webgl port of my engine, I've found that alpha textures brighten what is behind them. This is not the desired behavior and is different from what I'm getting in my OpenGL engine. I'm using...

    gl.blendFunc ( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA );

    Is this a known bug or am I possibly forgetting something else that would affect the render? The shader is very straight-forward...

  2. #2
    Senior Member
    Join Date
    May 2010

    Re: Bug with gl.blendFunc?

    I haven't seen that bug - but one that's related is that some browser versions incorrectly assign you a "destination alpha" buffer even though you didn't ask for one. Also, "destination alpha" is only very rarely used in OpenGL and DirectX programs - yet it is the default for WebGL contexts.

    So, two suggestions:

    1) When you create your context...use something like:

    var gl = canvas.getContext ( "experimental-webgl",
    alpha : false ,
    antialias : true ,
    depth : true ,
    stencil : false ,
    premultipliedAlpha: false } ) ;

    ...note particularly "alpha:false".

    2) To work-around the bug, if it's still there, use this to clear the screen each frame:

    gl.colorMask ( 1,1,1,1 ) ; // Note the last '1' enables writes to dest-alpha buffer.
    gl.clearColor ( r,g,b,1 ) ; // r,g,b can be whatever - but we're setting alpha=1
    gl.colorMask ( 1,1,1,0 ) ; // Note the last '0' disables writing to dest-alpha
    ...render your scene...

    If that's not it - it's possible you have some kind of weird premultiplied alpha issue with your textures.

  3. #3
    Junior Member
    Join Date
    Oct 2010

    Re: Bug with gl.blendFunc?

    The first suggestion worked. Thanks a lot!

Similar Threads

  1. Compilation bug?
    By barraqueiro in forum OpenCL
    Replies: 1
    Last Post: 08-30-2012, 03:25 PM
  2. clEnqueueReleaseD3D10ObjectsKHR bug?
    By opencl_beginner in forum OpenCL
    Replies: 1
    Last Post: 12-13-2010, 03:42 AM
  3. Strange Bug
    By PantheraOnca in forum OpenCL
    Replies: 3
    Last Post: 12-09-2010, 11:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean