mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 21:15:07 +02:00
Guard against unloaded env cubemaps
This commit is contained in:
parent
1e925d7bd8
commit
d7d351fc63
1 changed files with 20 additions and 13 deletions
|
@ -140,8 +140,8 @@ void EntityTreeRenderer::update() {
|
||||||
// If we haven't already updated and previously attempted to load a texture,
|
// If we haven't already updated and previously attempted to load a texture,
|
||||||
// check if the texture loaded and apply it
|
// check if the texture loaded and apply it
|
||||||
if (!updated && (
|
if (!updated && (
|
||||||
(_pendingSkyboxTexture && _skyboxTexture && _skyboxTexture->isLoaded()) ||
|
(_pendingSkyboxTexture && (!_skyboxTexture || _skyboxTexture->isLoaded())) ||
|
||||||
(_pendingAmbientTexture && _ambientTexture && _ambientTexture->isLoaded()))) {
|
(_pendingAmbientTexture && (!_ambientTexture && _ambientTexture->isLoaded())))) {
|
||||||
applyZonePropertiesToScene(_bestZone);
|
applyZonePropertiesToScene(_bestZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,15 +326,19 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
_ambientTexture.clear();
|
_ambientTexture.clear();
|
||||||
} else {
|
} else {
|
||||||
_ambientTexture = textureCache->getTexture(zone->getKeyLightProperties().getAmbientURL(), CUBE_TEXTURE);
|
_ambientTexture = textureCache->getTexture(zone->getKeyLightProperties().getAmbientURL(), CUBE_TEXTURE);
|
||||||
if (_ambientTexture && _ambientTexture->isLoaded() && _ambientTexture->getGPUTexture()) {
|
_pendingAmbientTexture = true;
|
||||||
|
|
||||||
|
if (_ambientTexture && _ambientTexture->isLoaded()) {
|
||||||
_pendingAmbientTexture = false;
|
_pendingAmbientTexture = false;
|
||||||
if (_ambientTexture->getGPUTexture()->getIrradiance()) {
|
|
||||||
sceneKeyLight->setAmbientSphere(_ambientTexture->getGPUTexture()->getIrradiance());
|
auto texture = _ambientTexture->getGPUTexture();
|
||||||
sceneKeyLight->setAmbientMap(_ambientTexture->getGPUTexture());
|
if (texture) {
|
||||||
|
sceneKeyLight->setAmbientSphere(texture->getIrradiance());
|
||||||
|
sceneKeyLight->setAmbientMap(texture);
|
||||||
isAmbientTextureSet = true;
|
isAmbientTextureSet = true;
|
||||||
|
} else {
|
||||||
|
qCDebug(entitiesrenderer) << "Failed to load ambient texture:" << zone->getKeyLightProperties().getAmbientURL();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_pendingAmbientTexture = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,24 +357,27 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zone->getSkyboxProperties().getURL().isEmpty()) {
|
if (zone->getSkyboxProperties().getURL().isEmpty()) {
|
||||||
skybox->setCubemap(gpu::TexturePointer());
|
skybox->setCubemap(nullptr);
|
||||||
_pendingSkyboxTexture = false;
|
_pendingSkyboxTexture = false;
|
||||||
_skyboxTexture.clear();
|
_skyboxTexture.clear();
|
||||||
} else {
|
} else {
|
||||||
// Update the Texture of the Skybox with the one pointed by this zone
|
// Update the Texture of the Skybox with the one pointed by this zone
|
||||||
_skyboxTexture = textureCache->getTexture(zone->getSkyboxProperties().getURL(), CUBE_TEXTURE);
|
_skyboxTexture = textureCache->getTexture(zone->getSkyboxProperties().getURL(), CUBE_TEXTURE);
|
||||||
|
_pendingSkyboxTexture = true;
|
||||||
|
|
||||||
|
if (_skyboxTexture && _skyboxTexture->isLoaded()) {
|
||||||
|
_pendingSkyboxTexture = false;
|
||||||
|
|
||||||
if (_skyboxTexture && _skyboxTexture->isLoaded() && _skyboxTexture->getGPUTexture()) {
|
|
||||||
auto texture = _skyboxTexture->getGPUTexture();
|
auto texture = _skyboxTexture->getGPUTexture();
|
||||||
skybox->setCubemap(texture);
|
skybox->setCubemap(texture);
|
||||||
_pendingSkyboxTexture = false;
|
if (!isAmbientTextureSet) {
|
||||||
if (!isAmbientTextureSet && texture->getIrradiance()) {
|
|
||||||
sceneKeyLight->setAmbientSphere(texture->getIrradiance());
|
sceneKeyLight->setAmbientSphere(texture->getIrradiance());
|
||||||
sceneKeyLight->setAmbientMap(texture);
|
sceneKeyLight->setAmbientMap(texture);
|
||||||
isAmbientTextureSet = true;
|
isAmbientTextureSet = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_pendingSkyboxTexture = true;
|
skybox->setCubemap(nullptr);
|
||||||
|
qCDebug(entitiesrenderer) << "Failed to load skybox:" << zone->getSkyboxProperties().getURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue