diff --git a/ext/ghoul b/ext/ghoul index 460ad44f0c..711fd33d85 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 460ad44f0c7208ef7a5a9d199792f1f4954c2310 +Subproject commit 711fd33d8536abc52242ae266566245bdc199a97 diff --git a/include/openspace/rendering/renderablecrawlingline.h b/include/openspace/rendering/renderablecrawlingline.h index a7979b2e0a..57356d9792 100644 --- a/include/openspace/rendering/renderablecrawlingline.h +++ b/include/openspace/rendering/renderablecrawlingline.h @@ -43,7 +43,6 @@ public: private: ghoul::opengl::ProgramObject* _program; - bool _programIsDirty; std::string _instrumentName; std::string _source; diff --git a/include/openspace/rendering/renderablefieldlines.h b/include/openspace/rendering/renderablefieldlines.h index 3f6ca14ffe..bd37f69b30 100644 --- a/include/openspace/rendering/renderablefieldlines.h +++ b/include/openspace/rendering/renderablefieldlines.h @@ -76,7 +76,6 @@ private: properties::StringProperty _seedPointSourceFile; ghoul::opengl::ProgramObject* _program; - bool _programIsDirty; ghoul::Dictionary _vectorFieldInfo; ghoul::Dictionary _fieldlineInfo; diff --git a/include/openspace/rendering/renderablepath.h b/include/openspace/rendering/renderablepath.h index 32b449df69..03637503a5 100644 --- a/include/openspace/rendering/renderablepath.h +++ b/include/openspace/rendering/renderablepath.h @@ -40,55 +40,54 @@ namespace ghoul { namespace openspace { - class RenderablePath : public Renderable { - public: - RenderablePath(const ghoul::Dictionary& dictionary); +class RenderablePath : public Renderable { +public: + RenderablePath(const ghoul::Dictionary& dictionary); - bool initialize() override; - bool deinitialize() override; + bool initialize() override; + bool deinitialize() override; - bool isReady() const override; + bool isReady() const override; - void render(const RenderData& data) override; - void update(const UpdateData& data) override; + void render(const RenderData& data) override; + void update(const UpdateData& data) override; - void calculatePath(std::string observer); - private: - struct VertexInfo { - float x, y, z, e; - //float r, g, b, a; - }; - void sendToGPU(); - void addPosition(psc pos); - void addColor(glm::vec4 col); - - glm::vec3 _lineColor; - glm::vec4 _lastPosition; - properties::FloatProperty _lineFade; - properties::FloatProperty _lineWidth; - properties::BoolProperty _drawLine; - - ghoul::opengl::ProgramObject* _programObject; - bool _programIsDirty; - - bool _successfullDictionaryFetch; - - std::string _target; - std::string _observer; - std::string _frame; - - GLuint _vaoID; - GLuint _vBufferID; - - bool _needsSweep; - - std::vector _vertexArray; - - float _increment; - double _start; - double _stop; - float _distanceFade; + void calculatePath(std::string observer); +private: + struct VertexInfo { + float x, y, z, e; + //float r, g, b, a; }; + void sendToGPU(); + void addPosition(psc pos); + void addColor(glm::vec4 col); + + glm::vec3 _lineColor; + glm::vec4 _lastPosition; + properties::FloatProperty _lineFade; + properties::FloatProperty _lineWidth; + properties::BoolProperty _drawLine; + + ghoul::opengl::ProgramObject* _programObject; + + bool _successfullDictionaryFetch; + + std::string _target; + std::string _observer; + std::string _frame; + + GLuint _vaoID; + GLuint _vBufferID; + + bool _needsSweep; + + std::vector _vertexArray; + + float _increment; + double _start; + double _stop; + float _distanceFade; +}; } // namespace openspace diff --git a/include/openspace/rendering/renderableplane.h b/include/openspace/rendering/renderableplane.h index 2c296da5f7..105ca7c7f9 100644 --- a/include/openspace/rendering/renderableplane.h +++ b/include/openspace/rendering/renderableplane.h @@ -75,7 +75,6 @@ private: bool _planeIsDirty; ghoul::opengl::ProgramObject* _shader; - bool _programIsDirty; bool _textureIsDirty; ghoul::opengl::Texture* _texture; ghoul::filesystem::File* _textureFile; diff --git a/include/openspace/rendering/renderableplaneprojection.h b/include/openspace/rendering/renderableplaneprojection.h index 8a7e8e4d75..92c5e479f6 100644 --- a/include/openspace/rendering/renderableplaneprojection.h +++ b/include/openspace/rendering/renderableplaneprojection.h @@ -43,57 +43,56 @@ namespace ghoul { } namespace openspace { - struct LinePoint; +struct LinePoint; - struct target { - std::string body; - std::string frame; - std::string node; - }; +struct target { + std::string body; + std::string frame; + std::string node; +}; - class RenderablePlaneProjection : public Renderable { +class RenderablePlaneProjection : public Renderable { - public: - RenderablePlaneProjection(const ghoul::Dictionary& dictionary); - ~RenderablePlaneProjection(); +public: + RenderablePlaneProjection(const ghoul::Dictionary& dictionary); + ~RenderablePlaneProjection(); - bool initialize() override; - bool deinitialize() override; + bool initialize() override; + bool deinitialize() override; - bool isReady() const override; + bool isReady() const override; - void render(const RenderData& data) override; - void update(const UpdateData& data) override; + void render(const RenderData& data) override; + void update(const UpdateData& data) override; - private: - void loadTexture(); - void updatePlane(const Image img, double currentTime); - std::string findClosestTarget(double currentTime); - void setTarget(std::string body); +private: + void loadTexture(); + void updatePlane(const Image img, double currentTime); + std::string findClosestTarget(double currentTime); + void setTarget(std::string body); - std::string _texturePath; + std::string _texturePath; - bool _planeIsDirty; + bool _planeIsDirty; - glm::dmat3 _stateMatrix; - std::string _frame; + glm::dmat3 _stateMatrix; + std::string _frame; - ghoul::opengl::ProgramObject* _shader; - bool _programIsDirty; - bool _textureIsDirty; - ghoul::opengl::Texture* _texture; - ghoul::filesystem::File* _textureFile; - GLuint _quad; - GLuint _vertexPositionBuffer; - std::string _spacecraft; - std::string _instrument; + ghoul::opengl::ProgramObject* _shader; + bool _textureIsDirty; + ghoul::opengl::Texture* _texture; + ghoul::filesystem::File* _textureFile; + GLuint _quad; + GLuint _vertexPositionBuffer; + std::string _spacecraft; + std::string _instrument; - double _previousTime; - target _target; - std::string _name; - bool _moving; - }; + double _previousTime; + target _target; + std::string _name; + bool _moving; +}; } // namespace openspace #endif diff --git a/include/openspace/rendering/renderablesphere.h b/include/openspace/rendering/renderablesphere.h index 2389998ce4..e8b7defddc 100644 --- a/include/openspace/rendering/renderablesphere.h +++ b/include/openspace/rendering/renderablesphere.h @@ -67,7 +67,6 @@ private: PowerScaledSphere* _sphere; - bool _programIsDirty; bool _sphereIsDirty; }; diff --git a/include/openspace/rendering/renderabletrail.h b/include/openspace/rendering/renderabletrail.h index 38a66a5070..cd04a00c22 100644 --- a/include/openspace/rendering/renderabletrail.h +++ b/include/openspace/rendering/renderabletrail.h @@ -66,7 +66,6 @@ private: properties::BoolProperty _showTimestamps; ghoul::opengl::ProgramObject* _programObject; - bool _programIsDirty; bool _successfullDictionaryFetch; diff --git a/include/openspace/rendering/stars/renderableconstellationbounds.h b/include/openspace/rendering/stars/renderableconstellationbounds.h index b127682f25..08299054f8 100644 --- a/include/openspace/rendering/stars/renderableconstellationbounds.h +++ b/include/openspace/rendering/stars/renderableconstellationbounds.h @@ -102,7 +102,6 @@ private: std::string _constellationFilename; ///< The file containing constellation names ghoul::opengl::ProgramObject* _program; - bool _programIsDirty; /// The list of all loaded constellation bounds std::vector _constellationBounds; diff --git a/include/openspace/rendering/stars/renderablestars.h b/include/openspace/rendering/stars/renderablestars.h index 4dac59231f..542a604850 100644 --- a/include/openspace/rendering/stars/renderablestars.h +++ b/include/openspace/rendering/stars/renderablestars.h @@ -77,7 +77,6 @@ private: properties::FloatProperty _minBillboardSize; ghoul::opengl::ProgramObject* _program; - bool _programIsDirty; std::string _speckFile; diff --git a/shaders/projectiveTexture_fs.glsl b/shaders/modules/projection/projectiveTexture_fs.glsl similarity index 99% rename from shaders/projectiveTexture_fs.glsl rename to shaders/modules/projection/projectiveTexture_fs.glsl index e6ba17dce7..6f34a71974 100644 --- a/shaders/projectiveTexture_fs.glsl +++ b/shaders/modules/projection/projectiveTexture_fs.glsl @@ -27,9 +27,9 @@ uniform vec4 campos; uniform vec4 objpos; //uniform vec3 camdir; // add this for specular + - -uniform float time; +uniform float time; uniform sampler2D texture1; uniform sampler2D texture2; diff --git a/shaders/projectiveTexture_vs.glsl b/shaders/modules/projection/projectiveTexture_vs.glsl similarity index 100% rename from shaders/projectiveTexture_vs.glsl rename to shaders/modules/projection/projectiveTexture_vs.glsl diff --git a/shaders/modules/stars/star_fs.glsl b/shaders/modules/stars/star_fs.glsl index 162f70b0e2..efde60046d 100644 --- a/shaders/modules/stars/star_fs.glsl +++ b/shaders/modules/stars/star_fs.glsl @@ -28,7 +28,7 @@ const int COLOROPTION_COLOR = 0; const int COLOROPTION_VELOCITY = 1; const int COLOROPTION_SPEED = 2; - + uniform sampler2D psfTexture; uniform sampler1D colorTexture; uniform float minBillboardSize; diff --git a/src/main.cpp b/src/main.cpp index 3396b8ef25..af5dc9325b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,6 +74,7 @@ int main(int argc, char** argv) { for (int i = 0; i < newArgc; ++i) newArgv[i] = const_cast(sgctArguments.at(i).c_str()); + // Need to set this before the creation of the sgct::Engine sgct::MessageHandler::instance()->setLogToConsole(false); sgct::MessageHandler::instance()->setShowTime(false); sgct::MessageHandler::instance()->setLogToCallback(true); diff --git a/src/rendering/planets/renderableplanetprojection.cpp b/src/rendering/planets/renderableplanetprojection.cpp index a0cb398db5..7e81e679a3 100644 --- a/src/rendering/planets/renderableplanetprojection.cpp +++ b/src/rendering/planets/renderableplanetprojection.cpp @@ -208,15 +208,20 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& } } -RenderablePlanetProjection::~RenderablePlanetProjection(){ +RenderablePlanetProjection::~RenderablePlanetProjection() { deinitialize(); } -bool RenderablePlanetProjection::initialize(){ +bool RenderablePlanetProjection::initialize() { bool completeSuccess = true; - if (_programObject == nullptr) - completeSuccess - &= OsEng.ref().configurationManager()->getValue("projectiveProgram", _programObject); + if (_programObject == nullptr) { + // projection program + _programObject = ghoul::opengl::ProgramObject::Build("projectiveProgram", + "${SHADERS}/modules/projection/projectiveTexture_vs.glsl", + "${SHADERS}/modules/projection/projectiveTexture_fs.glsl"); + if (!_programObject) + return false; + } if (_fboProgramObject == nullptr) completeSuccess @@ -492,8 +497,10 @@ void RenderablePlanetProjection::update(const UpdateData& data){ if (openspace::ImageSequencer2::ref().isReady() && _performProjection){ openspace::ImageSequencer2::ref().updateSequencer(_time); _capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID); - } - //floor fading to decimal + } + + if (_programObject->isDirty()) + _programObject->rebuildFromFile(); } void RenderablePlanetProjection::loadProjectionTexture(){ diff --git a/src/rendering/renderablecrawlingline.cpp b/src/rendering/renderablecrawlingline.cpp index 3e1166a890..b9510bc6cd 100644 --- a/src/rendering/renderablecrawlingline.cpp +++ b/src/rendering/renderablecrawlingline.cpp @@ -48,7 +48,6 @@ namespace openspace { RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _program(nullptr) - , _programIsDirty(false) , _imageSequenceTime(-1.f) , _vao(0) , _vbo(0) @@ -83,7 +82,6 @@ bool RenderableCrawlingLine::initialize() { ); if (!_program) return false; - _program->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); glGenVertexArrays(1, &_vao); glGenBuffers(1, &_vbo); @@ -148,6 +146,8 @@ void RenderableCrawlingLine::render(const RenderData& data) { } void RenderableCrawlingLine::update(const UpdateData& data) { + if (_program->isDirty()) + _program->rebuildFromFile(); glm::dmat3 transformMatrix = glm::dmat3(1); openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _referenceFrame, data.time, transformMatrix); diff --git a/src/rendering/renderablefieldlines.cpp b/src/rendering/renderablefieldlines.cpp index 06babef237..0df2d05e98 100644 --- a/src/rendering/renderablefieldlines.cpp +++ b/src/rendering/renderablefieldlines.cpp @@ -85,7 +85,6 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary) , _seedPointSource("source", "SeedPoint Source") , _seedPointSourceFile("sourceFile", "SeedPoint File") , _program(nullptr) - , _programIsDirty(false) , _seedPointsAreDirty(true) , _fieldLinesAreDirty(true) , _fieldlineVAO(0) @@ -210,12 +209,6 @@ bool RenderableFieldlines::initialize() { if (!_program) return false; - _program->setProgramObjectCallback( - [&](ghoul::opengl::ProgramObject*) { - this->_programIsDirty = true; - } - ); - return true; } @@ -251,10 +244,8 @@ void RenderableFieldlines::render(const RenderData& data) { } void RenderableFieldlines::update(const UpdateData&) { - if (_programIsDirty) { + if (_program->isDirty()) _program->rebuildFromFile(); - _programIsDirty = false; - } if (_seedPointsAreDirty) { loadSeedPoints(); diff --git a/src/rendering/renderablepath.cpp b/src/rendering/renderablepath.cpp index a5185ece21..9a3a2eff43 100644 --- a/src/rendering/renderablepath.cpp +++ b/src/rendering/renderablepath.cpp @@ -62,7 +62,6 @@ RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary) , _lineWidth("lineWidth", "Line Width", 2.f, 1.f, 20.f) , _drawLine("drawline", "Draw Line", false) , _programObject(nullptr) - , _programIsDirty(true) , _successfullDictionaryFetch(true) , _vaoID(0) , _vBufferID(0) @@ -107,7 +106,6 @@ bool RenderablePath::initialize() { ); if (!_programObject) return false; - _programObject->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); bool intervalSet = hasTimeInterval(); if (intervalSet) { @@ -197,10 +195,8 @@ void RenderablePath::update(const UpdateData& data) { return; } - if (_programIsDirty) { + if (_programObject->isDirty()) _programObject->rebuildFromFile(); - _programIsDirty = false; - } } void RenderablePath::calculatePath(std::string observer) { diff --git a/src/rendering/renderableplane.cpp b/src/rendering/renderableplane.cpp index ab144a22ee..64badebdde 100644 --- a/src/rendering/renderableplane.cpp +++ b/src/rendering/renderableplane.cpp @@ -54,7 +54,6 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) , _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f)) , _origin(Origin::Center) , _shader(nullptr) - , _programIsDirty(false) , _textureIsDirty(false) , _texture(nullptr) , _quad(0) @@ -129,7 +128,6 @@ bool RenderablePlane::initialize() { if (_shader == nullptr) OsEng.ref().configurationManager()->getValue("planeProgram", _shader); - _shader->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); loadTexture(); return isReady(); @@ -168,10 +166,8 @@ void RenderablePlane::render(const RenderData& data) { } void RenderablePlane::update(const UpdateData& data) { - if (_programIsDirty) { + if (_shader->isDirty()) _shader->rebuildFromFile(); - _programIsDirty = false; - } if (_planeIsDirty) createPlane(); diff --git a/src/rendering/renderableplaneprojection.cpp b/src/rendering/renderableplaneprojection.cpp index fed5ad02f6..ff9cb2fd47 100644 --- a/src/rendering/renderableplaneprojection.cpp +++ b/src/rendering/renderableplaneprojection.cpp @@ -52,7 +52,6 @@ RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& di , _texturePath("") , _planeIsDirty(false) , _shader(nullptr) - , _programIsDirty(false) , _textureIsDirty(false) , _texture(nullptr) , _quad(0) @@ -162,10 +161,8 @@ void RenderablePlaneProjection::update(const UpdateData& data) { updatePlane(img, time); } - if (_programIsDirty) { + if (_shader->isDirty()) _shader->rebuildFromFile(); - _programIsDirty = false; - } if (_textureIsDirty) { loadTexture(); diff --git a/src/rendering/renderablesphere.cpp b/src/rendering/renderablesphere.cpp index 9cc8a97b1e..e8bfd3ce96 100644 --- a/src/rendering/renderablesphere.cpp +++ b/src/rendering/renderablesphere.cpp @@ -59,7 +59,6 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) , _shader(nullptr) , _texture(nullptr) , _sphere(nullptr) - , _programIsDirty(false) , _sphereIsDirty(false) { std::string path; @@ -130,7 +129,6 @@ bool RenderableSphere::initialize() { "${SHADERS}/modules/sphere/sphere_fs.glsl"); if (!_shader) return false; - _shader->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); loadTexture(); @@ -172,10 +170,8 @@ void RenderableSphere::render(const RenderData& data) { } void RenderableSphere::update(const UpdateData& data) { - if (_programIsDirty) { + if (_shader->isDirty()) _shader->rebuildFromFile(); - _programIsDirty = false; - } if (_sphereIsDirty) { delete _sphere; diff --git a/src/rendering/renderabletrail.cpp b/src/rendering/renderabletrail.cpp index 04172a4b05..b02ec2d3f2 100644 --- a/src/rendering/renderabletrail.cpp +++ b/src/rendering/renderabletrail.cpp @@ -64,7 +64,6 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) , _lineWidth("lineWidth", "Line Width", 2.f, 1.f, 20.f) , _showTimestamps("timestamps", "Show Timestamps", false) , _programObject(nullptr) - , _programIsDirty(true) , _successfullDictionaryFetch(true) , _vaoID(0) , _vBufferID(0) @@ -119,7 +118,6 @@ bool RenderableTrail::initialize() { "${SHADERS}/modules/trails/ephemeris_fs.glsl"); if (!_programObject) return false; - _programObject->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); return completeSuccess; } @@ -195,10 +193,8 @@ void RenderableTrail::update(const UpdateData& data) { return; } - if (_programIsDirty) { + if (_programObject->isDirty()) _programObject->rebuildFromFile(); - _programIsDirty = false; - } double lightTime = 0.0; psc pscPos; diff --git a/src/rendering/stars/renderableconstellationbounds.cpp b/src/rendering/stars/renderableconstellationbounds.cpp index 43a60c05a6..25f87139b4 100644 --- a/src/rendering/stars/renderableconstellationbounds.cpp +++ b/src/rendering/stars/renderableconstellationbounds.cpp @@ -60,7 +60,6 @@ RenderableConstellationBounds::RenderableConstellationBounds( : Renderable(dictionary) , _vertexFilename("") , _constellationFilename("") - , _programIsDirty(false) , _distance("distance", "Distance to the celestial Sphere", 15.f, 0.f, 30.f) , _constellationSelection("constellationSelection", "Constellation Selection") , _originReferenceFrame("") @@ -96,7 +95,6 @@ bool RenderableConstellationBounds::initialize() { "${SHADERS}/modules/constellationbounds/constellationbounds_fs.glsl"); if (!_program) return false; - _program->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ this->_programIsDirty = true; }); bool loadSuccess = loadVertexFile(); if (!loadSuccess) @@ -178,10 +176,8 @@ void RenderableConstellationBounds::render(const RenderData& data) { } void RenderableConstellationBounds::update(const UpdateData& data) { - if (_programIsDirty) { + if (_program->isDirty()) _program->rebuildFromFile(); - _programIsDirty = false; - } SpiceManager::ref().getPositionTransformMatrix( _originReferenceFrame, diff --git a/src/rendering/stars/renderablestars.cpp b/src/rendering/stars/renderablestars.cpp index fc69275e71..4b0532fc90 100644 --- a/src/rendering/stars/renderablestars.cpp +++ b/src/rendering/stars/renderablestars.cpp @@ -90,7 +90,6 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) , _scaleFactor("scaleFactor", "Scale Factor", 5.f, 0.f, 10.f) , _minBillboardSize("minBillboardSize", "Min Billboard Size", 15.f, 1.f, 100.f) , _program(nullptr) - , _programIsDirty(false) , _speckFile("") , _nValuesPerStar(0) , _vao(0) @@ -151,7 +150,6 @@ bool RenderableStars::initialize() { "${SHADERS}/modules/stars/star_ge.glsl"); if (!_program) return false; - _program->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); completeSuccess &= loadData(); completeSuccess &= (_pointSpreadFunctionTexture != nullptr); @@ -227,10 +225,9 @@ void RenderableStars::render(const RenderData& data) { } void RenderableStars::update(const UpdateData& data) { - if (_programIsDirty) { + if (_program->isDirty()) { _program->rebuildFromFile(); _dataIsDirty = true; - _programIsDirty = false; } if (_dataIsDirty) { diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 3ce1d2f7ab..7d26ec72f9 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -184,15 +184,6 @@ bool Scene::initialize() { _programs.push_back(tmpProgram); OsEng.ref().configurationManager()->setValue("fboPassProgram", tmpProgram); - // projection program - tmpProgram = ProgramObject::Build("projectiveProgram", - "${SHADERS}/projectiveTexture_vs.glsl", - "${SHADERS}/projectiveTexture_fs.glsl"); - if (!tmpProgram) return false; - tmpProgram->setProgramObjectCallback(cb); - _programs.push_back(tmpProgram); - OsEng.ref().configurationManager()->setValue("projectiveProgram", tmpProgram); - // pscstandard tmpProgram = ProgramObject::Build("pscstandard", "${SHADERS}/pscstandard_vs.glsl",