diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.jpg b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.jpg new file mode 100644 index 0000000000..7977396159 Binary files /dev/null and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.jpg differ diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.ktx b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.ktx new file mode 100644 index 0000000000..a5f4fae4eb Binary files /dev/null and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.ktx differ diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.texmeta.json b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.texmeta.json new file mode 100644 index 0000000000..96edd3abf0 --- /dev/null +++ b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.texmeta.json @@ -0,0 +1,9 @@ +{ + "compressed": { + "COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT": "Default-Sky-9-cubemap-ambient_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx", + "COMPRESSED_SRGB8_ETC2": "Default-Sky-9-cubemap-ambient_COMPRESSED_SRGB8_ETC2.ktx" + }, + "original": "Default-Sky-9-cubemap-ambient.jpg", + "uncompressed": "Default-Sky-9-cubemap-ambient.ktx", + "version": 1 +} diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx new file mode 100644 index 0000000000..279042e8dd Binary files /dev/null and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx differ diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient_COMPRESSED_SRGB8_ETC2.ktx b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient_COMPRESSED_SRGB8_ETC2.ktx new file mode 100644 index 0000000000..0a36017dbe Binary files /dev/null and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient_COMPRESSED_SRGB8_ETC2.ktx differ diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.ktx b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.ktx index 4231bf7650..7d5e18f3c9 100644 Binary files a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.ktx and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.ktx differ diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.texmeta.json b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.texmeta.json index 28512662d9..729bb2d70f 100644 --- a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.texmeta.json +++ b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.texmeta.json @@ -4,5 +4,6 @@ "COMPRESSED_SRGB8_ETC2": "Default-Sky-9-cubemap_COMPRESSED_SRGB8_ETC2.ktx" }, "original": "Default-Sky-9-cubemap.jpg", - "uncompressed": "Default-Sky-9-cubemap.ktx" + "uncompressed": "Default-Sky-9-cubemap.ktx", + "version": 1 } diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx index c789fa4ac5..9e821605b4 100644 Binary files a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT.ktx differ diff --git a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_SRGB8_ETC2.ktx b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_SRGB8_ETC2.ktx index deede32614..405cd9f09b 100644 Binary files a/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_SRGB8_ETC2.ktx and b/interface/resources/images/Default-Sky-9-cubemap/Default-Sky-9-cubemap_COMPRESSED_SRGB8_ETC2.ktx differ diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index 4aff76df21..81a6b100d0 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -220,6 +220,10 @@ void GL45Texture::generateMips() const { (void)CHECK_GL_ERROR(); } +// (NOTE: it seems to work now, but for posterity:) DSA ARB does not work on AMD, so use EXT +// unless EXT is not available on the driver +#define AMD_CUBE_MAP_EXT_WORKAROUND 0 + Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const { Size amountCopied = sourceSize; if (GL_TEXTURE_2D == _target) { @@ -267,22 +271,26 @@ Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const case GL_COMPRESSED_SIGNED_R11_EAC: case GL_COMPRESSED_RG11_EAC: case GL_COMPRESSED_SIGNED_RG11_EAC: +#if AMD_CUBE_MAP_EXT_WORKAROUND if (glCompressedTextureSubImage2DEXT) { auto target = GLTexture::CUBE_FACE_LAYOUT[face]; glCompressedTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, internalFormat, static_cast(sourceSize), sourcePointer); - } else { + } else +#endif + { glCompressedTextureSubImage3D(_id, mip, 0, yOffset, face, size.x, size.y, 1, internalFormat, static_cast(sourceSize), sourcePointer); } break; default: - // DSA ARB does not work on AMD, so use EXT - // unless EXT is not available on the driver +#if AMD_CUBE_MAP_EXT_WORKAROUND if (glTextureSubImage2DEXT) { auto target = GLTexture::CUBE_FACE_LAYOUT[face]; glTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer); - } else { + } else +#endif + { glTextureSubImage3D(_id, mip, 0, yOffset, face, size.x, size.y, 1, format, type, sourcePointer); } break; diff --git a/libraries/gpu/src/gpu/Format.cpp b/libraries/gpu/src/gpu/Format.cpp index 7e277ae488..013a5ac4a6 100644 --- a/libraries/gpu/src/gpu/Format.cpp +++ b/libraries/gpu/src/gpu/Format.cpp @@ -26,8 +26,8 @@ const Element Element::COLOR_COMPRESSED_BCX_SRGB { TILE4x4, COMPRESSED, COMPRESS const Element Element::COLOR_COMPRESSED_BCX_SRGBA_MASK { TILE4x4, COMPRESSED, COMPRESSED_BC1_SRGBA }; const Element Element::COLOR_COMPRESSED_BCX_SRGBA { TILE4x4, COMPRESSED, COMPRESSED_BC3_SRGBA }; const Element Element::COLOR_COMPRESSED_BCX_XY { TILE4x4, COMPRESSED, COMPRESSED_BC5_XY }; -const Element Element::COLOR_COMPRESSED_BCX_SRGBA_HIGH { TILE4x4, COMPRESSED, COMPRESSED_BC7_SRGBA }; const Element Element::COLOR_COMPRESSED_BCX_HDR_RGB { TILE4x4, COMPRESSED, COMPRESSED_BC6_RGB }; +const Element Element::COLOR_COMPRESSED_BCX_SRGBA_HIGH { TILE4x4, COMPRESSED, COMPRESSED_BC7_SRGBA }; const Element Element::COLOR_COMPRESSED_ETC2_RGB { TILE4x4, COMPRESSED, COMPRESSED_ETC2_RGB }; const Element Element::COLOR_COMPRESSED_ETC2_SRGB { TILE4x4, COMPRESSED, COMPRESSED_ETC2_SRGB }; diff --git a/libraries/gpu/src/gpu/FrameReader.cpp b/libraries/gpu/src/gpu/FrameReader.cpp index 812f4db7cc..740ec2b26f 100644 --- a/libraries/gpu/src/gpu/FrameReader.cpp +++ b/libraries/gpu/src/gpu/FrameReader.cpp @@ -18,7 +18,6 @@ #include "Batch.h" #include "TextureTable.h" - #include "FrameIOKeys.h" namespace gpu { @@ -324,6 +323,13 @@ TexturePointer Deserializer::readTexture(const json& node, uint32_t external) { readOptional(ktxFile, node, keys::ktxFile); Element ktxTexelFormat, ktxMipFormat; if (!ktxFile.empty()) { + // If we get a texture that starts with ":" we need to re-route it to the resources directory + if (ktxFile.at(0) == ':') { + QString frameReaderPath = __FILE__; + frameReaderPath.replace("\\", "/"); + frameReaderPath.replace("libraries/gpu/src/gpu/framereader.cpp", "interface/resources", Qt::CaseInsensitive); + ktxFile.replace(0, 1, frameReaderPath.toStdString()); + } if (QFileInfo(ktxFile.c_str()).isRelative()) { ktxFile = basedir + ktxFile; } 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/image/src/image/TextureProcessing.h b/libraries/image/src/image/TextureProcessing.h index b4036ddd9f..c1817a08a6 100644 --- a/libraries/image/src/image/TextureProcessing.h +++ b/libraries/image/src/image/TextureProcessing.h @@ -57,6 +57,7 @@ namespace TextureUsage { * @typedef {number} TextureCache.TextureType */ enum Type { + // NOTE: add new texture types at the bottom here DEFAULT_TEXTURE, STRICT_TEXTURE, ALBEDO_TEXTURE, 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/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); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index b8c720e9ca..82b7f3102a 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -648,6 +648,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { if (!_defaultLight || !_defaultBackground) { auto defaultSkyboxURL = PathUtils::resourcesUrl() + "images/Default-Sky-9-cubemap/Default-Sky-9-cubemap.texmeta.json"; + auto defaultAmbientURL = PathUtils::resourcesUrl() + "images/Default-Sky-9-cubemap/Default-Sky-9-cubemap-ambient.texmeta.json"; if (!_defaultSkyboxNetworkTexture) { PROFILE_RANGE(render, "Process Default Skybox"); @@ -658,7 +659,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { if (!_defaultAmbientNetworkTexture) { PROFILE_RANGE(render, "Process Default Ambient map"); _defaultAmbientNetworkTexture = DependencyManager::get()->getTexture( - defaultSkyboxURL, image::TextureUsage::AMBIENT_TEXTURE); + defaultAmbientURL, image::TextureUsage::AMBIENT_TEXTURE); } if (_defaultSkyboxNetworkTexture && _defaultSkyboxNetworkTexture->isLoaded() && _defaultSkyboxNetworkTexture->getGPUTexture()) {