Showing the changes to interface/src/Application.cpp (1 of 8 files). Show all
Unified · Split
| @@ -1150,7 +1150,7 @@ void Application::paintGL() { · 1149 unmodified lines | ||
| 1150 | 1150 | |
| 1151 | 1151 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 1152 | 1152 | PerformanceTimer perfTimer("Mirror"); |
| 1153 | − auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor(); | |
| 1153 | + auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 1154 | 1154 | |
| 1155 | 1155 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| 1156 | 1156 | renderRearViewMirror(&renderArgs, _mirrorViewRect); |
| @@ -1231,15 +1231,28 @@ void Application::paintGL() { · 74 unmodified lines | ||
| 1231 | 1231 | } |
| 1232 | 1232 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1233 | 1233 | if (isHMDMode()) { |
| 1234 | + auto mirrorBodyOrientation = myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)); | |
| 1235 | + | |
| 1234 | 1236 | glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix()); |
| 1235 | − _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() | |
| 1236 | − * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation); | |
| 1237 | + // Mirror HMD yaw and roll | |
| 1238 | + glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation); | |
| 1239 | + mirrorHmdEulers.y = -mirrorHmdEulers.y; | |
| 1240 | + mirrorHmdEulers.z = -mirrorHmdEulers.z; | |
| 1241 | + glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers); | |
| 1242 | + | |
| 1243 | + glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation; | |
| 1244 | + | |
| 1245 | + _myCamera.setRotation(worldMirrorRotation); | |
| 1246 | + | |
| 1237 | 1247 | glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix()); |
| 1248 | + // Mirror HMD lateral offsets | |
| 1249 | + hmdOffset.x = -hmdOffset.x; | |
| 1250 | + | |
| 1238 | 1251 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() |
| 1239 | 1252 | + glm::vec3(0, _raiseMirror * myAvatar->getAvatarScale(), 0) |
| 1240 | − + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | |
| 1241 | − glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror | |
| 1242 | − + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); | |
| 1253 | + + mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror | |
| 1254 | + + mirrorBodyOrientation * hmdOffset); | |
| 1255 | + | |
| 1243 | 1256 | } else { |
| 1244 | 1257 | _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() |
| 1245 | 1258 | * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| @@ -1273,6 +1286,10 @@ void Application::paintGL() { · 27 unmodified lines | ||
| 1273 | 1286 | // Primary rendering pass |
| 1274 | 1287 | auto framebufferCache = DependencyManager::get<FramebufferCache>(); |
| 1275 | 1288 | const QSize size = framebufferCache->getFrameBufferSize(); |
| 1289 | + | |
| 1290 | + // Final framebuffer that will be handled to the display-plugin | |
| 1291 | + auto finalFramebuffer = framebufferCache->getFramebuffer(); | |
| 1292 | + | |
| 1276 | 1293 | { |
| 1277 | 1294 | PROFILE_RANGE(__FUNCTION__ "/mainRender"); |
| 1278 | 1295 | PerformanceTimer perfTimer("mainRender"); |
| @@ -1326,9 +1343,63 @@ void Application::paintGL() { · 47 unmodified lines | ||
| 1326 | 1343 | } |
| 1327 | 1344 | displaySide(&renderArgs, _myCamera); |
| 1328 | 1345 | renderArgs._context->enableStereo(false); |
| 1329 | − gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) { | |
| 1330 | − batch.setFramebuffer(nullptr); | |
| 1331 | − }); | |
| 1346 | + | |
| 1347 | + // Blit primary to final FBO | |
| 1348 | + auto primaryFbo = framebufferCache->getPrimaryFramebuffer(); | |
| 1349 | + | |
| 1350 | + if (renderArgs._renderMode == RenderArgs::MIRROR_RENDER_MODE) { | |
| 1351 | + if (displayPlugin->isStereo()) { | |
| 1352 | + gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1353 | + gpu::Vec4i srcRectLeft; | |
| 1354 | + srcRectLeft.z = size.width() / 2; | |
| 1355 | + srcRectLeft.w = size.height(); | |
| 1356 | + | |
| 1357 | + gpu::Vec4i srcRectRight; | |
| 1358 | + srcRectRight.x = size.width() / 2; | |
| 1359 | + srcRectRight.z = size.width(); | |
| 1360 | + srcRectRight.w = size.height(); | |
| 1361 | + | |
| 1362 | + gpu::Vec4i destRectLeft; | |
| 1363 | + destRectLeft.x = srcRectLeft.z; | |
| 1364 | + destRectLeft.z = srcRectLeft.x; | |
| 1365 | + destRectLeft.y = srcRectLeft.y; | |
| 1366 | + destRectLeft.w = srcRectLeft.w; | |
| 1367 | + | |
| 1368 | + gpu::Vec4i destRectRight; | |
| 1369 | + destRectRight.x = srcRectRight.z; | |
| 1370 | + destRectRight.z = srcRectRight.x; | |
| 1371 | + destRectRight.y = srcRectRight.y; | |
| 1372 | + destRectRight.w = srcRectRight.w; | |
| 1373 | + | |
| 1374 | + batch.setFramebuffer(finalFramebuffer); | |
| 1375 | + batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 1.0f, 0.0f)); | |
| 1376 | + // BLit left to right and right to left in stereo | |
| 1377 | + batch.blit(primaryFbo, srcRectRight, finalFramebuffer, destRectLeft); | |
| 1378 | + batch.blit(primaryFbo, srcRectLeft, finalFramebuffer, destRectRight); | |
| 1379 | + }); | |
| 1380 | + } else { | |
| 1381 | + gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1382 | + gpu::Vec4i srcRect; | |
| 1383 | + srcRect.z = size.width(); | |
| 1384 | + srcRect.w = size.height(); | |
| 1385 | + gpu::Vec4i destRect; | |
| 1386 | + destRect.x = size.width(); | |
| 1387 | + destRect.y = 0; | |
| 1388 | + destRect.z = 0; | |
| 1389 | + destRect.w = size.height(); | |
| 1390 | + batch.setFramebuffer(finalFramebuffer); | |
| 1391 | + batch.blit(primaryFbo, srcRect, finalFramebuffer, destRect); | |
| 1392 | + }); | |
| 1393 | + } | |
| 1394 | + } else { | |
| 1395 | + gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1396 | + gpu::Vec4i rect; | |
| 1397 | + rect.z = size.width(); | |
| 1398 | + rect.w = size.height(); | |
| 1399 | + batch.setFramebuffer(finalFramebuffer); | |
| 1400 | + batch.blit(primaryFbo, rect, finalFramebuffer, rect); | |
| 1401 | + }); | |
| 1402 | + } | |
| 1332 | 1403 | } |
| 1333 | 1404 | |
| 1334 | 1405 | // Overlay Composition, needs to occur after screen space effects have completed |
| @@ -1336,7 +1407,9 @@ void Application::paintGL() { · 1 unmodified line | ||
| 1336 | 1407 | { |
| 1337 | 1408 | PROFILE_RANGE(__FUNCTION__ "/compositor"); |
| 1338 | 1409 | PerformanceTimer perfTimer("compositor"); |
| 1339 | − auto primaryFbo = framebufferCache->getPrimaryFramebufferDepthColor(); | |
| 1410 | + | |
| 1411 | + auto primaryFbo = finalFramebuffer; | |
| 1412 | + | |
| 1340 | 1413 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo)); |
| 1341 | 1414 | if (displayPlugin->isStereo()) { |
| 1342 | 1415 | QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height())); |
| @@ -1362,23 +1435,13 @@ void Application::paintGL() { · 19 unmodified lines | ||
| 1362 | 1435 | PROFILE_RANGE(__FUNCTION__ "/pluginOutput"); |
| 1363 | 1436 | PerformanceTimer perfTimer("pluginOutput"); |
| 1364 | 1437 | |
| 1365 | − auto primaryFramebuffer = framebufferCache->getPrimaryFramebufferDepthColor(); | |
| 1366 | − auto scratchFramebuffer = framebufferCache->getFramebuffer(); | |
| 1367 | − gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | |
| 1368 | − gpu::Vec4i rect; | |
| 1369 | − rect.z = size.width(); | |
| 1370 | − rect.w = size.height(); | |
| 1371 | − batch.setFramebuffer(scratchFramebuffer); | |
| 1372 | − batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f)); | |
| 1373 | − batch.blit(primaryFramebuffer, rect, scratchFramebuffer, rect); | |
| 1374 | − batch.setFramebuffer(nullptr); | |
| 1375 | − }); | |
| 1376 | − auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0); | |
| 1438 | + auto finalTexturePointer = finalFramebuffer->getRenderBuffer(0); | |
| 1439 | + | |
| 1377 | 1440 | GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer); |
| 1378 | 1441 | Q_ASSERT(0 != finalTexture); |
| 1379 | 1442 | |
| 1380 | 1443 | Q_ASSERT(!_lockedFramebufferMap.contains(finalTexture)); |
| 1381 | − _lockedFramebufferMap[finalTexture] = scratchFramebuffer; | |
| 1444 | + _lockedFramebufferMap[finalTexture] = finalFramebuffer; | |
| 1382 | 1445 | |
| 1383 | 1446 | Q_ASSERT(isCurrentContext(_offscreenContext->getContext())); |
| 1384 | 1447 | { |
| @@ -3331,7 +3394,7 @@ QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { · 1946 unmodified lines | ||
| 3331 | 3394 | renderArgs->_renderMode = RenderArgs::DEFAULT_RENDER_MODE; |
| 3332 | 3395 | renderRearViewMirror(renderArgs, QRect(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE), true); |
| 3333 | 3396 | |
| 3334 | − auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor(); | |
| 3397 | + auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 3335 | 3398 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 3336 | 3399 | renderArgs->_context->downloadFramebuffer(primaryFbo, glm::ivec4(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE), image); |
| 3337 | 3400 | |