OGRE and Quad Buffer Stereo

What it says on the tin: a place to discuss proposed new features.
User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

OGRE and Quad Buffer Stereo

Post by crefvik » Sat Jul 20, 2013 12:02 am

Hi guys,

My name is Christian and I'm a software engineer at zSpace, Inc.. I've been asked to look into quad buffer support for OGRE using both OpenGL and Direct3D. After downloading the source, OGRE doesn't appear to support this today.

However, It seems like there is quite a bit of interest for this based on what I've been reading on the forums. I didn't see this on the OGRE road map, but I'd like to help develop a solution for everyone that is usable for OpenGL as well as Direct3D 9 and 11. Here's my design document proposal for adding stereo to OGRE.

What is the process for developing new features for OGRE in a way they be approved back into trunk? Who should I talk to?

Thanks,
Christian
Last edited by crefvik on Wed Aug 14, 2013 1:15 am, edited 1 time in total.
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: OGRE and Quad Buffer Stereo

Post by Wolfmanfx » Sat Jul 20, 2013 12:08 am

Hi,

You can read this one http://www.ogre3d.org/developers/submit-patch for submitting patches. Furthermore we need a signed Contributor_License (http://www.ogre3d.org/downloads/OGRE_Co ... icense.pdf).

Best way would be to start a fork and when you did something you can make a pull request.
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Mon Jul 22, 2013 11:39 pm

Hi Murat,

Thanks for the reply - I will definitely submit the contributor license. I saw the Submit Patch or Bug / JIRA page, but there wasn't any mention of any design document that needed to be reviewed before just modifying the source and requesting it to be pulled back into the trunk.

In any case, I can certainly get started on forking the current source to get started.

Thanks for the help,
Christian
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Tue Aug 13, 2013 11:35 pm

Hi guys,

I've created a design document for adding stereo to OGRE. My proposal covers both OpenGL and Direct3D.

Please take a look and let me know if you have any concerns. Please let me know if you have a problem accessing the document.

Thanks,
Christian
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: OGRE and Quad Buffer Stereo

Post by Wolfmanfx » Wed Aug 14, 2013 7:53 am

Hi,

I just readed it looking good.
Here some points:
* This feature should be a compiletime option - so make sure you guard enum / code which belongs to it
* Make sure cmake can handle the new deps

Otherwise i am looking forward to see the your pull request.
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Wed Sep 25, 2013 7:28 pm

Hi Murat,

I have made much progress on this project. Per your request, all the code related to this feature is a compile time option. Per your request, I have made sure that the CMakeLists.txt of the OGRE SDK handles these new dependencies similar to the other OGRE external dependencies. I have made sure that the new dependencies have also been added to the ogredeps repository in order to make it easier for developers to build with the Direct3D stereo related code.

At this point, I have the following configurations enabled for stereo:
  • OpenGL - Windows
  • OpenGL - Linux
  • OpenGL - Mac (Cocoa and Carbon)
  • Direct3D 9 - NVIDIA
  • Direct3D 11 - NVIDIA
I am currently working on Direct3D for AMD. I have tested the above configurations using hardware that supports frame sequential stereo (ie. quad buffer stereo).

Specifically, I've tested the following hardware:
  • NVIDIA 3DVision Glasses
  • NVIDIA 3DVision Pro Glasses
  • Benq XL2420-B Display
  • Acer GD235Hz Display
  • NVIDIA Quadro 4000
  • AMD Radeon HD 7700
  • MacBook Pro with NVIDIA GeForce GT 330m
  • MacBook Pro with AMD Radeon HD 6700m
  • zSpace Display
In order to work in a stable environment, I am using 1.81 to do the development. However, I will be migrating by code to the 2.0 and the default branches.

If you have any questions, please let me know.

Thanks,
Christian
0 x

v3_xd
Kobold
Posts: 26
Joined: Thu Nov 07, 2013 5:11 am
Location: Guayaquil

