Showing the changes to interface/src/Application_Graphics.cpp (1 of 1 file). Show all
Unified · Split
| @@ -522,45 +522,41 @@ void Application::updateRenderArgs(float deltaTime) { · 521 unmodified lines | |||
| 522 | appRenderArgs._eyeToWorld = _myCamera.getTransform(); | 522 | appRenderArgs._eyeToWorld = _myCamera.getTransform(); |
| 523 | appRenderArgs._isStereo = false; | 523 | appRenderArgs._isStereo = false; |
| 524 | 524 | ||
| 525 | { | 525 | if (getActiveDisplayPlugin()->isStereo()) { |
| 526 | auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); | 526 | auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); |
| 527 | float ipdScale = hmdInterface->getIPDScale(); | ||
| 528 | |||
| 529 | // scale IPD by sensorToWorldScale, to make the world seem larger or smaller accordingly. | 527 | // scale IPD by sensorToWorldScale, to make the world seem larger or smaller accordingly. |
| 530 | ipdScale *= sensorToWorldScale; | 528 | float ipdScale = hmdInterface->getIPDScale() * sensorToWorldScale; |
| 531 | 529 | ||
| 532 | auto baseProjection = appRenderArgs._renderArgs.getViewFrustum().getProjection(); | 530 | auto baseProjection = appRenderArgs._renderArgs.getViewFrustum().getProjection(); |
| 533 | 531 | ||
| 534 | if (getActiveDisplayPlugin()->isStereo()) { | 532 | // Stereo modes will typically have a larger projection matrix overall, |
| 535 | // Stereo modes will typically have a larger projection matrix overall, | 533 | // so we ask for the 'mono' projection matrix, which for stereo and HMD |
| 536 | // so we ask for the 'mono' projection matrix, which for stereo and HMD | 534 | // plugins will imply the combined projection for both eyes. |
| 537 | // plugins will imply the combined projection for both eyes. | 535 | // |
| 538 | // | 536 | // This is properly implemented for the Oculus plugins, but for OpenVR |
| 539 | // This is properly implemented for the Oculus plugins, but for OpenVR | 537 | // and Stereo displays I'm not sure how to get / calculate it, so we're |
| 540 | // and Stereo displays I'm not sure how to get / calculate it, so we're | 538 | // just relying on the left FOV in each case and hoping that the |
| 541 | // just relying on the left FOV in each case and hoping that the | 539 | // overall culling margin of error doesn't cause popping in the |
| 542 | // overall culling margin of error doesn't cause popping in the | 540 | // right eye. There are FIXMEs in the relevant plugins |
| 543 | // right eye. There are FIXMEs in the relevant plugins | 541 | _myCamera.setProjection(getActiveDisplayPlugin()->getCullingProjection(baseProjection)); |
| 544 | _myCamera.setProjection(getActiveDisplayPlugin()->getCullingProjection(baseProjection)); | 542 | appRenderArgs._isStereo = true; |
| 545 | appRenderArgs._isStereo = true; | 543 | |
| 546 | 544 | auto& eyeOffsets = appRenderArgs._eyeOffsets; | |
| 547 | auto& eyeOffsets = appRenderArgs._eyeOffsets; | 545 | auto& eyeProjections = appRenderArgs._eyeProjections; |
| 548 | auto& eyeProjections = appRenderArgs._eyeProjections; | 546 | |
| 549 | 547 | // FIXME we probably don't need to set the projection matrix every frame, | |
| 550 | // FIXME we probably don't need to set the projection matrix every frame, | 548 | // only when the display plugin changes (or in non-HMD modes when the user |
| 551 | // only when the display plugin changes (or in non-HMD modes when the user | 549 | // changes the FOV manually, which right now I don't think they can. |
| 552 | // changes the FOV manually, which right now I don't think they can. | 550 | for_each_eye([&](Eye eye) { |
| 553 | for_each_eye([&](Eye eye) { | 551 | // Grab the translation |
| 554 | // Grab the translation | 552 | eyeOffsets[eye] = getActiveDisplayPlugin()->getEyeToHeadTransform(eye); |
| 555 | eyeOffsets[eye] = getActiveDisplayPlugin()->getEyeToHeadTransform(eye); | 553 | // Apply IPD scaling |
| 556 | // Apply IPD scaling | 554 | eyeOffsets[eye][3][0] *= ipdScale; |
| 557 | eyeOffsets[eye][3][0] *= ipdScale; | 555 | eyeProjections[eye] = getActiveDisplayPlugin()->getEyeProjection(eye, baseProjection); |
| 558 | eyeProjections[eye] = getActiveDisplayPlugin()->getEyeProjection(eye, baseProjection); | 556 | }); |
| 559 | }); | 557 | |
| 560 | 558 | // Configure the type of display / stereo | |
| 561 | // Configure the type of display / stereo | 559 | appRenderArgs._renderArgs._displayMode = (isHMDMode() ? RenderArgs::STEREO_HMD : RenderArgs::STEREO_MONITOR); |
| 562 | appRenderArgs._renderArgs._displayMode = (isHMDMode() ? RenderArgs::STEREO_HMD : RenderArgs::STEREO_MONITOR); | ||
| 563 | } | ||
| 564 | } | 560 | } |
| 565 | 561 | ||
| 566 | appRenderArgs._renderArgs._stencilMaskMode = getActiveDisplayPlugin()->getStencilMaskMode(); | 562 | appRenderArgs._renderArgs._stencilMaskMode = getActiveDisplayPlugin()->getStencilMaskMode(); |