From 2fcf4617c9e6a28566fc46d8184da2eabb070169 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 27 Jan 2023 21:29:12 +0100 Subject: [PATCH] Correctly swizzle the textures for ScreenSpaceImage types to allow for 8 bit grayscale images (closes #2330) --- modules/base/rendering/screenspaceimagelocal.cpp | 4 ++++ modules/base/rendering/screenspaceimageonline.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index 0c16b436f9..7b302a9068 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -124,6 +124,10 @@ void ScreenSpaceImageLocal::update() { // image is only RGB glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (texture->format() == ghoul::opengl::Texture::Format::Red) { + texture->setSwizzleMask({ GL_RED, GL_RED, GL_RED, GL_ONE }); + } + texture->uploadTexture(); texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); texture->purgeFromRAM(); diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index 7620f14629..c5cb15a5e1 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -127,6 +127,10 @@ void ScreenSpaceImageOnline::update() { // image is only RGB glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (texture->format() == ghoul::opengl::Texture::Format::Red) { + texture->setSwizzleMask({ GL_RED, GL_RED, GL_RED, GL_ONE }); + } + texture->uploadTexture(); texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); texture->purgeFromRAM();