mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 21:59:44 +02:00
Adding HazeStage
This commit is contained in:
parent
f92707a00c
commit
2394d0931c
4 changed files with 145 additions and 2 deletions
|
@ -270,7 +270,6 @@ void EntityRenderer::removeFromScene(const ScenePointer& scene, Transaction& tra
|
|||
Item::clearID(_renderItemID);
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) {
|
||||
if (!isValidRenderItem()) {
|
||||
return;
|
||||
|
|
|
@ -89,7 +89,6 @@ public:
|
|||
bool backgroundPropertiesChanged() const { return _backgroundPropertiesChanged; }
|
||||
bool skyboxPropertiesChanged() const { return _skyboxPropertiesChanged; }
|
||||
|
||||
#pragma optimize("", off)
|
||||
bool hazePropertiesChanged() const {
|
||||
return _hazePropertiesChanged;
|
||||
}
|
||||
|
|
63
libraries/render-utils/src/HazeStage.cpp
Normal file
63
libraries/render-utils/src/HazeStage.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// HazeStage.cpp
|
||||
//
|
||||
// Created by Nissim Hadar on 9/26/2017.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "HazeStage.h"
|
||||
|
||||
#include "DeferredLightingEffect.h"
|
||||
|
||||
#include <gpu/Context.h>
|
||||
|
||||
std::string HazeStage::_stageName { "HAZE_STAGE"};
|
||||
|
||||
HazeStage::Index HazeStage::findHaze(const HazePointer& haze) const {
|
||||
auto found = _hazeMap.find(haze);
|
||||
if (found != _hazeMap.end()) {
|
||||
return INVALID_INDEX;
|
||||
} else {
|
||||
return (*found).second;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HazeStage::Index HazeStage::addHaze(const HazePointer& haze) {
|
||||
|
||||
auto found = _hazeMap.find(haze);
|
||||
if (found == _hazeMap.end()) {
|
||||
auto hazeId = _hazes.newElement(haze);
|
||||
// Avoid failing to allocate a haze, just pass
|
||||
if (hazeId != INVALID_INDEX) {
|
||||
|
||||
// Insert the haze and its index in the reverse map
|
||||
_hazeMap.insert(HazeMap::value_type(haze, hazeId));
|
||||
}
|
||||
return hazeId;
|
||||
} else {
|
||||
return (*found).second;
|
||||
}
|
||||
}
|
||||
|
||||
HazeStage::HazePointer HazeStage::removeHaze(Index index) {
|
||||
HazePointer removed = _hazes.freeElement(index);
|
||||
|
||||
if (removed) {
|
||||
_hazeMap.erase(removed);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
HazeStageSetup::HazeStageSetup() {
|
||||
}
|
||||
|
||||
void HazeStageSetup::run(const render::RenderContextPointer& renderContext) {
|
||||
auto stage = renderContext->_scene->getStage(HazeStage::getName());
|
||||
if (!stage) {
|
||||
renderContext->_scene->resetStage(HazeStage::getName(), std::make_shared<HazeStage>());
|
||||
}
|
||||
}
|
||||
|
82
libraries/render-utils/src/HazeStage.h
Normal file
82
libraries/render-utils/src/HazeStage.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
//
|
||||
// HazeStage.h
|
||||
|
||||
// Created by Nissim Hadar on 9/26/2017.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_render_utils_HazeStage_h
|
||||
#define hifi_render_utils_HazeStage_h
|
||||
|
||||
#include <model/Stage.h>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <render/IndexedContainer.h>
|
||||
#include <render/Stage.h>
|
||||
|
||||
#include "LightingModel.h"
|
||||
|
||||
// Haze stage to set up haze-related rendering tasks
|
||||
class HazeStage : public render::Stage {
|
||||
public:
|
||||
static std::string _stageName;
|
||||
static const std::string& getName() { return _stageName; }
|
||||
|
||||
using Index = render::indexed_container::Index;
|
||||
static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
||||
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
||||
|
||||
using HazePointer = model::SunSkyStagePointer;
|
||||
using Hazes = render::indexed_container::IndexedPointerVector<model::SunSkyStage>;
|
||||
using HazeMap = std::unordered_map<HazePointer, Index>;
|
||||
|
||||
using HazeIndices = std::vector<Index>;
|
||||
|
||||
|
||||
Index findHaze(const HazePointer& haze) const;
|
||||
Index addHaze(const HazePointer& haze);
|
||||
|
||||
HazePointer removeHaze(Index index);
|
||||
|
||||
bool checkHazeId(Index index) const { return _hazes.checkIndex(index); }
|
||||
|
||||
Index getNumHazes() const { return _hazes.getNumElements(); }
|
||||
Index getNumFreeHazes() const { return _hazes.getNumFreeIndices(); }
|
||||
Index getNumAllocatedHazes() const { return _hazes.getNumAllocatedIndices(); }
|
||||
|
||||
HazePointer getHaze(Index hazeId) const {
|
||||
return _hazes.get(hazeId);
|
||||
}
|
||||
|
||||
Hazes _hazes;
|
||||
HazeMap _hazeMap;
|
||||
|
||||
class Frame {
|
||||
public:
|
||||
Frame() {}
|
||||
|
||||
void clear() { _hazes.clear(); }
|
||||
|
||||
void pushHaze(HazeStage::Index index) { _hazes.emplace_back(index); }
|
||||
|
||||
HazeStage::HazeIndices _hazes;
|
||||
};
|
||||
|
||||
Frame _currentFrame;
|
||||
};
|
||||
using HazeStagePointer = std::shared_ptr<HazeStage>;
|
||||
|
||||
class HazeStageSetup {
|
||||
public:
|
||||
using JobModel = render::Job::Model<HazeStageSetup>;
|
||||
|
||||
HazeStageSetup();
|
||||
void run(const render::RenderContextPointer& renderContext);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue