Results 1 to 3 of 3

Thread: Anaglyph rendering and glBlendFunc()

  1. #1
    Newbie Newbie
    Join Date
    May 2015
    Posts
    2

    Anaglyph rendering and glBlendFunc()

    Hello,

    I am developing application for my University project where I am doing anaglyph rendering.
    In my project I am using:
    • FREEGLUT
    • Using OpenGL 3.3 with Shaders #330
    • Using C++



    I am a beginner with OpenGL API, but I think I have learned the basics so please bear that in mind.
    So the problem I am having with is the function
    Code :
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE);
    which causes unwanted transparancy between different objects rendered.

    My rendering function follows like this (I am also using face culling):
    Code :
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);
    glClear(clearOptions | GL_DEPTH_BUFFER_BIT);
     
    glUseProgram(shaderProgram);
     
    // Sets active the left eye perspective matrix
    // draw scene
     
    glClear(GL_DEPTH_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE);
     
    // Sets active the right eye perspective matrix
    // draw scene
     
    glUseProgram(0);
     
    glutSwapBuffers();
    glutPostRedisplay();

    In the attachments I have highlighted the problematic areas.
    My question is what can I do so that the blending only happens with the two images of the same object (since I am doing anaglyph rendering, I have to render each object twice, I want the blending to happen only with these two images for each object).

    I hope I was clear enough, if you need more information then please ask.

    Thanks!
    Attached Images Attached Images

  2. #2
    Newbie Newbie
    Join Date
    May 2015
    Posts
    2
    Could this be solved by rendering the scene to two textures and than processing them in a shader?
    Using this methord I think I wouldnt need to use the blending....

    Got this idea from this thread: https://www.opengl.org/discussion_bo...ut-glColorMask

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,103
    I suggest using glColorMask().

    Another option is to render each view to a separate texture then blend the textures as a final pass (this requires FBOs, but it doesn't require shaders).

    But there's really no reason not to use glColorMask(). What the creator of the thread you linked to seemed to forget is that you can't actually choose the colours if the output is to a monitor. You're stuck with the monitor's primaries, and if your glasses don't match the primaries, you need different glasses. Attempting to use a different colour will just end up using a mix of primaries which will result in bleeding (the tristimulus model doesn't work for anaglyphs; a mix of primaries which looks like a particular colour to the naked eye isn't actually the same thing as a monochromatic source of that colour).

Similar Threads

  1. anaglyph in gl
    By tincy in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-04-2010, 01:24 PM
  2. anaglyph rendering problem
    By raoulduke in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-28-2005, 04:15 AM
  3. Chromatic Anaglyph
    By ffkiller in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-16-2003, 06:47 AM
  4. BW Anaglyph creation ...
    By imported_Christoph in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-13-2002, 04:24 AM
  5. Anaglyph suggestion please.
    By Ace_Man in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-01-2001, 05:25 AM

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