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/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); diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index 63ca43725b..616ff13dce 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,18 @@ ImageReader::ImageReader(const QWeakPointer& texture, QNetworkReply* r _content(content) { } +std::once_flag onceListSuppoertedFormatsflag; +void listSupportedImageFormats() { + std::call_once(onceListSuppoertedFormatsflag, [](){ + auto supportedFormats = QImageReader::supportedImageFormats(); + QString formats; + foreach(const QByteArray& f, supportedFormats) { + formats += QString(f) + ","; + } + qCDebug(renderutils) << "List of supported Image formats:" << formats; + }); +} + void ImageReader::run() { QSharedPointer texture = _texture.toStrongRef(); if (texture.isNull()) { @@ -409,11 +404,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();