Re: OGRE and Quad Buffer Stereo

Post by v3_xd » Mon Nov 18, 2013 10:24 pm

Hello, I'm working on a project with nvidia 3d glasses on ubuntu and I'm using a quad GPU is your code available?
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Mon Nov 18, 2013 11:20 pm

Sure, if anyone is interested, my code is available here:
https://bitbucket.org/crefvik/ogre
https://bitbucket.org/crefvik/ogredeps

I've modified the ogredeps to add the NVAPI and AMD Quad Buffer SDK libraries. Currently, all my changes exist on the 1.8 branch. I'm working with Murat to see what we can do to get them ported to 1.10 and merged into the official repository.

If you have any questions about the code, please let me know.

Thanks,
Christian
0 x

v3_xd
Kobold
Posts: 26
Joined: Thu Nov 07, 2013 5:11 am
Location: Guayaquil

Re: OGRE and Quad Buffer Stereo

Post by v3_xd » Tue Nov 19, 2013 12:51 am

Hello Christian. Thanks for sharing your work. Do you have any example code for the NVIDIA 3DVision Glasses using this version of ogre? Thanks
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Tue Nov 19, 2013 4:27 am

Sure, no problem. The full sample code is below - its fairly simple. Its really the same kind of thing that you would do for any other OGRE sample application. The only new thing is the following:

Code: Select all

viewport->setDrawBuffer(colourBuffer);
The values of colourBuffer can be:
  • Ogre::CBT_BACK
    Ogre::CBT_BACK_LEFT
    Ogre::CBT_BACK_RIGHT
This is basically what you would need to do with OpenGL, so I just abstracted it for OGRE with the English spelling. Stereo is not automatic, so the application should be able to easily disable or enable it. The other nice thing about choosing the buffer is that if the eyes are swapped in the application, you can unswap them by switching between the left and right buffers for all the stereo viewports. And to switch to 2D, you simply only draw to the back buffer.

Anyway - the full code is below, so let me know if you have any questions or problems. There maybe some code that is commented out and feel free to play with the stereo settings.

Thanks,
Christian

Code: Select all

#include "Ogre/Ogre.h"

#include "OIS/OISEvents.h"
#include "OIS/OISInputManager.h"
#include "OIS/OISKeyboard.h"
#include "OIS/OISMouse.h"

class AnimationFrameListener : public Ogre::FrameListener
{
  public:
    AnimationFrameListener(Ogre::Entity* sinbadEntity, bool* isSinbadRunning)
    {
      // Cache the application state
      m_isSinbadRunning = isSinbadRunning;

      // Get the running animiations for the base of Sinbad and the top of Sinbad
      m_sinbadRunBaseAnimationState = sinbadEntity->getAnimationState("RunBase");
      m_sinbadRunTopAnimationState = sinbadEntity->getAnimationState("RunTop");
    }

    bool frameStarted(const Ogre::FrameEvent& evt)
    {
      // If Sinbad is running, enable the animation
      m_sinbadRunBaseAnimationState->setEnabled(*m_isSinbadRunning);
      m_sinbadRunTopAnimationState->setEnabled(*m_isSinbadRunning);

      if (*m_isSinbadRunning)
      {
        // If Sinbad is running, reset the animation if necessary
        if (m_sinbadRunBaseAnimationState->hasEnded())
          m_sinbadRunBaseAnimationState->setTimePosition(0.0f);

        if (m_sinbadRunTopAnimationState->hasEnded())
          m_sinbadRunTopAnimationState->setTimePosition(0.0f);
      }
      else
      {
        // If Sinbad is not running, reset the animation
        m_sinbadRunBaseAnimationState->setTimePosition(0.0f);
        m_sinbadRunTopAnimationState->setTimePosition(0.0f);
      }

      m_sinbadRunBaseAnimationState->addTime(evt.timeSinceLastFrame);
      m_sinbadRunTopAnimationState->addTime(evt.timeSinceLastFrame);

      return true;
    }

