From c8e5b35de94f21b5b02616f0278f951a3c7a96d7 Mon Sep 17 00:00:00 2001 From: samcake Date: Fri, 1 May 2015 12:04:15 -0700 Subject: [PATCH 1/4] Fixing typo --- libraries/gpu/src/gpu/GLBackendOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/GLBackendOutput.cpp b/libraries/gpu/src/gpu/GLBackendOutput.cpp index dd8e9c68b6..7b2deb64d2 100755 --- a/libraries/gpu/src/gpu/GLBackendOutput.cpp +++ b/libraries/gpu/src/gpu/GLBackendOutput.cpp @@ -75,7 +75,7 @@ GLBackend::GLFramebuffer* GLBackend::syncGPUObject(const Framebuffer& framebuffe } } #if (GPU_FEATURE_PROFILE == GPU_LEGACY) - // for reasons that i don;t understand yet, it seems that on mac gl, a fbo must have a color buffer... + // for reasons that i don't understand yet, it seems that on mac gl, a fbo must have a color buffer... else { GLuint renderBuffer = 0; glGenRenderbuffers(1, &renderBuffer); From 1b558e7390bb9e15f3a313864478038a5d6cee1c Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 1 May 2015 13:37:04 -0700 Subject: [PATCH 2/4] investigating the semi transparent textured bug --- libraries/fbx/src/FBXReader.cpp | 8 ++++++-- libraries/render-utils/src/model.slf | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index ca4ccc294f..396859f3f8 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1746,8 +1746,12 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, material.id = getID(object.properties); material._material = model::MaterialPointer(new model::Material()); - material._material->setEmissive(material.emissive); - material._material->setDiffuse(material.diffuse); + material._material->setEmissive(material.emissive); + if (glm::all(glm::equal(material.diffuse, glm::vec3(0.0f)))) { + material._material->setDiffuse(material.diffuse); + } else { + material._material->setDiffuse(material.diffuse); + } material._material->setSpecular(material.specular); material._material->setShininess(material.shininess); diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index 7648cac429..61c1319783 100755 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -33,7 +33,7 @@ void main(void) { packDeferredFragment( normalize(interpolatedNormal.xyz), evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a), - getMaterialDiffuse(mat) * diffuse.rgb * color, + /*getMaterialDiffuse(mat) **/ diffuse.rgb /** color*/, getMaterialSpecular(mat), getMaterialShininess(mat)); } From 2382183075a00ced40971df000be778d5b9de174 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 1 May 2015 16:09:41 -0700 Subject: [PATCH 3/4] FIxed the bug about the tga not loading by recognizing the file format type from the filename extension and passing the info to the QImage::fromData() --- libraries/render-utils/src/TextureCache.cpp | 56 +++++++++++++-------- libraries/render-utils/src/model.slf | 2 +- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index 63ca43725b..cf4ba00893 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -28,6 +29,8 @@ #include "gpu/GLBackend.h" +#include + TextureCache::TextureCache() : _permutationNormalTexture(0), _whiteTexture(0), @@ -344,27 +347,7 @@ NetworkTexture::NetworkTexture(const QUrl& url, TextureType type, const QByteArr _loaded = true; } - // default to white/blue/black - /* glBindTexture(GL_TEXTURE_2D, getID()); - switch (type) { - case NORMAL_TEXTURE: - loadSingleColorTexture(OPAQUE_BLUE); - break; - - case SPECULAR_TEXTURE: - loadSingleColorTexture(OPAQUE_BLACK); - break; - - case SPLAT_TEXTURE: - loadSingleColorTexture(TRANSPARENT_WHITE); - break; - - default: - loadSingleColorTexture(OPAQUE_WHITE); - break; - } - glBindTexture(GL_TEXTURE_2D, 0); - */ + std::string theName = url.toString().toStdString(); // if we have content, load it after we have our self pointer if (!content.isEmpty()) { _startedLoading = true; @@ -396,6 +379,17 @@ ImageReader::ImageReader(const QWeakPointer& texture, QNetworkReply* r _content(content) { } +std::once_flag onceListSuppoertedFormatsflag; +void listSupportedImageFormats() { + std::call_once(onceListSuppoertedFormatsflag, [](){ + auto supportedFormats = QImageReader::supportedImageFormats(); + qCDebug(renderutils) << "ImageReader:: List of supported formats:"; + foreach(const QByteArray& f, supportedFormats) { + qCDebug(renderutils) << "format = " << f; + } + }); +} + void ImageReader::run() { QSharedPointer texture = _texture.toStrongRef(); if (texture.isNull()) { @@ -409,11 +403,29 @@ void ImageReader::run() { _content = _reply->readAll(); _reply->deleteLater(); } - QImage image = QImage::fromData(_content); + listSupportedImageFormats(); + + // try to help the QImage loader by extracting the image file format from the url filename ext + // Some tga are not created properly for example without it + auto filename = _url.fileName().toStdString(); + auto filenameExtension = filename.substr(filename.find_last_of('.') + 1); + QImage image = QImage::fromData(_content, filenameExtension.c_str()); + + // Note that QImage.format is the pixel format which is different from the "format" of the image file... + auto imageFormat = image.format(); int originalWidth = image.width(); int originalHeight = image.height(); + if (originalWidth == 0 || originalHeight == 0 || imageFormat == QImage::Format_Invalid) { + if (filenameExtension.empty()) { + qCDebug(renderutils) << "QImage failed to create from content, no file extension:" << _url; + } else { + qCDebug(renderutils) << "QImage failed to create from content" << _url; + } + return; + } + // enforce a fixed maximum area (1024 * 2048) const int MAXIMUM_AREA_SIZE = 2097152; int imageArea = image.width() * image.height(); diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index 61c1319783..7648cac429 100755 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -33,7 +33,7 @@ void main(void) { packDeferredFragment( normalize(interpolatedNormal.xyz), evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a), - /*getMaterialDiffuse(mat) **/ diffuse.rgb /** color*/, + getMaterialDiffuse(mat) * diffuse.rgb * color, getMaterialSpecular(mat), getMaterialShininess(mat)); } From f9802a1072e5a284c11385d2fc36d2c327cbfb38 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 1 May 2015 16:39:25 -0700 Subject: [PATCH 4/4] IMprove the message --- libraries/render-utils/src/TextureCache.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index cf4ba00893..616ff13dce 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -383,10 +383,11 @@ std::once_flag onceListSuppoertedFormatsflag; void listSupportedImageFormats() { std::call_once(onceListSuppoertedFormatsflag, [](){ auto supportedFormats = QImageReader::supportedImageFormats(); - qCDebug(renderutils) << "ImageReader:: List of supported formats:"; + QString formats; foreach(const QByteArray& f, supportedFormats) { - qCDebug(renderutils) << "format = " << f; - } + formats += QString(f) + ","; + } + qCDebug(renderutils) << "List of supported Image formats:" << formats; }); }