[osg-users] RTT and stereo (corrected)

2 views
Skip to first unread message

Roman Grigoriev

unread,
Dec 11, 2008, 1:50:26 AM12/11/08
to osg-...@lists.openscenegraph.org

Sorry guys I simply replied to email.

Hi Robert!

I’m using following setup

I create a camera that I use for viewing my geometries – colorCamera1

Render to framebuffer colortexture and depthtexture

That  I use distortion – lens correction – distortionCamera

Than I apply depth-of-field (downsample,blur,apply dof)  in  finalCamera

Here is my camera’s setup

 

unsigned int width=800;

    unsigned int height=600;

      float g_ViewportWidth=width;

      float g_ViewportHeight=height;

      float tex_width=800;

      float tex_height=600;

      float tex_width_2=1600;

      float tex_height_2=1200;

     

viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);

       osg::ref_ptr<osg::GraphicsContext::Traits> traits = new

osg::GraphicsContext::Traits;

 traits->x = 0;

 traits->y = 0;

 traits->width =  width;

 traits->height = height;

 traits->windowDecoration = false;

 traits->doubleBuffer = true;

 traits->sharedContext = 0;

 

 traits->screenNum = 0;

 HWND m_hWnd;

 

//Create first context and add first View to the composite viewer

 

   osg::ref_ptr<osg::GraphicsContext> gc1 =

osg::GraphicsContext::createGraphicsContext(traits.get());

 

   if(gc1.valid())

   {

         osg::ref_ptr<osg::Camera> cam=viewer.getCamera();

         cam->setGraphicsContext(gc1.get());

         cam->setViewport(new osg::Viewport(0,0, traits->width,traits->height));

         GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;

 

    cam->setDrawBuffer(buffer);

    cam->setReadBuffer(buffer);

 

   }

   // viewer.setUpViewInWindow(10,10,g_ViewportWidth,g_ViewportHeight);

//osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(GetSafeHwnd());

 

   osgViewer::GraphicsWindowWin32* window = dynamic_cast<osgViewer::GraphicsWindowWin32*>(viewer.getCamera()->getGraphicsContext());

      hWnd=window->getHWND();

         typedef std::list< osg::ref_ptr<osg::OperationThread> > Threads;

 

      //   osg::DisplaySettings::instance()->setStereo(true);

      //   osg::DisplaySettings::instance()->setStereoMode(osg::DisplaySettings::StereoMode::HORIZONTAL_SPLIT);      

 

 

      osg::ref_ptr<osg::TextureRectangle> colorTexture = new osg::TextureRectangle;

    colorTexture->setTextureSize( tex_width_2,tex_height_2);

      colorTexture->setInternalFormat(GL_RGBA);

      colorTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

      colorTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

      colorTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);

    colorTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);

 

      osg::ref_ptr<osg::TextureRectangle> colorTexture2 = new osg::TextureRectangle;

    colorTexture2->setTextureSize( tex_width,tex_height);

      colorTexture2->setInternalFormat(GL_RGBA);

      colorTexture2->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

      colorTexture2->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

      colorTexture2->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);

    colorTexture2->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);

 

      osg::ref_ptr<osg::TextureRectangle> downTexture = new osg::TextureRectangle;

    downTexture->setTextureSize( tex_width/4.0f,tex_height/4.0f);

      downTexture->setInternalFormat(GL_RGBA);

      downTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

      downTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

      downTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);

    downTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);

 

 

      osg::ref_ptr<osg::TextureRectangle> depthTexture = new osg::TextureRectangle;

    depthTexture->setTextureSize( tex_width_2, tex_height_2);

      /*depthTexture->setInternalFormat(GL_RGBA32F_ARB);

    depthTexture->setSourceFormat(GL_RGBA);

    depthTexture->setSourceType(GL_FLOAT);

      */

      depthTexture->setInternalFormat(GL_DEPTH_COMPONENT);

      depthTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

      depthTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

 

            osg::ref_ptr<osg::TextureRectangle> blurXTexture = new osg::TextureRectangle;

        blurXTexture->setTextureSize(tex_width,tex_height);

       blurXTexture->setInternalFormat(GL_RGBA);

 

            blurXTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

            blurXTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

           

            osg::ref_ptr<osg::TextureRectangle> blurYTexture = new osg::TextureRectangle;

        blurYTexture->setTextureSize(tex_width/4,tex_height/4);

            blurYTexture->setInternalFormat(GL_RGBA);

            blurYTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);

            blurYTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

 

 

 

   colorCamera1->setViewport(0,0,tex_width_2,tex_height_2);

            colorCamera1->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);

      colorCamera1->setProjectionMatrixAsPerspective(50, 4.0f/3.0f,0.01f, 7000.f);

            int inheritanceMask =

      (osg::CullSettings::VariablesMask::ALL_VARIABLES &

      ~osg::CullSettings::VariablesMask::CULL_MASK);

            colorCamera1->setInheritanceMask(inheritanceMask);

            colorCamera1->setCullMask(0x01);

  // colorCamera1->setViewport(new osg::Viewport(0,0, tex_width_2,tex_height_2));

  // view->getCamera()->setProjectionMatrixAsPerspective(45,traits->width/traits->height, 10, 1000000);

    colorCamera1->setClearColor(osg::Vec4f(1.0f,0.0f,0.0f,1.0f));

    colorCamera1->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      colorCamera1->setReferenceFrame(osg::Transform::ABSOLUTE_RF);   

    colorCamera1->setRenderOrder(osg::Camera::POST_RENDER,10);

      //colorCamera1->setRenderOrder(osg::Camera::PRE_RENDER);

      colorCamera1->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

      colorCamera1->attach(osg::Camera::DEPTH_BUFFER,depthTexture.get());

      colorCamera1->attach(osg::Camera::COLOR_BUFFER,colorTexture.get());

           

     

      float samples =0;

      float colorsamples=0;

      //colorCamera1->attach(osg::Camera::COLOR_BUFFER, colorTexture.get());//, 0, 0, false, 0, 0);

     

      osg::ref_ptr<ViewPartitionNode> viewPartition = new ViewPartitionNode(colorTexture.get(),depthTexture.get(),tex_width_2,tex_height_2);

      viewPartition->addChild(viewnode.get());

      colorCamera1->addChild(viewPartition.get());

      //colorCamera1->addChild(viewnode.get());

      root->addChild(colorCamera1.get());

 

 {

                osg::ref_ptr<osg::Geode> geode = new osg::Geode;

    osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // vertex coords

    // counter-clockwise

    quad_coords->push_back(osg::Vec3d(0, 0, 0));

    quad_coords->push_back(osg::Vec3d(tex_width, 0, 0));

    quad_coords->push_back(osg::Vec3d(tex_width,tex_height, 0));

    quad_coords->push_back(osg::Vec3d(0, tex_height, 0));

 

    osg::ref_ptr<osg::Vec2Array> quad_tcoords = new osg::Vec2Array; // texture coords

    quad_tcoords->push_back(osg::Vec2(0, 0));

    quad_tcoords->push_back(osg::Vec2(tex_width, 0));

    quad_tcoords->push_back(osg::Vec2(tex_width, tex_height));

    quad_tcoords->push_back(osg::Vec2(0, tex_height));

 

    osg::ref_ptr<osg::Geometry> quad_geom = new osg::Geometry;

    osg::ref_ptr<osg::DrawArrays> quad_da = new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);

    quad_geom->setVertexArray(quad_coords.get());

    quad_geom->setTexCoordArray(0, quad_tcoords.get());

    quad_geom->addPrimitiveSet(quad_da.get());

        geode->addDrawable(quad_geom.get());

        quad_geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);

         quad_geom->getOrCreateStateSet()->setMode(GL_DEPTH,osg::StateAttribute::OFF);

         osg::ref_ptr<osg::Camera> distortionCamera=new osg::Camera;

                distortionCamera->setName("downsampleCamera");

                distortionCamera->setClearColor(osg::Vec4f(0.5f,0.5f,0.5f,1.0f));

                        distortionCamera->setProjectionMatrix(osg::Matrix::ortho2D(0,tex_width,0,tex_height));

                distortionCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

                distortionCamera->setViewMatrix(osg::Matrix::identity());

                distortionCamera->setViewport(new osg::Viewport(0,0, tex_width,tex_height));

                distortionCamera->setRenderOrder(osg::Camera::POST_RENDER,13);

                        distortionCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

                        distortionCamera->attach(osg::Camera::COLOR_BUFFER,colorTexture2.get());

                distortionCamera->addChild(geode.get());

 

                osg::ref_ptr<osg::StateSet> distortionstateset =distortionCamera->getOrCreateStateSet();

                        distortionstateset->setTextureAttributeAndModes(0,colorTexture.get(),osg::StateAttribute::ON);

                        distortionstateset->setTextureAttributeAndModes(1,depthTexture.get(),osg::StateAttribute::ON);

                        root->addChild(distortionCamera.get());

                        osg::Program* programDist = new osg::Program;

                        distortionstateset->setAttribute(programDist);

                        programDist->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX, osgDB::findDataFile("distortion_vp.txt")));

                        programDist->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT, osgDB::findDataFile("distortion_fp.txt")));

                        osg::Uniform* base_tex = new osg::Uniform("baseTexture",0);

                        distortionstateset->addUniform(base_tex);

                        osg::Uniform* depth_tex = new osg::Uniform("depthTexture",1);

                        distortionstateset->addUniform(depth_tex);

                        osg::Uniform* width_height_u = new osg::Uniform("width_height_sample",osg::Vec3(tex_width,tex_height,tex_width_2/tex_width));

                        distortionstateset->addUniform(width_height_u);

 

                        // Focal length of the camear

                        float focalLength=0.5;//15

                        // Focal range of the camera

                        float focalRange=0.2;//13

                        // zNear and zFar values

                        float zNear=0.01;

                        float zFar=100;

                        osg::Uniform* focalLength1_u = new osg::Uniform("Flength_Frange_zNear_zFar",osg::Vec4(focalLength,focalRange,zNear,zFar));

                        distortionstateset->addUniform(focalLength1_u);

                        focalLength1_u->setUpdateCallback(new UniformVarying_fl);

 

                        /*osg::Uniform* focalLength_u = new osg::Uniform("focalLength",focalLength);

                        distortionstateset->addUniform(focalLength_u);

                       

                        osg::Uniform* focalRange_u = new osg::Uniform("focalRange",focalRange);

                        distortionstateset->addUniform(focalRange_u);

                         focalLength1_u->setUpdateCallback(new UniformVarying_fl);

                        osg::Uniform* zNear_u = new osg::Uniform("zNear",zNear);

                        distortionstateset->addUniform(zNear_u);

 

                        osg::Uniform* zFar_u = new osg::Uniform("zFar",zFar);

                        distortionstateset->addUniform(zFar_u);

                        */

            }

 

 {

                osg::ref_ptr<osg::Geode> geode = new osg::Geode;

    osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // vertex coords

    // counter-clockwise

    quad_coords->push_back(osg::Vec3d(0, 0, 0));

    quad_coords->push_back(osg::Vec3d(tex_width/4.0, 0, 0));

    quad_coords->push_back(osg::Vec3d(tex_width/4.0,tex_height/4.0, 0));

    quad_coords->push_back(osg::Vec3d(0, tex_height/4.0, 0));

 

    osg::ref_ptr<osg::Vec2Array> quad_tcoords = new osg::Vec2Array; // texture coords

    quad_tcoords->push_back(osg::Vec2(0, 0));

    quad_tcoords->push_back(osg::Vec2(tex_width, 0));

    quad_tcoords->push_back(osg::Vec2(tex_width, tex_height));

    quad_tcoords->push_back(osg::Vec2(0, tex_height));

 

    osg::ref_ptr<osg::Geometry> quad_geom = new osg::Geometry;

    osg::ref_ptr<osg::DrawArrays> quad_da = new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);

    quad_geom->setVertexArray(quad_coords.get());

    quad_geom->setTexCoordArray(0, quad_tcoords.get());

    quad_geom->addPrimitiveSet(quad_da.get());

        geode->addDrawable(quad_geom.get());

        quad_geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);

         quad_geom->getOrCreateStateSet()->setMode(GL_DEPTH,osg::StateAttribute::OFF);

         osg::ref_ptr<osg::Camera> downsampleCamera=new osg::Camera;

                downsampleCamera->setName("downsampleCamera");

                downsampleCamera->setClearColor(osg::Vec4f(0.5f,0.5f,0.5f,1.0f));

                        downsampleCamera->setProjectionMatrix(osg::Matrix::ortho2D(0,tex_width/4.0,0,tex_height/4.0));

                downsampleCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

                downsampleCamera->setViewMatrix(osg::Matrix::identity());

                downsampleCamera->setViewport(new osg::Viewport(0,0, tex_width/4.0,tex_height/4.0));

                downsampleCamera->setRenderOrder(osg::Camera::POST_RENDER,14);

                        downsampleCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

                        downsampleCamera->attach(osg::Camera::COLOR_BUFFER,downTexture.get());

                downsampleCamera->addChild(geode.get());

 

                osg::ref_ptr<osg::StateSet> downsamplestateset =downsampleCamera->getOrCreateStateSet();

                        downsamplestateset->setTextureAttributeAndModes(0,colorTexture2.get(),osg::StateAttribute::ON);

                       

                        root->addChild(downsampleCamera.get());

                        osg::Program* programDN = new osg::Program;

                        downsamplestateset->setAttribute(programDN);

                        programDN->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX, osgDB::findDataFile("downSample_vp.txt")));

                        programDN->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT, osgDB::findDataFile("downSample_fp.txt")));

                        osg::Uniform* baseTextureSampler = new osg::Uniform("tex",0);

                        downsamplestateset->addUniform(baseTextureSampler);

            }

 

 {

                osg::ref_ptr<osg::Geode> geode = new osg::Geode;

    osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // vertex coords

    // counter-clockwise

   quad_coords->push_back(osg::Vec3d(0, 0, 0));

    quad_coords->push_back(osg::Vec3d(tex_width/4, 0, 0));

    quad_coords->push_back(osg::Vec3d(tex_width/4,tex_height/4, 0));

    quad_coords->push_back(osg::Vec3d(0, tex_height/4, 0));

 

    osg::ref_ptr<osg::Vec2Array> quad_tcoords = new osg::Vec2Array; // texture coords

    quad_tcoords->push_back(osg::Vec2(0, 0));

    quad_tcoords->push_back(osg::Vec2(tex_width/4, 0));

    quad_tcoords->push_back(osg::Vec2(tex_width/4, tex_height/4));

    quad_tcoords->push_back(osg::Vec2(0, tex_height/4));

 

    osg::ref_ptr<osg::Geometry> quad_geom = new osg::Geometry;

    osg::ref_ptr<osg::DrawArrays> quad_da = new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);

    quad_geom->setVertexArray(quad_coords.get());

    quad_geom->setTexCoordArray(0, quad_tcoords.get());

    quad_geom->addPrimitiveSet(quad_da.get());

        geode->addDrawable(quad_geom.get());

        quad_geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);

         quad_geom->getOrCreateStateSet()->setMode(GL_DEPTH,osg::StateAttribute::OFF);

                blurYCamera->setName("blurYCamera");

                blurYCamera->setClearColor(osg::Vec4f(0.5f,0.5f,0.5f,1.0f));

                        blurYCamera->setProjectionMatrix(osg::Matrix::ortho2D(0,tex_width/4,0,tex_height/4));

                blurYCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

                blurYCamera->setViewMatrix(osg::Matrix::identity());

                blurYCamera->setViewport(new osg::Viewport(0,0, tex_width/4.0,tex_height/4.0));

                blurYCamera->setRenderOrder(osg::Camera::POST_RENDER,16);

                        blurYCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

                        blurYCamera->attach(osg::Camera::COLOR_BUFFER,blurYTexture.get());

                blurYCamera->addChild(geode.get());

 

                osg::ref_ptr<osg::StateSet> blurYstateset =blurYCamera->getOrCreateStateSet();

                        blurYstateset->setTextureAttributeAndModes(0,downTexture.get(),osg::StateAttribute::ON);

                       

                        root->addChild(blurYCamera.get());

                        osg::Program* programGBY = new osg::Program;

                        blurYstateset->setAttribute(programGBY);

                        programGBY->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX, osgDB::findDataFile("blur.vsh")));

                        programGBY->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT, osgDB::findDataFile("blur.fsh")));

                        osg::Uniform* baseTextureSampler = new osg::Uniform("tex",0);

                        blurYstateset->addUniform(baseTextureSampler);

                       

            }

 

 

  osg::ref_ptr<osg::Geode> geode = new osg::Geode;

    osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // vertex coords

    // counter-clockwise

    quad_coords->push_back(osg::Vec3d(0, 0, -1));

    quad_coords->push_back(osg::Vec3d(g_ViewportWidth, 0, -1));

    quad_coords->push_back(osg::Vec3d(g_ViewportWidth,g_ViewportHeight, -1));

    quad_coords->push_back(osg::Vec3d(0, g_ViewportHeight, -1));

 

    osg::ref_ptr<osg::Vec2Array> quad_tcoords = new osg::Vec2Array; // texture coords

    quad_tcoords->push_back(osg::Vec2(0, 0));

    quad_tcoords->push_back(osg::Vec2(g_ViewportWidth, 0));

    quad_tcoords->push_back(osg::Vec2(g_ViewportWidth, g_ViewportHeight));

    quad_tcoords->push_back(osg::Vec2(0, g_ViewportHeight));

 

    osg::ref_ptr<osg::Geometry> quad_geom = new osg::Geometry;

    osg::ref_ptr<osg::DrawArrays> quad_da = new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);

    quad_geom->setVertexArray(quad_coords.get());

    quad_geom->setTexCoordArray(0, quad_tcoords.get());

    quad_geom->addPrimitiveSet(quad_da.get());

        geode->addDrawable(quad_geom.get());

 

  quad_geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);

 

                        osg::ref_ptr<osg::Camera> finalCamera=new osg::Camera;

                        finalCamera->setViewport(0,0, width,height);

                        finalCamera->setClearColor(osg::Vec4f(0.0f,0.0f,1.0f,1.0f));

                        finalCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

                        finalCamera->setProjectionMatrix(osg::Matrix::ortho2D(0,width,0,height));

                finalCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

                finalCamera->setViewMatrix(osg::Matrix::identity());

                finalCamera->setRenderOrder(osg::Camera::POST_RENDER,20);

                finalCamera->addChild(geode.get());

                        osg::ref_ptr<osg::StateSet> finalstateset =finalCamera->getOrCreateStateSet();

                        finalstateset->setTextureAttributeAndModes(0,colorTexture2.get(),osg::StateAttribute::ON);

                        finalstateset->setTextureAttributeAndModes(1,blurYTexture.get(),osg::StateAttribute::ON);

                        //finalstateset->setTextureAttributeAndModes(2,blurYTexture.get(),osg::StateAttribute::ON);

                  osg::ref_ptr<osg::StateSet> ssf = geode->getOrCreateStateSet(); 

                        osg::Program* programf = new osg::Program;

 

                        ssf->setAttribute(programf);

                             programf->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX, osgDB::findDataFile("poissonblur_vp.txt")));

                        programf->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT, osgDB::findDataFile("poissonblur_fp.txt")));

                        osg::Uniform* base_tex = new osg::Uniform("tex",0);

                        ssf->addUniform(base_tex);

                        osg::Uniform* depth_tex = new osg::Uniform("texLow",1);

                        ssf->addUniform(depth_tex);

                       

                        osg::Uniform* radiusScale_u = new osg::Uniform("radiusScale",1/tex_width);

                        ssf->addUniform(radiusScale_u);

                       

                       

                        root->addChild(geode.get());

                        root->addChild(finalCamera.get());

     

                        viewer.setSceneData(root.get());

 

Roman Grigoriev

unread,
Dec 11, 2008, 1:57:23 AM12/11/08
to OpenSceneGraph Users

So for now I solve problem by doing all postprocess operations for left and right eye and have huge frame drop to 25 fps L

Could someone please give me recommendations what is better render to one big texture both left and right eye (1600*600) or render to two small textures (800*600)?

Than in advance

Bye

Robert Osfield

unread,
Dec 11, 2008, 4:20:09 AM12/11/08
to OpenSceneGraph Users
Hi Roman,

On Thu, Dec 11, 2008 at 6:57 AM, Roman Grigoriev <grig...@gosniias.ru> wrote:
> So for now I solve problem by doing all postprocess operations for left and
> right eye and have huge frame drop to 25 fps L

Stereo rendering normally incurrs a performacne hit, as you are
doubling the amount of work done. Is ther performance
disproportional?

> Could someone please give me recommendations what is better render to one
> big texture both left and right eye (1600*600) or render to two small
> textures (800*600)?

Design wise it would be much easier to have one texture pure eye.
Performance wise it probably won't make too much difference as the
bottlenecks aren't likely to be related to setup of FBO's/teuxtures.
You "might" see a performance improvement with using a single texture,
but I doubt it would be worthwhile.

I'd recommend looking at your wider performance bottlenecks. What is
your cull/draw costs? Due you have two graphics cards and a multi-core
GPU available?

