Search Unity

Transparencies when drawing an FBO in an FBO

Discussion in 'General Graphics' started by NaBUru38, Aug 21, 2015.

  1. NaBUru38

    NaBUru38

    Joined:
    Jan 26, 2014
    Posts:
    12
    Hello, I'm developing a graphics program and I'm having issues with transparencies.

    According to this, if you want to draw an FBO on the screen, you must to this:

    void draw()
    {

    // draw image on FBO

    textureFbo.begin();
    ofEnableAlphaBlending();

    image.draw(0, 0);

    ofDisableAlphaBlending();
    textureFbo.end();

    // draw FBO on screen

    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

    textureFbo.draw(0,0);

    glDisable(GL_BLEND);
    }

    However, that code isn't working to me, because I'm doing something more complicated. I'm drawing videos on an FBO, and then draw them on another FBO, and then draw them on a quad (ofxGLWarper).

    void draw()
    {

    // draw videos on a scene FBO

    sceneFbo->begin();

    drawVideos ();

    sceneFbo->end ();

    // draw the scene FBO on a second FBO

    alphaFbo->begin();

    sceneFbo->draw(0, 0);

    alphaFbo->end();

    // draw the second FBO on a quad

    quad->begin();

    alphaFbo->draw(0, 0);

    quad->end();
    }

    Actually it's even more complicated, because I don't just draw videos in the scene, but also more FBOs. And the alphaFbo may use an alpha mask.


    So I'm trying different combinations of glEnable, glBlendFunc and glEnableAlphaBlending but they don't work.

    Any suggestions on how to draw an FBO in an FBO with transparencies? Or where can I learn about blending functions? Thanks!
     
  2. Dolkar

    Dolkar

    Joined:
    Jun 8, 2013
    Posts:
    576
    Maybe you should ask this in the openFrameworks forum and not here, where most people know next to nothing about it.
     
  3. NaBUru38

    NaBUru38

    Joined:
    Jan 26, 2014
    Posts:
    12
    Oops, my mistake. I've been using both Unity and OpenFrameworks the past few weeks, and my head is shaky.