mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:28:48 +02:00
Use blue default texture when we fail to load a normal map.
This commit is contained in:
parent
070e755368
commit
55de8ceb85
4 changed files with 14 additions and 14 deletions
|
@ -102,7 +102,7 @@ void Head::init() {
|
||||||
_eyePositionLocation = _irisProgram.uniformLocation("eyePosition");
|
_eyePositionLocation = _irisProgram.uniformLocation("eyePosition");
|
||||||
|
|
||||||
_irisTexture = Application::getInstance()->getTextureCache()->getTexture(QUrl::fromLocalFile(IRIS_TEXTURE_FILENAME),
|
_irisTexture = Application::getInstance()->getTextureCache()->getTexture(QUrl::fromLocalFile(IRIS_TEXTURE_FILENAME),
|
||||||
true).staticCast<DilatableNetworkTexture>();
|
false, true).staticCast<DilatableNetworkTexture>();
|
||||||
}
|
}
|
||||||
_faceModel.init();
|
_faceModel.init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,11 +365,11 @@ void NetworkGeometry::maybeReadModelWithMapping() {
|
||||||
basePath = basePath.left(basePath.lastIndexOf('/') + 1);
|
basePath = basePath.left(basePath.lastIndexOf('/') + 1);
|
||||||
if (!part.diffuseFilename.isEmpty()) {
|
if (!part.diffuseFilename.isEmpty()) {
|
||||||
url.setPath(basePath + part.diffuseFilename);
|
url.setPath(basePath + part.diffuseFilename);
|
||||||
networkPart.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(url, mesh.isEye);
|
networkPart.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(url, false, mesh.isEye);
|
||||||
}
|
}
|
||||||
if (!part.normalFilename.isEmpty()) {
|
if (!part.normalFilename.isEmpty()) {
|
||||||
url.setPath(basePath + part.normalFilename);
|
url.setPath(basePath + part.normalFilename);
|
||||||
networkPart.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url);
|
networkPart.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, true);
|
||||||
}
|
}
|
||||||
networkMesh.parts.append(networkPart);
|
networkMesh.parts.append(networkPart);
|
||||||
|
|
||||||
|
|
|
@ -121,18 +121,18 @@ GLuint TextureCache::getFileTextureID(const QString& filename) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<NetworkTexture> TextureCache::getTexture(const QUrl& url, bool dilatable) {
|
QSharedPointer<NetworkTexture> TextureCache::getTexture(const QUrl& url, bool normalMap, bool dilatable) {
|
||||||
QSharedPointer<NetworkTexture> texture;
|
QSharedPointer<NetworkTexture> texture;
|
||||||
if (dilatable) {
|
if (dilatable) {
|
||||||
texture = _dilatableNetworkTextures.value(url);
|
texture = _dilatableNetworkTextures.value(url);
|
||||||
if (texture.isNull()) {
|
if (texture.isNull()) {
|
||||||
texture = QSharedPointer<NetworkTexture>(new DilatableNetworkTexture(url));
|
texture = QSharedPointer<NetworkTexture>(new DilatableNetworkTexture(url, normalMap));
|
||||||
_dilatableNetworkTextures.insert(url, texture);
|
_dilatableNetworkTextures.insert(url, texture);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
texture = _networkTextures.value(url);
|
texture = _networkTextures.value(url);
|
||||||
if (texture.isNull()) {
|
if (texture.isNull()) {
|
||||||
texture = QSharedPointer<NetworkTexture>(new NetworkTexture(url));
|
texture = QSharedPointer<NetworkTexture>(new NetworkTexture(url, normalMap));
|
||||||
_networkTextures.insert(url, texture);
|
_networkTextures.insert(url, texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ Texture::~Texture() {
|
||||||
glDeleteTextures(1, &_id);
|
glDeleteTextures(1, &_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const QUrl& url) : _reply(NULL), _averageColor(1.0f, 1.0f, 1.0f, 1.0f) {
|
NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) : _reply(NULL), _averageColor(1.0f, 1.0f, 1.0f, 1.0f) {
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -230,9 +230,9 @@ NetworkTexture::NetworkTexture(const QUrl& url) : _reply(NULL), _averageColor(1.
|
||||||
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleDownloadProgress(qint64,qint64)));
|
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleDownloadProgress(qint64,qint64)));
|
||||||
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleReplyError()));
|
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleReplyError()));
|
||||||
|
|
||||||
// default to white
|
// default to white/blue
|
||||||
glBindTexture(GL_TEXTURE_2D, getID());
|
glBindTexture(GL_TEXTURE_2D, getID());
|
||||||
loadSingleColorTexture(OPAQUE_WHITE);
|
loadSingleColorTexture(normalMap ? OPAQUE_BLUE : OPAQUE_WHITE);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,8 +288,8 @@ void NetworkTexture::handleReplyError() {
|
||||||
_reply = NULL;
|
_reply = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url) :
|
DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, bool normalMap) :
|
||||||
NetworkTexture(url),
|
NetworkTexture(url, normalMap),
|
||||||
_innerRadius(0),
|
_innerRadius(0),
|
||||||
_outerRadius(0)
|
_outerRadius(0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
GLuint getFileTextureID(const QString& filename);
|
GLuint getFileTextureID(const QString& filename);
|
||||||
|
|
||||||
/// Loads a texture from the specified URL.
|
/// Loads a texture from the specified URL.
|
||||||
QSharedPointer<NetworkTexture> getTexture(const QUrl& url, bool dilatable = false);
|
QSharedPointer<NetworkTexture> getTexture(const QUrl& url, bool normalMap = false, bool dilatable = false);
|
||||||
|
|
||||||
/// 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
|
||||||
/// used for scene rendering.
|
/// used for scene rendering.
|
||||||
|
@ -105,7 +105,7 @@ class NetworkTexture : public QObject, public Texture {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NetworkTexture(const QUrl& url);
|
NetworkTexture(const QUrl& url, bool normalMap);
|
||||||
~NetworkTexture();
|
~NetworkTexture();
|
||||||
|
|
||||||
/// Returns the average color over the entire texture.
|
/// Returns the average color over the entire texture.
|
||||||
|
@ -132,7 +132,7 @@ class DilatableNetworkTexture : public NetworkTexture {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DilatableNetworkTexture(const QUrl& url);
|
DilatableNetworkTexture(const QUrl& url, bool normalMap);
|
||||||
|
|
||||||
/// Returns a pointer to a texture with the requested amount of dilation.
|
/// Returns a pointer to a texture with the requested amount of dilation.
|
||||||
QSharedPointer<Texture> getDilatedTexture(float dilation);
|
QSharedPointer<Texture> getDilatedTexture(float dilation);
|
||||||
|
|
Loading…
Reference in a new issue