Showing the changes to libraries/render-utils/src/FramebufferCache.cpp (1 of 3 files). Show all
Unified · Split
| @@ -41,6 +41,8 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 40 unmodified lines | ||
| 41 | 41 | _primarySpecularTexture.reset(); |
| 42 | 42 | _selfieFramebuffer.reset(); |
| 43 | 43 | _cachedFramebuffers.clear(); |
| 44 | + _lightingTexture.reset(); | |
| 45 | + _lightingFramebuffer.reset(); | |
| 44 | 46 | } |
| 45 | 47 | } |
| 46 | 48 | |
| @@ -74,6 +76,12 @@ void FramebufferCache::createPrimaryFramebuffer() { · 27 unmodified lines | ||
| 74 | 76 | _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); |
| 75 | 77 | auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler)); |
| 76 | 78 | _selfieFramebuffer->setRenderBuffer(0, tex); |
| 79 | + | |
| 80 | + _lightingTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA), width, height, defaultSampler)); | |
| 81 | + //_lightingTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::SRGBA), width, height, defaultSampler)); | |
| 82 | + // _lightingTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::HALF, gpu::RGBA), width, height, defaultSampler)); | |
| 83 | + _lightingFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | |
| 84 | + _lightingFramebuffer->setRenderBuffer(0, _lightingTexture); | |
| 77 | 85 | } |
| 78 | 86 | |
| 79 | 87 | gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() { |
| @@ -118,6 +126,20 @@ gpu::TexturePointer FramebufferCache::getPrimarySpecularTexture() { · 38 unmodified lines | ||
| 118 | 126 | return _primarySpecularTexture; |
| 119 | 127 | } |
| 120 | 128 | |
| 129 | +gpu::FramebufferPointer FramebufferCache::getLightingFramebuffer() { | |
| 130 | + if (!_lightingFramebuffer) { | |
| 131 | + createPrimaryFramebuffer(); | |
| 132 | + } | |
| 133 | + return _lightingFramebuffer; | |
| 134 | +} | |
| 135 | + | |
| 136 | +gpu::TexturePointer FramebufferCache::getLightingTexture() { | |
| 137 | + if (!_lightingTexture) { | |
| 138 | + createPrimaryFramebuffer(); | |
| 139 | + } | |
| 140 | + return _lightingTexture; | |
| 141 | +} | |
| 142 | + | |
| 121 | 143 | gpu::FramebufferPointer FramebufferCache::getFramebuffer() { |
| 122 | 144 | if (_cachedFramebuffers.isEmpty()) { |
| 123 | 145 | _cachedFramebuffers.push_back(gpu::FramebufferPointer(gpu::Framebuffer::create(gpu::Element::COLOR_RGBA_32, _frameBufferSize.width(), _frameBufferSize.height()))); |