Skip to main content
Up and Coming
July 12, 2013

Anaglyph 3D in the Rift

I'm adding support for viewing anaglyph 3D in Deskope. I have zero experience with anaglyph 3D and there's not much online about what I'm doing since it's kind of a weird thing to do.

Anyway, since I don't know how it's supposed to look, I'm not a very good tester. Can you tell from these screenshots and my shader code if I'm doing it right?

Deskope 2013-07-12 10-01-36-26.png
Deskope 2013-07-12 10-01-47-15.png
Deskope 2013-07-12 10-01-57-93.png

sampler Tex0;
float4 BlendColor : register(c0);

// fetch texture and blend with a color
float4 main( float2 Texture : TEXCOORD0 ) : COLOR0
{
return tex2D(Tex0, Texture) * BlendColor;
}

    15 replies

    Up and Coming
    July 12, 2013
    "AngelJ" wrote:
    ... It helps to know that colors are supposed to look natural after your eyes blend the images together. Like I said, I have no experience with anaglyph.

    If you need a reference for skin tone comparisons, just view a portion of most any "Debbie Does..." movie on a good quality calibrated monitor. :o

    Then view some anaglyph skin, and try to adjust for the best match you can. ;)
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    AngelJAuthor
    Up and Coming
    July 12, 2013
    "geekmaster" wrote:
    If you need a reference for skin tone comparisons, just view a portion of most any "Debbie Does..." movie on a good quality calibrated monitor.

    Then view some anaglyph skin, and try to adjust for the best match you can.


    Developing for the Rift is turning out to be more fun than I expected! :lol:
    Up and Coming
    July 12, 2013
    Or for even more "skin tone" fun, if you happen to be a Sylvester Stallone fan, perhaps you can track down a copy of his first (porn) film re-titled "The Italian Stallion" after his Rocky movies.
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    AngelJAuthor
    Up and Coming
    July 12, 2013
    "geekmaster" wrote:
    Or for even more "skin tone" fun, if you happen to be a Sylvester Stallone fan, perhaps you can track down a copy of his first (porn) film re-titled "The Italian Stallion" after his Rocky movies.

    :o I'm surprised more people don't know about this. Now I'm gonna tell everyone!
    Participant
    August 22, 2013
    I am guessing all this is about converting anaglyph images into separate left/right images for the Rift?...

    FWIW, it should be possible to fudge with the math in such a way as to try to reconstruct more natural-looking images (as seen in the Rift).

    possible thoughts:
    in particular, red and green;
    these tend to dominate over general perception of gamma (brightness), much more so than blue;
    red and green also tend to be strongly positively correlated, and red/green and blue weakly positively correlated.

    this means it should be passable to partly spread red over to green, and green over to red, without messing up color too much. blue can be partly bled over, and partly estimated.

    if it were possible to estimate and compensate for left/right divergence, it should be possible to find the matching color-point in the "adjacent" image and make use of its color-information. doing this in real-time (such as for a movie) would be difficult, but it could be possible to estimate it as a global translation from the image-data (such as by calculating/probing a certain number of pixels each frame, and deciding which direction to shift the images).

    or, make a guess, and use a constant value (this is a lot easier for images with a consistent eye-distance).


    the cheaper solution though would be simply to allow for a certain amount of color-bleed in the calculations.

    say (simple case, green/magenta, untested):

    inPix=input pixel;
    lPix=vec4(
    0.4*inPix.g + 0.25*inPix.r + 0.10*inPix.b,
    inPix.g,
    0.25*inPix.g + 0.25*inPix.b);
    rPix=vec4(
    inPix.r,
    0.4*inPix.r + 0.25*inPix.g + 0.15*inPix.b,
    inPix.b);


    then, fiddle with it until things look reasonably natural...


    potentially, a tool could be written to use statistical means to help generate a filter, which would work best if one has both the input left/right images and the anaglyph output (for a collection of images), and then tries to calculate the ideal weighting factors for regenerating the original input images from the anaglyph output.

    potentially then, it could also be practical to process multiple sets of input pixels (rather than just 1 or 2 pixels at a time, we could take account for 4 or 6 pixels into account), and then maybe use a collection of matrix multiplies and similar to blend between them. likely the tool would scan over ranges of input pixels and identify which are most often the most strongly correlated, ... then spit this out in a form which can be later fed back into the shader.

    in-shader, it is likely to look something like:
    pix0=texture(img, st+st0);
    pix1=texture(img, st+st1);
    ...
    outPixel=pix0*mat0 + pix1*mat1 + pix2*mat2 + ...;


    or such...