mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +02:00
Release skybox texs when not rendering
This commit is contained in:
parent
7db22ee8c2
commit
0e9b783ca3
4 changed files with 27 additions and 4 deletions
|
@ -297,7 +297,14 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
auto sceneLocation = sceneStage->getLocation();
|
auto sceneLocation = sceneStage->getLocation();
|
||||||
auto sceneTime = sceneStage->getTime();
|
auto sceneTime = sceneStage->getTime();
|
||||||
|
|
||||||
|
// Skybox and procedural skybox data
|
||||||
|
auto skybox = std::dynamic_pointer_cast<ProceduralSkybox>(skyStage->getSkybox());
|
||||||
|
static QString userData;
|
||||||
|
|
||||||
if (!zone) {
|
if (!zone) {
|
||||||
|
userData = QString();
|
||||||
|
skybox->clear();
|
||||||
|
|
||||||
_pendingSkyboxTexture = false;
|
_pendingSkyboxTexture = false;
|
||||||
_skyboxTexture.clear();
|
_skyboxTexture.clear();
|
||||||
|
|
||||||
|
@ -373,9 +380,7 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
|
|
||||||
switch (zone->getBackgroundMode()) {
|
switch (zone->getBackgroundMode()) {
|
||||||
case BACKGROUND_MODE_SKYBOX: {
|
case BACKGROUND_MODE_SKYBOX: {
|
||||||
auto skybox = std::dynamic_pointer_cast<ProceduralSkybox>(skyStage->getSkybox());
|
|
||||||
skybox->setColor(zone->getSkyboxProperties().getColorVec3());
|
skybox->setColor(zone->getSkyboxProperties().getColorVec3());
|
||||||
static QString userData;
|
|
||||||
if (userData != zone->getUserData()) {
|
if (userData != zone->getUserData()) {
|
||||||
userData = zone->getUserData();
|
userData = zone->getUserData();
|
||||||
skybox->parse(userData);
|
skybox->parse(userData);
|
||||||
|
@ -414,9 +419,15 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
|
|
||||||
case BACKGROUND_MODE_INHERIT:
|
case BACKGROUND_MODE_INHERIT:
|
||||||
default:
|
default:
|
||||||
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application background through
|
// Clear the skybox to release its textures
|
||||||
_pendingSkyboxTexture = false;
|
userData = QString();
|
||||||
|
skybox->clear();
|
||||||
|
|
||||||
_skyboxTexture.clear();
|
_skyboxTexture.clear();
|
||||||
|
_pendingSkyboxTexture = false;
|
||||||
|
|
||||||
|
// Let the application background through
|
||||||
|
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ public:
|
||||||
void setCubemap(const gpu::TexturePointer& cubemap);
|
void setCubemap(const gpu::TexturePointer& cubemap);
|
||||||
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
||||||
|
|
||||||
|
virtual void clear() { setCubemap(nullptr); }
|
||||||
|
|
||||||
void prepare(gpu::Batch& batch, int textureSlot = SKYBOX_SKYMAP_SLOT, int bufferSlot = SKYBOX_CONSTANTS_SLOT) const;
|
void prepare(gpu::Batch& batch, int textureSlot = SKYBOX_SKYMAP_SLOT, int bufferSlot = SKYBOX_CONSTANTS_SLOT) const;
|
||||||
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
|
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,14 @@ ProceduralSkybox::ProceduralSkybox() : model::Skybox() {
|
||||||
_procedural._state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP));
|
_procedural._state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProceduralSkybox::clear() {
|
||||||
|
// Parse and prepare a procedural with no shaders to release textures
|
||||||
|
parse(QString());
|
||||||
|
_procedural.ready();
|
||||||
|
|
||||||
|
Skybox::clear();
|
||||||
|
}
|
||||||
|
|
||||||
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
|
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
|
||||||
if (_procedural.ready()) {
|
if (_procedural.ready()) {
|
||||||
ProceduralSkybox::render(batch, frustum, (*this));
|
ProceduralSkybox::render(batch, frustum, (*this));
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
|
|
||||||
void parse(const QString& userData) { _procedural.parse(userData); }
|
void parse(const QString& userData) { _procedural.parse(userData); }
|
||||||
|
|
||||||
|
virtual void clear() override;
|
||||||
|
|
||||||
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
|
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
|
||||||
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox);
|
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue