| 433 | } |
| 434 | |
| 435 | void PostProcessor::createObjectsForFrame(size_t frameId) |
| 436 | { |
| 437 | auto& textures = mTextures[frameId]; |
| 438 | |
| 439 | int width = renderWidth(); |
| 440 | int height = renderHeight(); |
| 441 | |
| 442 | for (osg::ref_ptr<osg::Texture>& texture : textures) |
| 443 | { |
| 444 | if (!texture) |
| 445 | { |
| 446 | if (Stereo::getMultiview()) |
| 447 | texture = new osg::Texture2DArray; |
| 448 | else |
| 449 | texture = new osg::Texture2D; |
| 450 | } |
| 451 | Stereo::setMultiviewCompatibleTextureSize(texture, width, height); |
| 452 | texture->setSourceFormat(GL_RGBA); |
| 453 | texture->setSourceType(GL_UNSIGNED_BYTE); |
| 454 | texture->setInternalFormat(GL_RGBA); |
| 455 | texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture::LINEAR); |
| 456 | texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture::LINEAR); |
| 457 | texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); |
| 458 | texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); |
| 459 | texture->setResizeNonPowerOfTwoHint(false); |
| 460 | Stereo::setMultiviewCompatibleTextureSize(texture, width, height); |
| 461 | texture->dirtyTextureObject(); |
| 462 | } |
| 463 | |
| 464 | textures[Tex_Normal]->setSourceFormat(GL_RGB); |
| 465 | textures[Tex_Normal]->setInternalFormat(GL_RGB); |
| 466 | |
| 467 | textures[Tex_Distortion]->setSourceFormat(GL_RGB); |
| 468 | textures[Tex_Distortion]->setInternalFormat(GL_RGB); |
| 469 | |
| 470 | Stereo::setMultiviewCompatibleTextureSize(textures[Tex_Distortion], static_cast<int>(width * DistortionRatio), |
| 471 | static_cast<int>(height * DistortionRatio)); |
| 472 | textures[Tex_Distortion]->dirtyTextureObject(); |
| 473 | |
| 474 | auto setupDepth = [](osg::Texture* tex) { |
| 475 | tex->setSourceFormat(GL_DEPTH_STENCIL_EXT); |
| 476 | tex->setSourceType(SceneUtil::AutoDepth::depthSourceType()); |
| 477 | tex->setInternalFormat(SceneUtil::AutoDepth::depthInternalFormat()); |
| 478 | }; |
| 479 | |
| 480 | setupDepth(textures[Tex_Depth]); |
| 481 | setupDepth(textures[Tex_OpaqueDepth]); |
| 482 | textures[Tex_OpaqueDepth]->setName("opaqueTexMap"); |
| 483 | |
| 484 | auto& fbos = mFbos[frameId]; |
| 485 | |
| 486 | fbos[FBO_Primary] = new osg::FrameBufferObject; |
| 487 | fbos[FBO_Primary]->setAttachment( |
| 488 | osg::Camera::COLOR_BUFFER0, Stereo::createMultiviewCompatibleAttachment(textures[Tex_Scene])); |
| 489 | if (mNormals && mNormalsSupported) |
| 490 | fbos[FBO_Primary]->setAttachment( |
| 491 | osg::Camera::COLOR_BUFFER1, Stereo::createMultiviewCompatibleAttachment(textures[Tex_Normal])); |
| 492 | fbos[FBO_Primary]->setAttachment( |
nothing calls this directly
no test coverage detected