diff --git a/libraries/graphics/src/graphics/skybox.slf b/libraries/graphics/src/graphics/skybox.slf index c20dd94bf4..231c1f4140 100755 --- a/libraries/graphics/src/graphics/skybox.slf +++ b/libraries/graphics/src/graphics/skybox.slf @@ -26,13 +26,6 @@ layout(location=0) in vec3 _normal; layout(location=0) out vec4 _fragColor; void main(void) { - vec3 coord = normalize(_normal); - vec3 color = skybox.color.rgb; - - // blend is only set if there is a cubemap - float check = float(skybox.color.a > 0.0); - color = mix(color, texture(cubeMap, coord).rgb, check); - color *= mix(vec3(1.0), skybox.color.rgb, check * float(skybox.color.a < 1.0)); - - _fragColor = vec4(color, 0.0); + vec3 skyboxColor = texture(cubeMap, normalize(_normal)).rgb; + _fragColor = vec4(mix(skybox.color.rgb, skyboxColor, skybox.color.a), 1.0); } diff --git a/libraries/image/src/image/TextureProcessing.cpp b/libraries/image/src/image/TextureProcessing.cpp index 429859d109..c144ed530a 100644 --- a/libraries/image/src/image/TextureProcessing.cpp +++ b/libraries/image/src/image/TextureProcessing.cpp @@ -690,6 +690,8 @@ void convertImageToLDRTexture(gpu::Texture* texture, Image&& image, BackendTarge compressionOptions.setFormat(nvtt::Format_BC4); } else if (mipFormat == gpu::Element::COLOR_COMPRESSED_BCX_XY) { compressionOptions.setFormat(nvtt::Format_BC5); + } else if (mipFormat == gpu::Element::COLOR_COMPRESSED_BCX_HDR_RGB) { + compressionOptions.setFormat(nvtt::Format_BC6); } else if (mipFormat == gpu::Element::COLOR_COMPRESSED_BCX_SRGBA_HIGH) { alphaMode = nvtt::AlphaMode_Transparency; compressionOptions.setFormat(nvtt::Format_BC7); diff --git a/libraries/ktx/src/TextureMeta.cpp b/libraries/ktx/src/TextureMeta.cpp index c8427c1f60..f97b5404e1 100644 --- a/libraries/ktx/src/TextureMeta.cpp +++ b/libraries/ktx/src/TextureMeta.cpp @@ -16,6 +16,7 @@ #include const QString TEXTURE_META_EXTENSION = ".texmeta.json"; +const uint16_t KTX_VERSION = 1; bool TextureMeta::deserialize(const QByteArray& data, TextureMeta* meta) { QJsonParseError error; @@ -46,6 +47,9 @@ bool TextureMeta::deserialize(const QByteArray& data, TextureMeta* meta) { } } } + if (root.contains("version")) { + meta->version = root["version"].toInt(); + } return true; } @@ -62,6 +66,7 @@ QByteArray TextureMeta::serialize() { root["original"] = original.toString(); root["uncompressed"] = uncompressed.toString(); root["compressed"] = compressed; + root["version"] = KTX_VERSION; doc.setObject(root); return doc.toJson(); diff --git a/libraries/ktx/src/TextureMeta.h b/libraries/ktx/src/TextureMeta.h index 5450fee110..fc39db6ef1 100644 --- a/libraries/ktx/src/TextureMeta.h +++ b/libraries/ktx/src/TextureMeta.h @@ -19,6 +19,7 @@ #include "khronos/KHR.h" extern const QString TEXTURE_META_EXTENSION; +extern const uint16_t KTX_VERSION; namespace std { template<> struct hash { @@ -37,6 +38,7 @@ struct TextureMeta { QUrl original; QUrl uncompressed; std::unordered_map availableTextureTypes; + uint16_t version { 0 }; }; diff --git a/libraries/material-networking/src/material-networking/TextureCache.cpp b/libraries/material-networking/src/material-networking/TextureCache.cpp index 8ffcad0c69..b15632c6be 100644 --- a/libraries/material-networking/src/material-networking/TextureCache.cpp +++ b/libraries/material-networking/src/material-networking/TextureCache.cpp @@ -1065,6 +1065,21 @@ void NetworkTexture::loadMetaContent(const QByteArray& content) { return; } + // Version 0 ktx skyboxes and ambient maps don't work on AMD anymore, so we fallback to the original texture + if (meta.version == 0 && _type == image::TextureUsage::Type::SKY_TEXTURE || + _type == image::TextureUsage::Type::AMBIENT_TEXTURE && !meta.original.isEmpty()) { + _currentlyLoadingResourceType = ResourceType::ORIGINAL; + _activeUrl = _activeUrl.resolved(meta.original); + + auto textureCache = DependencyManager::get(); + auto self = _self.lock(); + if (!self) { + return; + } + QMetaObject::invokeMethod(this, "attemptRequest", Qt::QueuedConnection); + return; + } + auto& backend = DependencyManager::get()->getGPUContext()->getBackend(); for (auto pair : meta.availableTextureTypes) { gpu::Element elFormat; diff --git a/libraries/procedural/src/procedural/proceduralSkybox.slf b/libraries/procedural/src/procedural/proceduralSkybox.slf index 12e8de9dc3..f938e0b9a2 100644 --- a/libraries/procedural/src/procedural/proceduralSkybox.slf +++ b/libraries/procedural/src/procedural/proceduralSkybox.slf @@ -42,5 +42,5 @@ void main(void) { color = max(color, vec3(0)); // Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline color = pow(color, vec3(2.2)); - _fragColor = vec4(color, 0.0); + _fragColor = vec4(color, 1.0); }