    bool* m_isSinbadRunning;

    Ogre::AnimationState* m_sinbadRunBaseAnimationState;
    Ogre::AnimationState* m_sinbadRunTopAnimationState;
};


class OISFrameListener : public Ogre::FrameListener
{
  public:
    OISFrameListener(Ogre::RenderWindow* window, Ogre::SceneNode* sinbadNode, bool* isStereoEnabled, bool* isSinbadRunning)
    {
      // Cache the objects
      m_window = window;
      m_sinbadNode = sinbadNode;
      m_isStereoEnabled = isStereoEnabled;
      m_isSinbadRunning = isSinbadRunning;

      // Reset the timer, rotation, and set the speeds
      m_timer.reset();
      m_sinbadRotation = Ogre::Radian(0);
      m_sinbadRunningSpeed = 50.0f;
      m_cameraSpeed = 200.0f;

      // Get the OGRE window handle
      size_t windowHnd = 0;
      m_window->getCustomAttribute("WINDOW", &windowHnd);

      // Convert the OGRE window handle to a string
      std::stringstream windowHndStr;
      windowHndStr << windowHnd;

      // Create an OIS input manager from the OGRE window handle string
      OIS::ParamList paramList;
      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
      m_inputManager = OIS::InputManager::createInputSystem(paramList);

      // Create the OIS keyboard and mouse unbuffered input objects
      m_keyboard = static_cast<OIS::Keyboard*>(m_inputManager->createInputObject(OIS::OISKeyboard, false));
      m_mouse = static_cast<OIS::Mouse*>(m_inputManager->createInputObject(OIS::OISMouse, false));
    }

    ~OISFrameListener()
    {
      // Cleanup the OIS keyboard, mouse, and input manager
      m_inputManager->destroyInputObject(m_keyboard);
      m_inputManager->destroyInputObject(m_mouse);
      OIS::InputManager::destroyInputSystem(m_inputManager);
    }

    bool frameStarted(const Ogre::FrameEvent& evt)
    {
      // Capture keyboard and mouse input
      m_keyboard->capture();
      m_mouse->capture();

      // Quit the application
      if (m_keyboard->isKeyDown(OIS::KC_ESCAPE))
        return false;

      // Toggle fullscreen
      if (m_keyboard->isKeyDown(OIS::KC_F) && m_timer.getMilliseconds() > 250)
      {
        bool isFullScreen = m_window->isFullScreen();
        m_window->setFullscreen(!isFullScreen, 1920, 1080);
        m_timer.reset();
      }

      // If stereo is enabled, swap left and right color buffers
      if (m_keyboard->isKeyDown(OIS::KC_M) && m_timer.getMilliseconds() > 250)
      {
        if (m_window->isStereoEnabled())
        {
          for (unsigned short i = 0; i < m_window->getNumViewports(); i++)
          {
            Ogre::Viewport* viewport = m_window->getViewport(i);
            if (Ogre::CBT_BACK_LEFT == viewport->getDrawBuffer())
              viewport->setDrawBuffer(Ogre::CBT_BACK_RIGHT);
            else if (Ogre::CBT_BACK_RIGHT == viewport->getDrawBuffer())
              viewport->setDrawBuffer(Ogre::CBT_BACK_LEFT);
          }
        }

        m_timer.reset();
      }

      // Enable / disable stereo
      if (m_keyboard->isKeyDown(OIS::KC_Z) && m_timer.getMilliseconds() > 250)
      {
        *m_isStereoEnabled = !(*m_isStereoEnabled);
        for (unsigned short i = 0; i < m_window->getNumViewports(); i++)
        {
          Ogre::Viewport* viewport = m_window->getViewport(i);
          if (0 == i && Ogre::CBT_BACK == viewport->getDrawBuffer())
            viewport->setDrawBuffer(Ogre::CBT_BACK_LEFT);
          else if (1 == i && Ogre::CBT_BACK == viewport->getDrawBuffer())
            viewport->setDrawBuffer(Ogre::CBT_BACK_RIGHT);
          else
            viewport->setDrawBuffer(Ogre::CBT_BACK);
        }

        m_timer.reset();
      }

      // Move Sinbad around the scene
      Ogre::Vector3 sinbadTranslate(0, 0, 0);
      if (m_keyboard->isKeyDown(OIS::KC_UP))
      {
        m_sinbadRotation = Ogre::Radian(Ogre::Math::PI);
        sinbadTranslate += Ogre::Vector3(0, 0, -1);
      }

      if (m_keyboard->isKeyDown(OIS::KC_DOWN))
      {
        m_sinbadRotation = Ogre::Radian(0);
        sinbadTranslate += Ogre::Vector3(0, 0, 1);
      }

      if (m_keyboard->isKeyDown(OIS::KC_LEFT))
      {
        m_sinbadRotation = Ogre::Radian(-Ogre::Math::HALF_PI);
        sinbadTranslate += Ogre::Vector3(-1, 0, 0);
      }

      if (m_keyboard->isKeyDown(OIS::KC_RIGHT))
      {
        m_sinbadRotation = Ogre::Radian(Ogre::Math::HALF_PI);
        sinbadTranslate += Ogre::Vector3(1, 0, 0);
      }

      *m_isSinbadRunning = !sinbadTranslate.isZeroLength();
      m_sinbadNode->translate(sinbadTranslate * evt.timeSinceLastFrame * m_sinbadRunningSpeed);
      m_sinbadNode->resetOrientation();
      m_sinbadNode->yaw(Ogre::Radian(m_sinbadRotation));

      // Move the camera around the scene
      Ogre::Vector3 cameraTranslate(0, 0, 0);
      if (m_keyboard->isKeyDown(OIS::KC_W))
        cameraTranslate += Ogre::Vector3(0, 0, -1);

      if (m_keyboard->isKeyDown(OIS::KC_S))
        cameraTranslate += Ogre::Vector3(0, 0, 1);

      if (m_keyboard->isKeyDown(OIS::KC_A))
        cameraTranslate += Ogre::Vector3(-1, 0, 0);

      if (m_keyboard->isKeyDown(OIS::KC_D))
        cameraTranslate += Ogre::Vector3(1, 0, 0);

      if (m_keyboard->isKeyDown(OIS::KC_PGDOWN))
        cameraTranslate += Ogre::Vector3(0, -1, 0);

      if (m_keyboard->isKeyDown(OIS::KC_PGUP))
        cameraTranslate += Ogre::Vector3(0, 1, 0);

      // Rotate the camera using the mouse
      float rotX = m_mouse->getMouseState().X.rel * evt.timeSinceLastFrame * -1;
      float rotY = m_mouse->getMouseState().Y.rel * evt.timeSinceLastFrame * -1;
      for (unsigned short i = 0; i < m_window->getNumViewports(); i++)
      {
        Ogre::Camera* camera = m_window->getViewport(i)->getCamera();
        camera->yaw(Ogre::Radian(rotX));
        camera->pitch(Ogre::Radian(rotY));
        camera->moveRelative(cameraTranslate * evt.timeSinceLastFrame * m_cameraSpeed);
      }

      return true;
    }

    bool* m_isStereoEnabled;
    bool* m_isSinbadRunning;
    float m_sinbadRunningSpeed;
    float m_cameraSpeed;

    OIS::InputManager* m_inputManager;
    OIS::Keyboard* m_keyboard;
    OIS::Mouse* m_mouse;

    Ogre::Radian m_sinbadRotation;
    Ogre::RenderWindow* m_window;
    Ogre::SceneNode* m_sinbadNode;
    Ogre::Timer m_timer;
};


void loadResources(const Ogre::String& configFilename)
{
  // Add all the resources in the resource configuration file
  Ogre::ConfigFile configFile;
  configFile.load(configFilename);
  Ogre::ConfigFile::SectionIterator sectionIter = configFile.getSectionIterator();
  Ogre::String secName, typeName, archName;
  while (sectionIter.hasMoreElements())
  {
    secName = sectionIter.peekNextKey();
    Ogre::ConfigFile::SettingsMultiMap* settings = sectionIter.getNext();
    Ogre::ConfigFile::SettingsMultiMap::iterator i;
    for (i = settings->begin(); i != settings->end(); ++i)
    {
      typeName = i->first;
      archName = i->second;
      Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
    }
  }

  // Index all added resources
  Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}


void createScene(Ogre::SceneManager* sceneManager, Ogre::Entity*& sinbadEntity, Ogre::SceneNode*& sinbadNode)
{
  // Create a plane for the floor, attach a material, and add it to the scene
//Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -50);
  Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -15);
  Ogre::MeshManager::getSingleton().createPlane("Floor", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 1500, 1500, 200, 200, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
  Ogre::Entity* floorEntity = sceneManager->createEntity("FloorEntity", "Floor");
  floorEntity->setMaterialName("Examples/BeachStones");
  sceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(floorEntity);

  // Create a directional light
  Ogre::Light* light = sceneManager->createLight("Light");
  light->setType(Ogre::Light::LT_DIRECTIONAL);
  light->setDiffuseColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
  light->setDirection(Ogre::Vector3(1, -1, 0));

  // Create an instance of the Sinbad mesh and add it to the scene
  sinbadEntity = sceneManager->createEntity("Sinbad", "Sinbad.mesh");
  sinbadNode = sceneManager->getRootSceneNode()->createChildSceneNode("SinbadNode");
//sinbadNode->setPosition(Ogre::Vector3(0.0f, 5.0f, 0.0f));
  sinbadNode->setPosition(Ogre::Vector3(0.0f, 0.0f, 0.0f));
  sinbadNode->setScale(Ogre::Vector3(3.0f, 3.0f, 3.0f));
  sinbadNode->attachObject(sinbadEntity);

  // Add shadows to the scene
  sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
}


void createViewport
(
  Ogre::RenderWindow* window,
  Ogre::SceneManager* sceneManager,
  const Ogre::String& name,
  const Ogre::Real focalLength,
  const Ogre::Vector2 frustumOffset,
  int zOrder,
  Ogre::ColourBufferType colourBuffer,
  Ogre::Viewport*& viewport
)
{
  // Create a camera and position it in the scene
  Ogre::Camera* camera = sceneManager->createCamera(name);
  camera->setPosition(0 + frustumOffset.x, 0, 100);
  camera->lookAt(0, 0, 0);
  camera->moveRelative(Ogre::Vector3(0, 25.0f, 30.0f));
  camera->pitch(Ogre::Radian(Ogre::Degree(-60.0f)));
  camera->setNearClipDistance(5.0f);

  // Create a viewport, set the background color to black, and set the aspect ratio
  viewport = window->addViewport(camera, zOrder);
  viewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
  camera->setAspectRatio(Ogre::Real(viewport->getActualWidth()) / Ogre::Real(viewport->getActualHeight()));

  // Set the color buffer type that will be used during rendering
  viewport->setDrawBuffer(colourBuffer);
}