Robert.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Roman Grigoriev

unread,
Dec 11, 2008, 4:41:26 AM12/11/08
to OpenSceneGraph Users
Thanx Robert for your reply.
With single view I have 50 fps with stereo I have 25 fps. It is very
predictable result.
Event 0.05
Update 1.36 (two Intersense InertiaCube3 sensors)
Cull 5.2 (clouds)
Draw 2.16 (ephemeris,clouds)
GPU 27.2
I simply try to improve it.
I have single 8600GT. But for stereo config I will use double GTX280. Hopes
that It will change situation.
Bye

Robert Osfield

unread,
Dec 11, 2008, 5:33:28 AM12/11/08
to OpenSceneGraph Users
Hi Roman,

The performance you are getting it not to surprising. Your GPU costs
are obviously the biggest bottleneck.

Moving to a single GTX280 will radically improve this, there is little
reason why you shouldn't be able to do 60Hz in stereo. Using two
GTX280 would give you an even wider margin for hitting a solid 60Hz.

Once you move to the 280's you probably find that the GPU is no longer
the bottleneck and your cull could well be the longest element, but if
you're hitting a solid 60Hz in stereo already no need to worry.

When doing stereo with two 280's use two viewer Camera's to make the
most of multi-threading performance that the OSG has to offer.


