mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-18 02:49:03 -06:00
Removing ghosting from renderablemodel
Organizing shaders
This commit is contained in:
@@ -71,7 +71,7 @@ private:
|
||||
std::string _destination;
|
||||
std::string _target;
|
||||
|
||||
bool _isGhost;
|
||||
//bool _isGhost;
|
||||
int _frameCount;
|
||||
|
||||
psc _sunPosition;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace {
|
||||
const std::string keyStart = "StartTime";
|
||||
const std::string keyEnd = "EndTime";
|
||||
const std::string keyFading = "Shading.Fadeable";
|
||||
const std::string keyGhosting = "Shading.Ghosting";
|
||||
//const std::string keyGhosting = "Shading.Ghosting";
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
, _texture(nullptr)
|
||||
, _geometry(nullptr)
|
||||
, _alpha(1.f)
|
||||
, _isGhost(false)
|
||||
//, _isGhost(false)
|
||||
, _performShading("performShading", "Perform Shading", true)
|
||||
, _frameCount(0)
|
||||
{
|
||||
@@ -115,11 +115,11 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
addProperty(_performFade);
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(keyGhosting)) {
|
||||
bool ghosting;
|
||||
dictionary.getValue(keyGhosting, ghosting);
|
||||
_isGhost = ghosting;
|
||||
}
|
||||
//if (dictionary.hasKeyAndValue<bool>(keyGhosting)) {
|
||||
// bool ghosting;
|
||||
// dictionary.getValue(keyGhosting, ghosting);
|
||||
// _isGhost = ghosting;
|
||||
//}
|
||||
}
|
||||
|
||||
bool RenderableModel::isReady() const {
|
||||
@@ -131,9 +131,14 @@ bool RenderableModel::isReady() const {
|
||||
|
||||
bool RenderableModel::initialize() {
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess
|
||||
&= OsEng.ref().configurationManager()->getValue("GenericModelShader", _programObject);
|
||||
if (_programObject == nullptr) {
|
||||
// NH shader
|
||||
_programObject = ghoul::opengl::ProgramObject::Build("ModelProgram",
|
||||
"${SHADERS}/modules/model/model_vs.glsl",
|
||||
"${SHADERS}/modules/model/model_fs.glsl");
|
||||
if (!_programObject)
|
||||
return false;
|
||||
}
|
||||
|
||||
loadTexture();
|
||||
|
||||
@@ -219,24 +224,26 @@ void RenderableModel::render(const RenderData& data) {
|
||||
}
|
||||
|
||||
void RenderableModel::update(const UpdateData& data) {
|
||||
if (_programObject->isDirty())
|
||||
_programObject->rebuildFromFile();
|
||||
double _time = data.time;
|
||||
|
||||
double futureTime;
|
||||
if (_isGhost){
|
||||
futureTime = openspace::ImageSequencer2::ref().getNextCaptureTime();
|
||||
double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - data.time;
|
||||
double interval = openspace::ImageSequencer2::ref().getIntervalLength();
|
||||
double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
|
||||
if (interval > 60) {
|
||||
if (t < 0.8)
|
||||
_fading = static_cast<float>(t);
|
||||
else if (t >= 0.95)
|
||||
_fading = _fading - 0.5f;
|
||||
}
|
||||
else
|
||||
_fading = 0.f;
|
||||
_time = futureTime;
|
||||
}
|
||||
//if (_isGhost){
|
||||
// futureTime = openspace::ImageSequencer2::ref().getNextCaptureTime();
|
||||
// double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - data.time;
|
||||
// double interval = openspace::ImageSequencer2::ref().getIntervalLength();
|
||||
// double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
|
||||
// if (interval > 60) {
|
||||
// if (t < 0.8)
|
||||
// _fading = static_cast<float>(t);
|
||||
// else if (t >= 0.95)
|
||||
// _fading = _fading - 0.5f;
|
||||
// }
|
||||
// else
|
||||
// _fading = 0.f;
|
||||
// _time = futureTime;
|
||||
//}
|
||||
|
||||
// set spice-orientation in accordance to timestamp
|
||||
if (!_source.empty())
|
||||
|
||||
@@ -170,11 +170,6 @@ bool Scene::initialize() {
|
||||
_programUpdateLock.unlock();
|
||||
};
|
||||
|
||||
// Start Timing for building SceneGraph shaders
|
||||
typedef std::chrono::high_resolution_clock clock_;
|
||||
typedef std::chrono::duration<double, std::ratio<1> > second_;
|
||||
std::chrono::time_point<clock_> beginning(clock_::now());
|
||||
|
||||
// fboPassthrough program
|
||||
tmpProgram = ProgramObject::Build("fboPassProgram",
|
||||
"${SHADERS}/fboPass_vs.glsl",
|
||||
@@ -193,16 +188,6 @@ bool Scene::initialize() {
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager()->setValue("pscShader", tmpProgram);
|
||||
|
||||
|
||||
// NH shader
|
||||
tmpProgram = ProgramObject::Build("ModelProgram",
|
||||
"${SHADERS}/model_vs.glsl",
|
||||
"${SHADERS}/model_fs.glsl");
|
||||
if (!tmpProgram) return false;
|
||||
tmpProgram->setProgramObjectCallback(cb);
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager()->setValue("GenericModelShader", tmpProgram);
|
||||
|
||||
// Night texture program
|
||||
tmpProgram = ProgramObject::Build("nightTextureProgram",
|
||||
"${SHADERS}/nighttexture_vs.glsl",
|
||||
@@ -257,11 +242,6 @@ bool Scene::initialize() {
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager()->setValue("GridProgram", tmpProgram);
|
||||
|
||||
// Done building shaders
|
||||
double elapsed = std::chrono::duration_cast<second_>(clock_::now()-beginning).count();
|
||||
LINFO("Time to load scene graph shaders: " << elapsed << " seconds");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user