int main(void)
{
  // Create an instance of OGRE root
  Ogre::Root* root = new Ogre::Root("plugins_d.cfg");

  // Show the configuration dialog, but if it doesn't work close the app
  if (!root->showConfigDialog())
    return -1;

  // Create a render window and verify that stereo is enabled
  Ogre::RenderWindow* window = root->initialise(true, "zSpace Example");
  bool isStereoEnabled = window->isStereoEnabled();

  // Load the resources for the scene
  loadResources("resources_d.cfg");

  // Create the scene manager and the scene
  Ogre::SceneManager* sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
  Ogre::Entity* sinbadEntity = NULL;
  Ogre::SceneNode* sinbadNode = NULL;
  createScene(sceneManager, sinbadEntity, sinbadNode);

  // Create the cameras and viewports
  Ogre::Real focalLength = 10.0f;
  Ogre::Vector2 frustumOffset(-3.0f, 0.0f);
  Ogre::Viewport* leftViewport = NULL;
  createViewport(window, sceneManager, "LeftCamera", focalLength, frustumOffset, 0, Ogre::CBT_BACK_LEFT, leftViewport);
  frustumOffset.x = 3.0f;
  Ogre::Viewport* rightViewport = NULL;
  createViewport(window, sceneManager, "RightCamera", focalLength, frustumOffset, 1, Ogre::CBT_BACK_RIGHT, rightViewport);

  bool isSinbadRunning = false;
  Ogre::FrameListener* animationFrameListener = new AnimationFrameListener(sinbadEntity, &isSinbadRunning);
  root->addFrameListener(animationFrameListener);

  Ogre::FrameListener* oisFrameListener = new OISFrameListener(window, sinbadNode, &isStereoEnabled, &isSinbadRunning);
  root->addFrameListener(oisFrameListener);

  // Start OGRE rendering
  root->startRendering();

  root->removeFrameListener(animationFrameListener);
  delete animationFrameListener;

  root->removeFrameListener(oisFrameListener);
  delete oisFrameListener;

  // Delete the root object
  delete root;

  return 0;
}
0 x

v3_xd
Kobold
Posts: 26
Joined: Thu Nov 07, 2013 5:11 am
Location: Guayaquil

Re: OGRE and Quad Buffer Stereo

Post by v3_xd » Tue Nov 19, 2013 4:38 pm

Hello Christian,

Thanks for sharing your code. I ran it but I get errors like:

error: ‘class Ogre::Viewport’ has no member named ‘getDrawBuffer’ and error: ‘CBT_BACK_LEFT’ is not a member of ‘Ogre’

I've looked at OgreViewport.cpp and I can't find getDrawBuffer. I cloned the source code from the link you provided and I ran one of the tutorials and it works.

Maybe I don't have the same version as you? Or maybe I'm doing something wrong.

thanks
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Tue Nov 19, 2013 6:44 pm

Hi v3_xd,

When you build OGRE using the source I pointed you to, you need to make sure the CMAKE argument for building the necessary stereo code is enabled, as shown in the screenshot below. This was done because it was requested by Murat initially when I created this post. Its also generally a good idea when adding new features.
ogre_stereo_enable.png
ogre_stereo_enable.png (50.56 KiB) Viewed 9055 times
You also need to make sure that you are using the v1-8 branch. I developed the code on that branch, because it was the most stable at the time. I can certainly merge the code to any newer release.

Hope that helps,
Christian
0 x

scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 2

Re: OGRE and Quad Buffer Stereo

Post by scrawl » Tue Nov 19, 2013 6:49 pm

Is there a major incompatibility between Stereo-enabled and non-enabled builds? Otherwise you should really avoid adding build options. It means you won't be able to use it with SDKs or Ogre builds packaged in repositories.
Unless the default would be changed to ON, but in that case, why are you adding the option anyway? No one will bother turning it off.
Its also generally a good idea when adding new features.
I strongly disagree.
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Tue Nov 19, 2013 7:07 pm

Hi Scrawl,

You're right, the code doesn't automatically enable stereo, the application must do this. In fact, many people do not have stereo hardware, so I would never force stereo to be enabled. In order to create stereo OGRE application, you basically do two things:
  • Enable the stereo setting in the renderer (ie. enable the setting for the pixel format in OpenGL or enable the driver for Direct3D)
  • Create at least two viewports in the application - set one viewport to the left buffer and another viewport to the right buffer
However, the reason I added the CMake option was because Murat told me to guard the code. The same thing approach was taken with RTSS, so there is precedent. If the OGRE team decides I can check in the feature without guarded the code, its easy enough to remove.