Robert.

Roman Grigoriev

unread,
Dec 11, 2008, 6:20:47 AM12/11/08
to OpenSceneGraph Users
>When doing stereo with two 280's use two viewer Camera's to make the
>most of multi-threading performance that the OSG has to offer.
Could you please explain it?
But if I have 2 views I have to share scenegraph between windows. So OSG
simply duplicate geometries?
Or maybe I don't understand something?
Roman

Robert Osfield

unread,
Dec 11, 2008, 6:58:24 AM12/11/08
to OpenSceneGraph Users
Hi Roman,

When doing stereo you would typically use a single View with a single
master Camera that controls the what the overall view of the scene is.
This View would then have two slave Cameras that are offset from the
master Camera's view/projection matrix to provide the appropriate
view. The scene graph is shared between the two slave Cameras. If
the slave Camera have different graphics contexts then you can have
separate OpenGL objects per context, but the OSG will automatically
manage this all for you, it also offers the opportunity for threading
the graphics contexts.

Robert.

Roman Grigoriev

unread,
Dec 11, 2008, 8:02:14 AM12/11/08
to OpenSceneGraph Users
Thanx Robert!
I try to use this config:
CompositeViewer (2 View)
First View1 800*600 (left eye first DVI output) Left eye camera
Second View2 800*600 (right eye second DVI output) right eye camera
So I only need to execute
view1.setSceneData(root);
view2.setSceneData(root);

