2014-06-07, 23:48
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:
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.
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.