mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:38:29 +02:00
For splat textures, use transparent white as a default.
This commit is contained in:
parent
530f5b0df8
commit
6e06b63709
4 changed files with 37 additions and 14 deletions
|
@ -719,7 +719,7 @@ void HeightfieldBuffer::render(bool cursor) {
|
||||||
const SharedObjectPointer texture = _textures.at(i);
|
const SharedObjectPointer texture = _textures.at(i);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
_networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
|
_networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
|
||||||
static_cast<HeightfieldTexture*>(texture.data())->getURL());
|
static_cast<HeightfieldTexture*>(texture.data())->getURL(), SPLAT_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -593,17 +593,20 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
||||||
NetworkMeshPart networkPart;
|
NetworkMeshPart networkPart;
|
||||||
if (!part.diffuseTexture.filename.isEmpty()) {
|
if (!part.diffuseTexture.filename.isEmpty()) {
|
||||||
networkPart.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.diffuseTexture.filename)), false, mesh.isEye, part.diffuseTexture.content);
|
_textureBase.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,
|
||||||
|
mesh.isEye, part.diffuseTexture.content);
|
||||||
networkPart.diffuseTexture->setLoadPriorities(_loadPriorities);
|
networkPart.diffuseTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
if (!part.normalTexture.filename.isEmpty()) {
|
if (!part.normalTexture.filename.isEmpty()) {
|
||||||
networkPart.normalTexture = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.normalTexture = Application::getInstance()->getTextureCache()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.normalTexture.filename)), true, false, part.normalTexture.content);
|
_textureBase.resolved(QUrl(part.normalTexture.filename)), NORMAL_TEXTURE,
|
||||||
|
false, part.normalTexture.content);
|
||||||
networkPart.normalTexture->setLoadPriorities(_loadPriorities);
|
networkPart.normalTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
if (!part.specularTexture.filename.isEmpty()) {
|
if (!part.specularTexture.filename.isEmpty()) {
|
||||||
networkPart.specularTexture = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.specularTexture = Application::getInstance()->getTextureCache()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.specularTexture.filename)), true, false, part.specularTexture.content);
|
_textureBase.resolved(QUrl(part.specularTexture.filename)), SPECULAR_TEXTURE,
|
||||||
|
false, part.specularTexture.content);
|
||||||
networkPart.specularTexture->setLoadPriorities(_loadPriorities);
|
networkPart.specularTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
networkMesh.parts.append(networkPart);
|
networkMesh.parts.append(networkPart);
|
||||||
|
|
|
@ -145,6 +145,8 @@ GLuint TextureCache::getPermutationNormalTextureID() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
|
const unsigned char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
const unsigned char TRANSPARENT_WHITE[] = { 0xFF, 0xFF, 0xFF, 0x0 };
|
||||||
|
const unsigned char OPAQUE_BLACK[] = { 0x0, 0x0, 0x0, 0xFF };
|
||||||
const unsigned char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
|
const unsigned char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
|
||||||
|
|
||||||
static void loadSingleColorTexture(const unsigned char* color) {
|
static void loadSingleColorTexture(const unsigned char* color) {
|
||||||
|
@ -175,13 +177,13 @@ GLuint TextureCache::getBlueTextureID() {
|
||||||
/// Extra data for creating textures.
|
/// Extra data for creating textures.
|
||||||
class TextureExtra {
|
class TextureExtra {
|
||||||
public:
|
public:
|
||||||
bool normalMap;
|
TextureType type;
|
||||||
const QByteArray& content;
|
const QByteArray& content;
|
||||||
};
|
};
|
||||||
|
|
||||||
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, bool normalMap, bool dilatable, const QByteArray& content) {
|
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, TextureType type, bool dilatable, const QByteArray& content) {
|
||||||
if (!dilatable) {
|
if (!dilatable) {
|
||||||
TextureExtra extra = { normalMap, content };
|
TextureExtra extra = { type, content };
|
||||||
return ResourceCache::getResource(url, QUrl(), false, &extra).staticCast<NetworkTexture>();
|
return ResourceCache::getResource(url, QUrl(), false, &extra).staticCast<NetworkTexture>();
|
||||||
}
|
}
|
||||||
NetworkTexturePointer texture = _dilatableNetworkTextures.value(url);
|
NetworkTexturePointer texture = _dilatableNetworkTextures.value(url);
|
||||||
|
@ -292,7 +294,7 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
||||||
QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
|
QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
|
||||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) {
|
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) {
|
||||||
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
||||||
return QSharedPointer<Resource>(new NetworkTexture(url, textureExtra->normalMap, textureExtra->content),
|
return QSharedPointer<Resource>(new NetworkTexture(url, textureExtra->type, textureExtra->content),
|
||||||
&Resource::allReferencesCleared);
|
&Resource::allReferencesCleared);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +318,7 @@ Texture::~Texture() {
|
||||||
glDeleteTextures(1, &_id);
|
glDeleteTextures(1, &_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap, const QByteArray& content) :
|
NetworkTexture::NetworkTexture(const QUrl& url, TextureType type, const QByteArray& content) :
|
||||||
Resource(url, !content.isEmpty()),
|
Resource(url, !content.isEmpty()),
|
||||||
_translucent(false) {
|
_translucent(false) {
|
||||||
|
|
||||||
|
@ -324,9 +326,25 @@ NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap, const QByteArray
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// default to white/blue
|
// default to white/blue/black
|
||||||
glBindTexture(GL_TEXTURE_2D, getID());
|
glBindTexture(GL_TEXTURE_2D, getID());
|
||||||
loadSingleColorTexture(normalMap ? OPAQUE_BLUE : OPAQUE_WHITE);
|
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);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
// if we have content, load it after we have our self pointer
|
// if we have content, load it after we have our self pointer
|
||||||
|
@ -465,7 +483,7 @@ void NetworkTexture::imageLoaded(const QImage& image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, const QByteArray& content) :
|
DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, const QByteArray& content) :
|
||||||
NetworkTexture(url, false, content),
|
NetworkTexture(url, DEFAULT_TEXTURE, content),
|
||||||
_innerRadius(0),
|
_innerRadius(0),
|
||||||
_outerRadius(0)
|
_outerRadius(0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,8 @@ class NetworkTexture;
|
||||||
|
|
||||||
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
||||||
|
|
||||||
|
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, SPLAT_TEXTURE };
|
||||||
|
|
||||||
/// Stores cached textures, including render-to-texture targets.
|
/// Stores cached textures, including render-to-texture targets.
|
||||||
class TextureCache : public ResourceCache {
|
class TextureCache : public ResourceCache {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -49,7 +51,7 @@ public:
|
||||||
GLuint getBlueTextureID();
|
GLuint getBlueTextureID();
|
||||||
|
|
||||||
/// Loads a texture from the specified URL.
|
/// Loads a texture from the specified URL.
|
||||||
NetworkTexturePointer getTexture(const QUrl& url, bool normalMap = false, bool dilatable = false,
|
NetworkTexturePointer getTexture(const QUrl& url, TextureType type = DEFAULT_TEXTURE, bool dilatable = false,
|
||||||
const QByteArray& content = QByteArray());
|
const QByteArray& content = QByteArray());
|
||||||
|
|
||||||
/// Returns a pointer to the primary framebuffer object. This render target includes a depth component, and is
|
/// Returns a pointer to the primary framebuffer object. This render target includes a depth component, and is
|
||||||
|
@ -123,7 +125,7 @@ class NetworkTexture : public Resource, public Texture {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NetworkTexture(const QUrl& url, bool normalMap, const QByteArray& content);
|
NetworkTexture(const QUrl& url, TextureType type, const QByteArray& content);
|
||||||
|
|
||||||
/// Checks whether it "looks like" this texture is translucent
|
/// Checks whether it "looks like" this texture is translucent
|
||||||
/// (majority of pixels neither fully opaque or fully transparent).
|
/// (majority of pixels neither fully opaque or fully transparent).
|
||||||
|
|
Loading…
Reference in a new issue