mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +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);
|
||||
if (texture) {
|
||||
_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;
|
||||
if (!part.diffuseTexture.filename.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
if (!part.normalTexture.filename.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
if (!part.specularTexture.filename.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
networkMesh.parts.append(networkPart);
|
||||
|
|
|
@ -145,6 +145,8 @@ GLuint TextureCache::getPermutationNormalTextureID() {
|
|||
}
|
||||
|
||||
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 };
|
||||
|
||||
static void loadSingleColorTexture(const unsigned char* color) {
|
||||
|
@ -175,13 +177,13 @@ GLuint TextureCache::getBlueTextureID() {
|
|||
/// Extra data for creating textures.
|
||||
class TextureExtra {
|
||||
public:
|
||||
bool normalMap;
|
||||
TextureType type;
|
||||
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) {
|
||||
TextureExtra extra = { normalMap, content };
|
||||
TextureExtra extra = { type, content };
|
||||
return ResourceCache::getResource(url, QUrl(), false, &extra).staticCast<NetworkTexture>();
|
||||
}
|
||||
NetworkTexturePointer texture = _dilatableNetworkTextures.value(url);
|
||||
|
@ -292,7 +294,7 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
|||
QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
|
||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* 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);
|
||||
}
|
||||
|
||||
|
@ -316,7 +318,7 @@ Texture::~Texture() {
|
|||
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()),
|
||||
_translucent(false) {
|
||||
|
||||
|
@ -324,9 +326,25 @@ NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap, const QByteArray
|
|||
_loaded = true;
|
||||
}
|
||||
|
||||
// default to white/blue
|
||||
// default to white/blue/black
|
||||
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);
|
||||
|
||||
// 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) :
|
||||
NetworkTexture(url, false, content),
|
||||
NetworkTexture(url, DEFAULT_TEXTURE, content),
|
||||
_innerRadius(0),
|
||||
_outerRadius(0)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,8 @@ class NetworkTexture;
|
|||
|
||||
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
||||
|
||||
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, SPLAT_TEXTURE };
|
||||
|
||||
/// Stores cached textures, including render-to-texture targets.
|
||||
class TextureCache : public ResourceCache {
|
||||
Q_OBJECT
|
||||
|
@ -49,7 +51,7 @@ public:
|
|||
GLuint getBlueTextureID();
|
||||
|
||||
/// 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());
|
||||
|
||||
/// 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:
|
||||
|
||||
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
|
||||
/// (majority of pixels neither fully opaque or fully transparent).
|
||||
|
|
Loading…
Reference in a new issue