mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 12:12:32 +02:00
add version to texmeta.json files, fallback to original file if version has changed for skyboxes
This commit is contained in:
parent
fa7a998cca
commit
4eeff52746
6 changed files with 27 additions and 10 deletions
|
@ -26,13 +26,6 @@ layout(location=0) in vec3 _normal;
|
||||||
layout(location=0) out vec4 _fragColor;
|
layout(location=0) out vec4 _fragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec3 coord = normalize(_normal);
|
vec3 skyboxColor = texture(cubeMap, normalize(_normal)).rgb;
|
||||||
vec3 color = skybox.color.rgb;
|
_fragColor = vec4(mix(skybox.color.rgb, skyboxColor, skybox.color.a), 1.0);
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,6 +690,8 @@ void convertImageToLDRTexture(gpu::Texture* texture, Image&& image, BackendTarge
|
||||||
compressionOptions.setFormat(nvtt::Format_BC4);
|
compressionOptions.setFormat(nvtt::Format_BC4);
|
||||||
} else if (mipFormat == gpu::Element::COLOR_COMPRESSED_BCX_XY) {
|
} else if (mipFormat == gpu::Element::COLOR_COMPRESSED_BCX_XY) {
|
||||||
compressionOptions.setFormat(nvtt::Format_BC5);
|
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) {
|
} else if (mipFormat == gpu::Element::COLOR_COMPRESSED_BCX_SRGBA_HIGH) {
|
||||||
alphaMode = nvtt::AlphaMode_Transparency;
|
alphaMode = nvtt::AlphaMode_Transparency;
|
||||||
compressionOptions.setFormat(nvtt::Format_BC7);
|
compressionOptions.setFormat(nvtt::Format_BC7);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
const QString TEXTURE_META_EXTENSION = ".texmeta.json";
|
const QString TEXTURE_META_EXTENSION = ".texmeta.json";
|
||||||
|
const uint16_t KTX_VERSION = 1;
|
||||||
|
|
||||||
bool TextureMeta::deserialize(const QByteArray& data, TextureMeta* meta) {
|
bool TextureMeta::deserialize(const QByteArray& data, TextureMeta* meta) {
|
||||||
QJsonParseError error;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +66,7 @@ QByteArray TextureMeta::serialize() {
|
||||||
root["original"] = original.toString();
|
root["original"] = original.toString();
|
||||||
root["uncompressed"] = uncompressed.toString();
|
root["uncompressed"] = uncompressed.toString();
|
||||||
root["compressed"] = compressed;
|
root["compressed"] = compressed;
|
||||||
|
root["version"] = KTX_VERSION;
|
||||||
doc.setObject(root);
|
doc.setObject(root);
|
||||||
|
|
||||||
return doc.toJson();
|
return doc.toJson();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "khronos/KHR.h"
|
#include "khronos/KHR.h"
|
||||||
|
|
||||||
extern const QString TEXTURE_META_EXTENSION;
|
extern const QString TEXTURE_META_EXTENSION;
|
||||||
|
extern const uint16_t KTX_VERSION;
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template<> struct hash<khronos::gl::texture::InternalFormat> {
|
template<> struct hash<khronos::gl::texture::InternalFormat> {
|
||||||
|
@ -37,6 +38,7 @@ struct TextureMeta {
|
||||||
QUrl original;
|
QUrl original;
|
||||||
QUrl uncompressed;
|
QUrl uncompressed;
|
||||||
std::unordered_map<khronos::gl::texture::InternalFormat, QUrl> availableTextureTypes;
|
std::unordered_map<khronos::gl::texture::InternalFormat, QUrl> availableTextureTypes;
|
||||||
|
uint16_t version { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1065,6 +1065,21 @@ void NetworkTexture::loadMetaContent(const QByteArray& content) {
|
||||||
return;
|
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<TextureCache>();
|
||||||
|
auto self = _self.lock();
|
||||||
|
if (!self) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QMetaObject::invokeMethod(this, "attemptRequest", Qt::QueuedConnection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& backend = DependencyManager::get<TextureCache>()->getGPUContext()->getBackend();
|
auto& backend = DependencyManager::get<TextureCache>()->getGPUContext()->getBackend();
|
||||||
for (auto pair : meta.availableTextureTypes) {
|
for (auto pair : meta.availableTextureTypes) {
|
||||||
gpu::Element elFormat;
|
gpu::Element elFormat;
|
||||||
|
|
|
@ -42,5 +42,5 @@ void main(void) {
|
||||||
color = max(color, vec3(0));
|
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
|
// 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));
|
color = pow(color, vec3(2.2));
|
||||||
_fragColor = vec4(color, 0.0);
|
_fragColor = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue