Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Anaglyphs without glColorMask?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    14

    Anaglyphs without glColorMask?

    Hi,

    I want to develop an anaglyph application where I can control color values. This mean for example to set blue little bit darker etc.

    I mean how can I create anaglyphs without glColorMask ?

    Can anybody help me?
    Thanks!

  2. #2
    V-man
    Guest

    Re: Anaglyphs without glColorMask?

    In your shaders, you could set red to 0.0 and green to 0.0 on the first pass.
    In the second pass, green is 0.0 and blue is 0.0.
    The second pass would need to be rendered to a RTT.
    Then render the RTT onto the framebuffer with glBlendFunc(GL_ONE, GL_ONE). That will add up.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    14

    Re: Anaglyphs without glColorMask?

    I'm a beginner in OGL.
    How can I set shaders? Which do you mean. Maybe I don't know what you mean but already used it.

    What is RTT?

    Thanks for your answer

  4. #4
    Senior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    258

    Re: Anaglyphs without glColorMask?

    RTT = render to texture.
    If you are a beginner, I'd stick to glColorMask. It is a bit crappy, i mean you can't do optimised anaglyp with it, but at the same time it's extremly fast.

    If you want to do this you need to render the scene to texture (maybe one texture for left eye, one for right), then write a shader (GLSL) to remap the colours.

    http://www.3dtv.at/knowhow/anaglyphcomparison_en.aspx

    Look for optimised anaglyph on that page, it's the one least likely to give you eye cancer. If you look at the images, you can see that red has totally disappeared. The idea is to make the brightness of the left and right eye the same. It's still gonna screw with your eyes, but it wont suck as hard as regular anaglyph.

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    14

    Re: Anaglyphs without glColorMask?

    Thanks.

    I would like to use glColorMask.
    But my exercise is to develop an optimised anaglyph application.

    I think I have to learn GLSL.

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2010
    Posts
    8

    Re: Anaglyphs without glColorMask?

    Now I know how to work with shaders and I want to use it for colorcode anaglyphs.

    But I don't understand why I have to render to texture and how shader knows the two textures (left and right eye).

    Can you help me again?

  7. #7
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Anaglyphs without glColorMask?

    Why : because it will allow fine tuning of the colors for best anaglyph reproduction.
    How shaders know the left and right eye : because you will tell it.

    Outline of a shader-based solution :
    1) render left eye scene to texture 1, full color
    2) render right eye scene to texture 2, full color
    3) bind texture 1 and 2
    4) use shader that samples left eye from texture 1, and right eye for texture 2
    5) color code is yellow/blue right ? so roughly the GLSL fragment shader will look like that :
    Code :
    lefteye = texture2D(leftTexture, currentTexcoord).rg * 0.7; // take only red and green components from left eye
    righteye = texture2D(rightTexture, currentTexcoord).b; // take only blue component from left eye
    gl_FragColor = lefteye+righteye;

    EDIT : why you did not use simple glColorMask solution ? FOr such a simple setup, it will work well and be easier to implement (no need for RTT or shaders, just render twice with different color mask).

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2010
    Posts
    8

    Re: Anaglyphs without glColorMask?

    I don't use the glcolormask method because the colors doesn't fit to the color of the glasses. So I want to change colors during runtime of the applikation. And this doesn't work with colormask. Only with accumulation buffer.



    I developed anaglyphs where I can change the colors (for example red little bit darker) - to adjust it to the color glasses.

    So I simply draw one object in one color (e.g. red) and one in
    the other color (e.g. blue).


    Now if I have an existing application. Of course I can change all colors and textures manually. But I want to do it easier like this.

    And my question is if this is possibile when I want to adjust colors for glasses.

    Maybe with shaders? And someone give me an example.

  9. #9
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Anaglyphs without glColorMask?

    You post sound like you did not read my post just above, because I exactly outlined the solution for you.
    I conveniently numbered each important step.
    Please, can you tell which part(s) you need explained with more details ??

    However you have to know that the color spectrum for each primary screen color (red green blue) is fixed. No amount of color tuning can help if more than one of these colors shows through both filters significantly.
    Even if the eye response is the same, you can have very different spectrums for the same apparent color.

    Most of the time, pure red versus pure blue works without ghosting, but incorporating the green component often brings ghosting. Finely tuned filters for your screen should be used to avoid this.

  10. #10
    Junior Member Newbie
    Join Date
    Oct 2010
    Posts
    8

    Re: Anaglyphs without glColorMask?

    Now I read a lot about glsl and wrote a shader for my anaglyphs. I'm doing the following steps:
    1. rendering left eye into a texture with GL_LUMINANCE value
    2. rendering right eye into a texture with GL_LUMINANCE value
    3. activate shader
    4. render resulting texture on a full-screen quad

    But the problem I have is that the background color is always present in the calculation with the shader.
    For example if I have red-blue anaglyphs. If I have a white background (left image) after activating of the shader it should be pink. But it is red and the blue side seems transparent in some way.
    If I change the background to black (right image), red overlaying part changes to blue.

    The two cubes in front look good. The color of them doesn't change. So I thought it must depend on the background color.

    I tried to change blending and alpha values but I didn't get a correct result.

    Can somebody help me? I don't know what I'm doing wrong.

    My shader:
    Code :
    uniform sampler2D left;
    uniform sampler2D right;
     
    void main(void)
    {
      vec4 cleft = texture2D(left, gl_TexCoord[0].st).rgba;
      vec4 cright = texture2D(right, gl_TexCoord[0].st).rgba;
      vec3 col;
     
      col.r = (cleft.r + cleft.g + cleft.b) / 3.0;
      col.g = 0.0;
      col.b = (cright.r + cright.g + cright.b) / 3.0;
     
      gl_FragColor = vec4(col, cleft.a+cright.a);
    }


Page 1 of 2 12 LastLast

Similar Threads

  1. Simplest way to convert 2D into anaglyphs
    By Cris000 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-17-2011, 10:11 AM
  2. ColorCode Anaglyphs
    By Cris000 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-19-2010, 12:30 PM
  3. Anaglyphs
    By WT in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-15-2006, 10:46 AM
  4. anaglyphs with shader
    By raoulduke in forum OpenGL: GLSL
    Replies: 2
    Last Post: 09-20-2005, 11:16 PM
  5. Anaglyphs in OpenGL
    By Piku in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-13-2001, 07:11 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