From 66dd0dc34ee0a5ae7dae71d7090258543b84ccd7 Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Fri, 3 Apr 2020 02:17:55 +0200 Subject: [PATCH 1/5] Attempt creating a star trail effect. Currently this leads to a white-out within seconds. We would need an fps-dependent frame decay. --- src/core/StelCore.cpp | 19 ++++++++++++++++++- src/core/StelCore.hpp | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/core/StelCore.cpp b/src/core/StelCore.cpp index 19cd7a00bb381..da7b1250d96b2 100644 --- a/src/core/StelCore.cpp +++ b/src/core/StelCore.cpp @@ -106,6 +106,7 @@ StelCore::StelCore() , de441Available(false) , de440Active(false) , de441Active(false) + , flagClearSky(true) { setObjectName("StelCore"); registerMathMetaTypes(); @@ -355,6 +356,9 @@ void StelCore::init() actionsMgr->addAction("actionHorizontal_Flip", displayGroup, N_("Flip scene horizontally"), this, "flipHorz", "Ctrl+Shift+H", "", true); actionsMgr->addAction("actionVertical_Flip", displayGroup, N_("Flip scene vertically"), this, "flipVert", "Ctrl+Shift+V", "", true); + + actionsMgr->addAction("actionClear_Background", displayGroup, N_("Toggle background clearing"), this, "flagClearSky", "Ctrl+Alt+C", "", true); + } QString StelCore::getDefaultProjectionTypeKey() const @@ -530,7 +534,13 @@ void StelCore::preDraw() Vec3f backColor = StelMainView::getInstance().getSkyBackgroundColor(); QOpenGLFunctions* gl = QOpenGLContext::currentContext()->functions(); gl->glClearColor(backColor[0], backColor[1], backColor[2], 0.f); - gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + if (flagClearSky) + gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + else + { + // TODO: dim whole framebuffer to 90%, else we are overexposed much too fast. + gl->glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } skyDrawer->preDraw(); } @@ -3044,3 +3054,10 @@ void StelCore::setAberrationUniforms(QOpenGLShaderProgram& program) const } program.setUniformValue("STELCORE_currentPlanetHeliocentricEclipticVelocity", velocity.toQVector()); } + +void StelCore::setFlagClearSky(const bool state) +{ + flagClearSky = state; + qDebug() << "flagClearSky now" << state; + emit flagClearSkyChanged(state); +} diff --git a/src/core/StelCore.hpp b/src/core/StelCore.hpp index d7413f6da6ed3..6cbd03727c9b4 100644 --- a/src/core/StelCore.hpp +++ b/src/core/StelCore.hpp @@ -67,6 +67,7 @@ class StelCore : public QObject Q_PROPERTY(bool flagUseDST READ getUseDST WRITE setUseDST NOTIFY flagUseDSTChanged) Q_PROPERTY(bool startupTimeStop READ getStartupTimeStop WRITE setStartupTimeStop NOTIFY startupTimeStopChanged) Q_PROPERTY(DitheringMode ditheringMode READ getDitheringMode WRITE setDitheringMode NOTIFY ditheringModeChanged) + Q_PROPERTY(bool flagClearSky READ getFlagClearSky WRITE setFlagClearSky NOTIFY flagClearSkyChanged) public: //! @enum FrameType @@ -794,6 +795,11 @@ public slots: //! Converts magnitude/arcsecĀ² to luminance in cd/mĀ². static float mpsasToLuminance(const float mag) { return 10.8e4f*std::pow(10.f, -0.4f*mag); } + //! get state of the clear sky flag. For regular use it should be true, while false will overdraw the previous frame + bool getFlagClearSky() const {return flagClearSky;} + //! set state of the clear sky flag. For regular use it should be true, while false will overdraw the previous frame + void setFlagClearSky(const bool state); + signals: //! This signal is emitted when the observer location has changed. void locationChanged(const StelLocation&); @@ -847,6 +853,8 @@ public slots: void configurationDataSaved(); void updateSearchLists(); void ditheringModeChanged(DitheringMode mode); + //! Emitted when clear sky flag changed. + void flagClearSkyChanged(bool state); private slots: //! Call this whenever latitude changes. I.e., just connect it to the locationChanged() signal. @@ -951,6 +959,8 @@ private slots: bool de441Available; // ephem file found bool de440Active; // available and user-activated. bool de441Active; // available and user-activated. + + bool flagClearSky; // Keep this true unless you want to render star streaks. }; #endif // STELCORE_HPP From 51bf016e60a9391147ecd54f483e5f96584e8312 Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Tue, 14 Sep 2021 19:28:34 +0200 Subject: [PATCH 2/5] Maybe proceed with a ViewportEffect? --- src/core/StelViewportEffect.cpp | 13 +++++++++++-- src/core/StelViewportEffect.hpp | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/core/StelViewportEffect.cpp b/src/core/StelViewportEffect.cpp index eec0457913b0b..651c8196fdaa3 100644 --- a/src/core/StelViewportEffect.cpp +++ b/src/core/StelViewportEffect.cpp @@ -148,7 +148,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher // sharp image up to the border of the fisheye image, at the cost of // accepting clamping artefacts. You can get rid of the clamping - // artefacts by specifying a viewport size a little less then + // artefacts by specifying a viewport size a little less than // (1<glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); } +void StelViewportFaderEffect::alterBuffer(QOpenGLFramebufferObject* buf) const +{ + Q_UNUSED(buf) + // TODO: I am still unsure about how to use this. When I want to have a scene fading to black (effect of a light echo or showing star trails), + // will the main buffer be changed, or can I only apply an effect to the finally displayed image? + // https://stackoverflow.com/questions/6810591/how-to-make-fading-to-black-effect-with-opengl +} + + diff --git a/src/core/StelViewportEffect.hpp b/src/core/StelViewportEffect.hpp index e7ea9898f057c..4847dd3fc59c1 100644 --- a/src/core/StelViewportEffect.hpp +++ b/src/core/StelViewportEffect.hpp @@ -70,5 +70,18 @@ class StelViewportDistorterFisheyeToSphericMirror : public StelViewportEffect QVector displayTexCoordList; }; +class StelViewportFaderEffect : public StelViewportEffect +{ +public: + StelViewportFaderEffect() {} + //~StelViewportFaderEffect() Q_DECL_OVERRIDE; + virtual QString getName() const Q_DECL_OVERRIDE {return "viewportFaderEffect";} + //! Alter the GL frame buffer, this method must not display anything. + //! The implementation in this class reduces the brightness of the existing buffer. + virtual void alterBuffer(QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; + //virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; +//private: +}; + #endif // STELVIEWPORTEFFECT_HPP From a4ae4b4a6deaad50615b2bf0636aab507889c0f6 Mon Sep 17 00:00:00 2001 From: Guillaume Chereau Date: Wed, 27 Oct 2021 17:37:07 +0800 Subject: [PATCH 3/5] Continue a bit the trail fader viewport effect Started by Georg in the previous commit. This can be enabled by setting [video] viewport_effect = viewportFaderEffect in the config file. This effect simply applies a mix of the current frame with the one before. Need to see if there is a way to improve the effect somehow. --- src/core/StelApp.cpp | 4 ++++ src/core/StelViewportEffect.cpp | 15 ++++++++------- src/core/StelViewportEffect.hpp | 6 ++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/core/StelApp.cpp b/src/core/StelApp.cpp index c395b55a5a4f9..6e88bdf5b2222 100644 --- a/src/core/StelApp.cpp +++ b/src/core/StelApp.cpp @@ -1375,6 +1375,10 @@ void StelApp::setViewportEffect(const QString& name) { viewportEffect = new StelViewportDistorterFisheyeToSphericMirror(w, h); } + else if (name == "viewportFaderEffect") + { + viewportEffect = new StelViewportFaderEffect(); + } else { qDebug() << "unknown viewport effect name:" << name; diff --git a/src/core/StelViewportEffect.cpp b/src/core/StelViewportEffect.cpp index 651c8196fdaa3..ef5998655bcca 100644 --- a/src/core/StelViewportEffect.cpp +++ b/src/core/StelViewportEffect.cpp @@ -345,12 +345,13 @@ void StelViewportDistorterFisheyeToSphericMirror::paintViewportBuffer(const QOpe GL(gl->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); } -void StelViewportFaderEffect::alterBuffer(QOpenGLFramebufferObject* buf) const +void StelViewportFaderEffect::paintViewportBuffer(const QOpenGLFramebufferObject* buf) const { - Q_UNUSED(buf) - // TODO: I am still unsure about how to use this. When I want to have a scene fading to black (effect of a light echo or showing star trails), - // will the main buffer be changed, or can I only apply an effect to the finally displayed image? - // https://stackoverflow.com/questions/6810591/how-to-make-fading-to-black-effect-with-opengl + StelPainter sPainter(StelApp::getInstance().getCore()->getProjection2d()); + QOpenGLFunctions* gl = sPainter.glFuncs(); + sPainter.setColor(1,1,1); + GL(gl->glBindTexture(GL_TEXTURE_2D, buf->texture())); + GL(gl->glBlendColor(1, 1, 1, 0.08)); + sPainter.setBlending(true, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); + sPainter.drawRect2d(0, 0, buf->width(), buf->height()); } - - diff --git a/src/core/StelViewportEffect.hpp b/src/core/StelViewportEffect.hpp index 4847dd3fc59c1..63d925d4a18c0 100644 --- a/src/core/StelViewportEffect.hpp +++ b/src/core/StelViewportEffect.hpp @@ -74,13 +74,11 @@ class StelViewportFaderEffect : public StelViewportEffect { public: StelViewportFaderEffect() {} - //~StelViewportFaderEffect() Q_DECL_OVERRIDE; virtual QString getName() const Q_DECL_OVERRIDE {return "viewportFaderEffect";} //! Alter the GL frame buffer, this method must not display anything. //! The implementation in this class reduces the brightness of the existing buffer. - virtual void alterBuffer(QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; - //virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; -//private: + // virtual void alterBuffer(QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; + virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; }; #endif // STELVIEWPORTEFFECT_HPP From b0054b8b61cf49ffe4abf6e7e467ad8a92d815c0 Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Sun, 15 Oct 2023 00:21:26 +0200 Subject: [PATCH 4/5] Suppress drawing of overly bright scene elements in "starstreak mode" --- src/core/StelApp.cpp | 30 ++++++++++++++++++++++-------- src/core/modules/LandscapeMgr.cpp | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/core/StelApp.cpp b/src/core/StelApp.cpp index 6e88bdf5b2222..c5b683a2b1c6d 100644 --- a/src/core/StelApp.cpp +++ b/src/core/StelApp.cpp @@ -977,10 +977,17 @@ void StelApp::highGraphicsModeDraw() const QList modules = moduleMgr->getCallOrders(StelModule::ActionDraw); - for(auto* module : modules) - { - module->draw(core); - } + if (core->getFlagClearSky()) + for (auto* module : modules) + { + module->draw(core); + } + else + for (auto* module : modules) + { + if (! QStringList({"MilkyWay", "ZodiacalLight", "LandscapeMgr", "GridlinesMgr"}).contains(module->objectName())) + module->draw(core); + } if(sceneMultisampledFBO) { @@ -1051,10 +1058,17 @@ void StelApp::draw() else { const QList modules = moduleMgr->getCallOrders(StelModule::ActionDraw); - for (auto* module : modules) - { - module->draw(core); - } + if (core->getFlagClearSky()) + for (auto* module : modules) + { + module->draw(core); + } + else + for (auto* module : modules) + { + if (! QStringList({"MilkyWay", "ZodiacalLight", "LandscapeMgr", "GridlinesMgr"}).contains(module->objectName())) + module->draw(core); + } } core->postDraw(); diff --git a/src/core/modules/LandscapeMgr.cpp b/src/core/modules/LandscapeMgr.cpp index 98e0e7b581976..70c65b5b29b4c 100644 --- a/src/core/modules/LandscapeMgr.cpp +++ b/src/core/modules/LandscapeMgr.cpp @@ -664,7 +664,7 @@ void LandscapeMgr::draw(StelCore* core) StelSkyDrawer* drawer=core->getSkyDrawer(); // Draw the atmosphere - if (!getFlagAtmosphereNoScatter()) + if (!getFlagAtmosphereNoScatter() && core->getFlagClearSky()) atmosphere->draw(core); // GZ 2016-01: When we draw the atmosphere with a low sun, it is possible that the glaring red ball is overpainted and thus invisible. From 70958540675d412c9ed105dbd2f0c207a2391aae Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Sun, 15 Oct 2023 11:36:29 +0200 Subject: [PATCH 5/5] Inhibit planet hint&labels Inhibit star labels Inhibit Gridlines and Nebula hints/labels Reactivate Landscape --- src/core/StelApp.cpp | 4 ++-- src/core/modules/Planet.cpp | 9 +++++---- src/core/modules/ZoneArray.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/StelApp.cpp b/src/core/StelApp.cpp index c5b683a2b1c6d..efc7fe96dd7df 100644 --- a/src/core/StelApp.cpp +++ b/src/core/StelApp.cpp @@ -985,7 +985,7 @@ void StelApp::highGraphicsModeDraw() else for (auto* module : modules) { - if (! QStringList({"MilkyWay", "ZodiacalLight", "LandscapeMgr", "GridlinesMgr"}).contains(module->objectName())) + if (! QStringList({"MilkyWay", "ZodiacalLight", "GridLinesMgr", "NebulaMgr"}).contains(module->objectName())) module->draw(core); } @@ -1066,7 +1066,7 @@ void StelApp::draw() else for (auto* module : modules) { - if (! QStringList({"MilkyWay", "ZodiacalLight", "LandscapeMgr", "GridlinesMgr"}).contains(module->objectName())) + if (! QStringList({"MilkyWay", "ZodiacalLight", "GridLinesMgr", "NebulaMgr"}).contains(module->objectName())) module->draw(core); } } diff --git a/src/core/modules/Planet.cpp b/src/core/modules/Planet.cpp index d227535f5d89f..fbd75b31e4a64 100644 --- a/src/core/modules/Planet.cpp +++ b/src/core/modules/Planet.cpp @@ -3082,11 +3082,12 @@ void Planet::draw(StelCore* core, float maxMagLabels, const QFont& planetNameFon // by putting here, only draw orbit if Planet is visible for clarity drawOrbit(core); // TODO - fade in here also... - if (flagLabels && ang_dist>0.25f && maxMagLabels>getVMagnitudeWithExtinction(core)) + if (flagLabels && ang_dist>0.25f && maxMagLabels>getVMagnitudeWithExtinction(core) && core->getFlagClearSky()) labelsFader=true; else labelsFader=false; - drawHints(core, planetNameFont); + if (core->getFlagClearSky()) + drawHints(core, planetNameFont); draw3dModel(core,transfo,static_cast(screenRd)); } @@ -3624,7 +3625,7 @@ void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP trans } // Draw the halo if it enabled in the ssystem.ini file (+ special case for backward compatible for the Sun) - if (isSun && drawSunHalo && core->getSkyDrawer()->getFlagEarlySunHalo()) + if (isSun && drawSunHalo && core->getSkyDrawer()->getFlagEarlySunHalo() && core->getFlagClearSky()) { // Prepare openGL lighting parameters according to luminance float surfArcMin2 = static_cast(getSpheroidAngularRadius(core))*60.f; @@ -3761,7 +3762,7 @@ void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP trans #endif } - bool allowDrawHalo = !isSun || !core->getSkyDrawer()->getFlagEarlySunHalo(); // We had drawn the sun already before the sphere. + bool allowDrawHalo = core->getFlagClearSky() && ( !isSun || !core->getSkyDrawer()->getFlagEarlySunHalo()); // We had drawn the sun already before the sphere. if (!isSun && !isMoon && currentLocationIsEarth) { // Let's hide halo when inner planet between Sun and observer (or moon between planet and observer). diff --git a/src/core/modules/ZoneArray.cpp b/src/core/modules/ZoneArray.cpp index 862c80bd7f24e..acd22f7e358d3 100644 --- a/src/core/modules/ZoneArray.cpp +++ b/src/core/modules/ZoneArray.cpp @@ -490,7 +490,7 @@ void SpecialZoneArray::draw(StelPainter* sPainter, int index, bool isInsid twinkleFactor=qMin(1.0f, 1.0f-0.9f*altAz[2]); // suppress twinkling in higher altitudes. Keep 0.1 twinkle amount in zenith. } - if (drawer->drawPointSource(sPainter, vf.toVec3d(), *tmpRcmag, s->getBVIndex(), !isInsideViewport, twinkleFactor) && s->hasName() && extinctedMagIndex < maxMagStarName && s->hasComponentID()<=1) + if (drawer->drawPointSource(sPainter, vf.toVec3d(), *tmpRcmag, s->getBVIndex(), !isInsideViewport, twinkleFactor) && core->getFlagClearSky() && s->hasName() && extinctedMagIndex < maxMagStarName && s->hasComponentID()<=1) { const float offset = tmpRcmag->radius*0.7f; const Vec3f colorr = StelSkyDrawer::indexToColor(s->getBVIndex())*0.75f;