Cheap 3D stereoscopic checkerboard mode for OpenGL
#1
Hi, I had some thoughts about an OpenGL 3D checkerboard mode. The "cheap" method would be similar to the RENDER_STEREO_MODE_INTERLACED one, with some minor drawbacks to the image quality.

The code from RenderSystemGL.cpp would look like this:
Code:
/* ... */

static const GLubyte stipple_checkerboard[] = {
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
  0xAA, 0xAA, 0xAA, 0xAA,
  0x55, 0x55, 0x55, 0x55,
};

void CRenderSystemGL::SetStereoMode(RENDER_STEREO_MODE mode, RENDER_STEREO_VIEW view)
{
  CRenderSystemBase::SetStereoMode(mode, view);

  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
  glDisable(GL_POLYGON_STIPPLE);
  glDrawBuffer(GL_BACK);

  /* ... */

  if(m_stereoMode == RENDER_STEREO_MODE_CHECKERBOARD)
  {
    glEnable(GL_POLYGON_STIPPLE);
    if(m_stereoView == RENDER_STEREO_VIEW_LEFT)
      glPolygonStipple(stipple_checkerboard);
    else if(m_stereoView == RENDER_STEREO_VIEW_RIGHT)
      glPolygonStipple(stipple_checkerboard+4);
  }

}

/* ... */

bool CRenderSystemGL::ClearBuffers(color_t color)
{

  /* ... */

  /* clear is not affected by stipple pattern, so we can only clear on first frame */
  if(m_stereoMode == RENDER_STEREO_MODE_CHECKERBOARD && m_stereoView == RENDER_STEREO_VIEW_RIGHT)
    return true;

  /* ... */
}

/* ... */

bool CRenderSystemGL::SupportsStereo(RENDER_STEREO_MODE mode)
{
  switch(mode)
  {
    case RENDER_STEREO_MODE_ANAGLYPH_RED_CYAN:
    case RENDER_STEREO_MODE_ANAGLYPH_GREEN_MAGENTA:
    case RENDER_STEREO_MODE_INTERLACED:
    case RENDER_STEREO_MODE_CHECKERBOARD:
      return true;
   /* ... */
  }
}

There have to be some minor additions to StereoscopicsManager.cpp, RenderSystem.h and maybe AMLCodec.cpp, but nothing complex. Everything is done without shaders, it should perform pretty good. The quality of the image could be increased by blurring in the unused neighboring pixels of each field (like this: http://www.ulrichmierendorff.com/softwar..._blur.html).

Unfortunately, I'm not able to compile Gotham right now. The code is not tested in any way, it is merely a proposition. I'm setting up my account on Github, give me some time for that.
Reply
#2
(2014-06-07, 23:48)membrane Wrote: The "cheap" method would be similar to the RENDER_STEREO_MODE_INTERLACED one, with some minor drawbacks to the image quality.

I've couldn't find more informations on the topic. Some sources say that the odmitted pixels shouldn't have any influence on the resulting image, but i doubt that. Converting a SBS/TAB source to the checkerboard mode requires seperate methodes to achive the best possible image quality:

Full SBS: blend both vertical and both horizontal nighbouring pixels in.
Half SBS: blend both vertical and one horizontal nighbouring pixels in.
Half TAB: blend one vertical and both horizontal nighbouring pixels in.

This could be done with seperate modes for each source or some logic.


Some TVs support just this 3D mode. Even TVs with shutter glasses could profit from this if the source is full SBS. Unfortunatly, I don't have a 3D TV to test this, so I'm flying blind here.
Reply
#3
I've made a PR: https://github.com/xbmc/xbmc/pull/4903.
Reply
#4
Thanks for your contribution! Some of the folk that deal in this area are a bit busy atm, but will get to it in time.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
I already commented on the PR and pinged elupus, but as JM said, he's quite busy atm. Given the stipple is working as intended PR is looking fine in general (besides of my comments), can't test myself because I'm not running any supporting OS
Reply

Logout Mark Read Team Forum Stats Members Help
Cheap 3D stereoscopic checkerboard mode for OpenGL0