Robert Osfield

unread,
Dec 11, 2008, 8:07:12 AM12/11/08
to OpenSceneGraph Users
HI Roman,

As I send in my previous email you shouldn't use two separate views
for what you are doing, it's neither conceptually a good fit, nor
programatically. Use a single View with two slave Camaras, it's
simpler coding wise, and you conceptually just have a single view,
either though it's composed of two eye images. Lots has been
discussed on this topic on osg-users in the past so please do a search
for the topics of Camera / Viewer / CompositeViewer.

Robert.

Roman Grigoriev

unread,
Dec 11, 2008, 8:31:05 AM12/11/08
to OpenSceneGraph Users
Thanx Robert!
I'll make like you said.
P.S. Could you please tell me in what situation I should use
CompositeViewer? Because as far as I got for opengl it's better to have one
big window than two small windows?

Максим Гаммер

unread,
Dec 11, 2008, 8:37:27 AM12/11/08
to OpenSceneGraph Users
or Matrix Head2GO )))
 
Gammer Max.

2008/12/11 Roman Grigoriev <grig...@gosniias.ru>



--
Гаммер Максим Дмитриевич
Начальник отдела ИТ НИИ ЭОР

Robert Osfield

unread,
Dec 11, 2008, 9:53:47 AM12/11/08
to OpenSceneGraph Users
Hi Roman,

On Thu, Dec 11, 2008 at 1:31 PM, Roman Grigoriev <grig...@gosniias.ru> wrote:
> P.S. Could you please tell me in what situation I should use
> CompositeViewer?

Please search my previous explanations of CompositeViewer vs Viewer.

> Because as far as I got for opengl it's better to have one
> big window than two small windows?

It depends... If you have one graphics card, a single window with two
viewports will be more efficient than two windows. If you have two
graphics cards then use two windows with a single viewport on each.

osgViewer is written so that is very easy to move between using two
Camera's sharing a single GraphicsWIndow, or two Camera's each with
their own GrpahicsWindow. The only thing you change is creation and
assigned on windows/viewports, everything else stays the same.
osgViewer will manage all the implementation details for you,
including threading.

Reply all
Reply to author
Forward
0 new messages