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 1 of 1

Thread: Fragment shader + alpha bending problem...

  1. #1
    Newbie Newbie
    Join Date
    Jun 2016
    Posts
    6

    Fragment shader + alpha bending problem...

    Hi,

    I have a problem, I use shader to mix 3 textures (YUV) to generate a RGBA color with A forced to 1.0 and I use an other shader to render texture with alpha RGBA.

    If two triangles render with second shader is overlapped i have a pretty transparency.

    if i have a triangle with transparency render over a triangle using YUV to RGB, the transparent is done on background (in my case black- i try to change black to red to verify).

    Could you help me ?

    Thanks,

    PS: I can send screen shoot by e-mail if need, i don't have web server to host it...

    The shader for YUV:
    ---------------------
    Code glsl:
    uniform sampler2D texPlane0;    // Y.
    uniform sampler2D texPlane1;    // U.
    uniform sampler2D texPlane2;    // V.
    varying vec2 varTexCoord;
    void main() 
    {
        float fY = 1.164 * ( texture2D ( texPlane0, varTexCoord ).r - 0.0625 );
        float fU =           texture2D ( texPlane1, varTexCoord ).r - 0.5;
        float fV =           texture2D ( texPlane2, varTexCoord ).r - 0.5;
        gl_FragColor = vec4 ( fY + 1.793 * fV, fY - 0.213 * fU + 0.533 * fV, fY + 2.112 * fU, 1.0);
    }

    I use this shader for other texture (RGBA):
    Code glsl:
    uniform sampler2D texPlane;
    varying vec2 varTexCoord;
    void main() 
    {
        gl_FragColor = texture2D ( texPlane, varTexCoord );
    }

    I use this code on OpenGL ( and OpenGLES with a different header) :
    ---------------------------------------------------------------------------
    Code cpp:
    glEnable ( GL_DEPTH_TEST );
    glEnable ( GL_CULL_FACE );
    glFrontFace ( GL_CW );
    glEnable ( GL_BLEND );
    glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    Render loop :
    ---------------
    Code cpp:
    glClearColor ( 0.0F, 0.0F, 0.0F, 1.0F );
    glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
     
    ... render mesh ...
    Last edited by Dark Photon; 05-27-2017 at 06:15 PM.

Tags for this Thread

Posting Permissions

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