locked
Direct3X Shooting Game Sample - Stereo3D Question

    Question

  • Hello,

    I noticed in the Shooting Game Sample that there is a time difference between the left and right eye renders.  In other words, objects will be in different positions in each eye.  This causes some eyestrain.  Is it a bug in the sample, or am I missing an option somewhere?

    Thanks in advance,

    Tuesday, February 05, 2013 10:38 PM

All replies

  • Objects are supposed to be in different positions when rendering stereoscopic content; it's what creates the 3D depth effect. But I'm guessing you mean that they are in the wrong different positions. On my system everything seems fine, but different graphics adapters and screens will handle things differently. In the sample, the StereoProjection.cpp and .h files provide for ways to configure and calibrate the 3D effect. The sample uses some default values and doesn't provide any configuration capabilities, which a real game would typically do by implementing the Settings contract to add custom game settings to the SettingsPane.

    I recommend you tinker with the values in Camera::SetProjParams until you find values that work properly for you. When writing a game that includes stereoscopy, you should expose a way to configure these settings through a custom settings pane.


    XNA/DirectX MVP | Website | Blog | @mikebmcl

    Tuesday, February 05, 2013 11:21 PM
  • Thanks, Mike.

    Sorry, I wasn't clear.  I definitely see a proper stereo separation (disparity) in the objects.  However, the objects that are rendered in the right eye are rendered at a different point in time.  Here's a flow of what I'm seeing:

    1. Render Left Eye

    2. Objects in motion advance one frame

    3. Render Right Eye.

    What I should see:

    1. Render Left Eye

    2. Render Right Eye

    3. Objects in motion advance one frame.

    Does that help?

    Thanks,

    Wednesday, February 06, 2013 5:14 PM
  • The relevant code that might help us track it down is in several places. (Working from: http://code.msdn.microsoft.com/windowsapps/Metro-style-DirectX-7c64aa8d

    DirectXBase::CreateWindowSizeDependentResources creates a stereo swap chain (if stereo is supported) and it also creates the two RTVs (one for each eye) as a single Texture2D array. So we know that if stereo is supported then both will be simultaneously presented.

    GameRenderer::Render loops through each eye such that both should be rendering based on the same data. The only thing that seemingly could be going wrong is the call to update ConstantBufferChangeOnResize where the DirectXMath code makes use of the return values of m_game->GameCamera()->LeftEyeProjection() and m_game->GameCamera()->RightEyeProjection() . Note that I'm not saying these are wrong, just that we cannot evaluate their correctness simply by looking at GamerRenderer::Render. They appear to be being used properly but if there's something wrong with how they are updating it, then we'd only know that by looking at that code.

    DirectXBase::Present also appears to be doing everything correctly since Present is only called at the end of GameRenderer::Render once both targets are updated.

    Next we're on to Camera::SetProjParams. This appears to be updating both projection matrices just fine. The LeftEyeProjection and RightEyeProjection member functions are simply accessors for the internal value so everything in Camera appears fine.

    This leads us to the game loop itself. Simple3DGame::RunGame is where the runtime logic is executed. First the timer is updated, then (if the game is still running) various Camera and Player parameters are updated. None of these is specific to a particular eye so this shouldn't present any problem either.

    In the end, I don't see anything in the sample that could be causing a problem. But perhaps my analysis will give you the insight you need to solve it.


    XNA/DirectX MVP | Website | Blog | @mikebmcl

    • Marked as answer by Jesse JiangModerator Tuesday, February 12, 2013 9:37 AM
    • Unmarked as answer by Jhaan Saturday, February 23, 2013 12:32 AM
    Wednesday, February 06, 2013 6:12 PM
  • Hi Mike,

    I'm back at this project after a bit and am wondering if the GameTimer is our culprit.  Should there be a pause in the GameTimer before rendering the right eye?

    Thanks again,

    Friday, February 22, 2013 10:21 PM
  • The left eye and right eye should both get the same time value per frame. If the left eye is getting one value and the right eye is getting a different value, then any animations (translation, rotation, scaling) which are modified based on the time value will likely give wrong results. But like I said in my earlier post, there's nothing wrong in the sample code itself so the best way to find the problem is to examine the code you have modified. The problem will be somewhere in there. If you're giving the left eye and right eye two different time values when rendering the same frame, that's a likely culprit.

    XNA/DirectX MVP | Website | Blog | @mikebmcl

    Saturday, February 23, 2013 10:49 AM
  • Thanks, Mike.

    But I see this behavior on the base sample with no modifications.  I'm using a Playstation 3D Monitor, for reference.

    Monday, February 25, 2013 7:59 PM
  • Have you made sure your graphics card drivers are up to date? Are there any settings in the graphics drivers that allow you to adjust stereoscopic settings? If the base sample doesn't work, then it's likely a hardware/driver issue. Have you tried anything else with 3D on your computer (e.g. a 3D bluray) and if so does it work?


    XNA/DirectX MVP | Website | Blog | @mikebmcl

    Wednesday, February 27, 2013 6:39 PM