Thanks,
Christian
0 x

scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 2

Re: OGRE and Quad Buffer Stereo

Post by scrawl » Tue Nov 19, 2013 7:14 pm

Yeah the thing is, the RTSS is huge. Your feature has an extremely small amount of code. Therefore, I really don't see the point for a build option. Having to manually fiddle with the build for something trivial like that is not a good idea.
0 x

v3_xd
Kobold
Posts: 26
Joined: Thu Nov 07, 2013 5:11 am
Location: Guayaquil

Re: OGRE and Quad Buffer Stereo

Post by v3_xd » Tue Nov 19, 2013 7:44 pm

Hello Christian,
You also need to make sure that you are using the v1-8 branch
The source I got from this link:
https://bitbucket.org/crefvik/ogre
might be ogre 1.9. or 1.10 I was working on version 1.8.1 and I had to do the overlay modification to my project to work with the ogre I downloaded from your link.
I searched the cmakelist for the OGRE_STEREO_ENABLE option and didn't find it. Also, your last comment on bitbucket was
Merge v1-9 to v1-10
thanks
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: OGRE and Quad Buffer Stereo

Post by Wolfmanfx » Tue Nov 19, 2013 8:53 pm

This must be a build time option because it depends on NV / AMD headers which we do not include in our prebuilds. Also our StateCache is a compiletime option which also not huge - not everybody need QuadBufferStereo the prebuilds are for the main stream.
0 x

v3_xd
Kobold
Posts: 26
Joined: Thu Nov 07, 2013 5:11 am
Location: Guayaquil

Re: OGRE and Quad Buffer Stereo

Post by v3_xd » Tue Nov 19, 2013 9:01 pm

does this work for nvidia 3d vision under linux? quad GPU
0 x

scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 2

Re: OGRE and Quad Buffer Stereo

Post by scrawl » Tue Nov 19, 2013 9:54 pm

This must be a build time option because it depends on NV / AMD headers which we do not include in our prebuilds
The headers are only needed for the DirectX implementation. GL supports it natively, so for the GL version at least, we could make the default option "On". Or better yet, remove the option and add another option ENABLE_DIRECTX_STEREO. Also, you can check in CMake if the headers are found and if so, enable the option automatically (which is how most CMake build options work).
StateCache is still a compile option because it was (and perhaps on some platforms still is) buggy (masterfalcon answered this somewhere).
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: OGRE and Quad Buffer Stereo

Post by Wolfmanfx » Tue Nov 19, 2013 10:16 pm

Without any testing on our side this will still stay a compile time option for 1.10 and optional. The state cache is optional because we need a ground truth for testing it was my idea to create a NullStateCacheManager in the first so we do not break too much in the first iteration and it still has bugs - so it means its not stable and should stay optional until we are 200% sure it wont break anything.
0 x

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Tue Nov 19, 2013 10:27 pm

Hi v3_xd,
I searched the cmakelist for the OGRE_STEREO_ENABLE option and didn't find it
The source and the commits can be found below:
https://bitbucket.org/crefvik/ogre/src?at=v1-8
https://bitbucket.org/crefvik/ogre/commits/branch/v1-8

You should be able to look at the source code and any code wrapped around OGRE_STEREO_ENABLE belongs to the feature.
does this work for nvidia 3d vision under linux? quad GPU
I have tested Linux (Ubuntu 12.04 LTS) using OpenGL quad buffer stereo using an NVIDIA Quadro 4000. I used the Onboard DIN connector to enable the stereo output, as shown below.
linux.png
linux.png (68.79 KiB) Viewed 9021 times
However, I did not use the NVIDIA 3DVision glasses. However, my understanding is that you would need to install the Linux USB driver for the 3DVision glasses and they should work. If you are finding this is not the case, I can try it. I have both the 3DVision and 3DVision Pro glasses. Let me know the hardware you are using.

Thanks,
Christian
0 x

scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 2

Re: OGRE and Quad Buffer Stereo

Post by scrawl » Tue Nov 19, 2013 11:34 pm

Wolfmanfx wrote:Without any testing on our side this will still stay a compile time option for 1.10 and optional.
As crefvik wrote, his code doesn't enable stereo unless you request it in the parameters. So it is optional in any case.
One level of indirection is enough here. The process for testing should be "change your program's code to set the Stereo option to true", rather than "change build option, recompile Ogre, then change your program's code". With the latter, it's unlikely to receive much testing at all, tbh.
I'm not completely sure about your point with NV/AMD headers not being included in the SDK (what's the reason for that? Are they too big?), so that may warrant a build option on the DX side, but on the GL side where it's natively supported: please do not hide features behind a build option unless you absolutely need to.
0 x

v3_xd
Kobold
Posts: 26
Joined: Thu Nov 07, 2013 5:11 am
Location: Guayaquil

Re: OGRE and Quad Buffer Stereo

Post by v3_xd » Wed Nov 20, 2013 11:48 pm

Hi Christian,

I have tested the code and it works well for me. Thanks for sharing :)
0 x

RigoCL
Greenskin
Posts: 114
Joined: Mon Oct 14, 2013 1:41 am
Location: Chile

Re: OGRE and Quad Buffer Stereo

Post by RigoCL » Wed Jan 08, 2014 12:23 am

Hi!

I've implemented the Stereo Vision Manager of this post, I still haven't ported it to Ogre 1.8 or even 1.9:

http://www.ogre3d.org/forums/viewtopic.php?f=5&t=32284

So, may I ask what is the difference of this new Quad Buffer Stereo compared to the older version I mentioned above? is it faster, more accurate, more realistic, or just newer?
Don't take me wrong, I'm just asking...

Besides, is this new code easily portable to Ogre 1.9??
0 x
Integrated: Ogre3D + dotScene (Blender loader) + MyGUI (UI) + RakNet (Client/Server) + Leap Motion (The future is here!) + StereoManager (3D Anaglyph red-cyan)
WIP: StereoManager (Real 3D) + CCS (Camera Control System) + Sound, experimenting with Android.

User avatar
crefvik
Kobold
Posts: 25
Joined: Sat Jul 13, 2013 1:12 am
Location: Santa Clara, CA
Contact:

Re: OGRE and Quad Buffer Stereo

Post by crefvik » Wed Jan 08, 2014 1:53 am

Hi RigoCL,
So, may I ask what is the difference of this new Quad Buffer Stereo compared to the older version I mentioned above? is it faster, more accurate, more realistic, or just newer?
Don't take me wrong, I'm just asking...
I didn't look at your patch, but from the post it looks like you support anaglyph stereo. The first version I'm posting supports quad buffer, so I could try to work with you in order to incorporate anaglyph.

The way I supported OGRE stereo was in my design document that I posted at the top of this thread. Basically I wanted allow the developer to create two separate viewports and indicate whether each viewport is dedicated to the left buffer or the right buffer. This also allows the application to support a unique camera and frustum per eye. Also, if you create multiple viewports, you can also create a stereo PIP window. Also, allowing the application to control the left and right buffer setting on the viewport solves the swapped eyes problem which is a common problem with frame sequential (ie. quad buffer) displays. There is also a flag to indicate whether stereo is supported in case the user moves the window from a stereoscopic display to a non-stereoscopic display, which is common in multi-monitor system setups. Render system wise I supported both Direct3D and OpenGL so you can easily use either implementation.

How did you implement stereo in your patch? Is it similar? I certainly appreciate any feedback - especially if you have stereo knowledge :wink:
Besides, is this new code easily portable to Ogre 1.9??
Yes, but right now I've got it working in 1.8 and the latest default. I can port it to 1.9, if you're interested.

If you have any questions about the implementation, please let me know.

Thanks,
Christian
0 x

Post Reply