From bc6b43b7bea23c9581175f4eca00794b5ff25e7e Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 8 Sep 2016 11:20:37 -0700 Subject: [PATCH] Add debug option to lower texture resolution --- interface/src/Application.cpp | 2 +- interface/src/Menu.cpp | 10 ++++++++++ libraries/model/src/model/TextureMap.cpp | 23 +++++++++++++++-------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 904a6c5b65..f475bf18e2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2006,7 +2006,7 @@ void Application::resizeGL() { static qreal lastDevicePixelRatio = 0; qreal devicePixelRatio = _window->devicePixelRatio(); if (offscreenUi->size() != fromGlm(uiSize) || devicePixelRatio != lastDevicePixelRatio) { - qDebug() << "Device pixel ratio changed, triggering resize"; + qDebug() << "Device pixel ratio changed, triggering resize to " << uiSize; offscreenUi->resize(fromGlm(uiSize), true); _offscreenContext->makeCurrent(); lastDevicePixelRatio = devicePixelRatio; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d3caa4a092..08abbf63d2 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -47,6 +47,8 @@ #include "Menu.h" +extern bool DEV_DECIMATE_TEXTURES; + Menu* Menu::getInstance() { return dynamic_cast(qApp->getWindow()->menuBar()); } @@ -390,6 +392,14 @@ Menu::Menu() { // Developer > Render > LOD Tools addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, dialogsManager.data(), SLOT(lodTools())); + // HACK enable texture decimation + { + auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, "Decimate Textures"); + connect(action, &QAction::triggered, [&](bool checked) { + DEV_DECIMATE_TEXTURES = checked; + }); + } + // Developer > Assets >>> MenuWrapper* assetDeveloperMenu = developerMenu->addMenu("Assets"); auto& atpMigrator = ATPAssetMigrator::getInstance(); diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index 754862aa4a..9345124d54 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -22,6 +22,13 @@ using namespace gpu; // FIXME: Declare this to enable compression //#define COMPRESS_TEXTURES +bool DEV_DECIMATE_TEXTURES = false; +QImage processSourceImage(const QImage& srcImage) { + if (DEV_DECIMATE_TEXTURES) { + return srcImage.scaled(srcImage.size() * 0.5f); + } + return srcImage; +} void TextureMap::setTextureSource(TextureSourcePointer& textureSource) { _textureSource = textureSource; @@ -53,7 +60,7 @@ void TextureMap::setLightmapOffsetScale(float offset, float scale) { } const QImage TextureUsage::process2DImageColor(const QImage& srcImage, bool& validAlpha, bool& alphaAsMask) { - QImage image = srcImage; + QImage image = processSourceImage(srcImage); validAlpha = false; alphaAsMask = true; const uint8 OPAQUE_ALPHA = 255; @@ -221,7 +228,7 @@ gpu::Texture* TextureUsage::createLightmapTextureFromImage(const QImage& srcImag gpu::Texture* TextureUsage::createNormalTextureFromNormalImage(const QImage& srcImage, const std::string& srcImageName) { - QImage image = srcImage; + QImage image = processSourceImage(srcImage); if (image.format() != QImage::Format_RGB888) { image = image.convertToFormat(QImage::Format_RGB888); @@ -254,8 +261,8 @@ double mapComponent(double sobelValue) { } gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcImage, const std::string& srcImageName) { - QImage image = srcImage; - + QImage image = processSourceImage(srcImage); + if (image.format() != QImage::Format_RGB888) { image = image.convertToFormat(QImage::Format_RGB888); } @@ -325,7 +332,7 @@ gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcIm } gpu::Texture* TextureUsage::createRoughnessTextureFromImage(const QImage& srcImage, const std::string& srcImageName) { - QImage image = srcImage; + QImage image = processSourceImage(srcImage); if (!image.hasAlphaChannel()) { if (image.format() != QImage::Format_RGB888) { image = image.convertToFormat(QImage::Format_RGB888); @@ -358,7 +365,7 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromImage(const QImage& srcIma } gpu::Texture* TextureUsage::createRoughnessTextureFromGlossImage(const QImage& srcImage, const std::string& srcImageName) { - QImage image = srcImage; + QImage image = processSourceImage(srcImage); if (!image.hasAlphaChannel()) { if (image.format() != QImage::Format_RGB888) { image = image.convertToFormat(QImage::Format_RGB888); @@ -395,7 +402,7 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromGlossImage(const QImage& s } gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImage, const std::string& srcImageName) { - QImage image = srcImage; + QImage image = processSourceImage(srcImage); if (!image.hasAlphaChannel()) { if (image.format() != QImage::Format_RGB888) { image = image.convertToFormat(QImage::Format_RGB888); @@ -687,7 +694,7 @@ const int CubeLayout::NUM_CUBEMAP_LAYOUTS = sizeof(CubeLayout::CUBEMAP_LAYOUTS) gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcImage, const std::string& srcImageName, bool isLinear, bool doCompress, bool generateMips, bool generateIrradiance) { gpu::Texture* theTexture = nullptr; if ((srcImage.width() > 0) && (srcImage.height() > 0)) { - QImage image = srcImage; + QImage image = processSourceImage(srcImage); if (image.format() != QImage::Format_RGB888) { image = image.convertToFormat(QImage::Format_RGB888); }