Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

star trails #1888

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,17 @@ void StelApp::highGraphicsModeDraw()

const QList<StelModule*> 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", "GridLinesMgr", "NebulaMgr"}).contains(module->objectName()))
module->draw(core);
}

if(sceneMultisampledFBO)
{
Expand Down Expand Up @@ -1051,10 +1058,17 @@ void StelApp::draw()
else
{
const QList<StelModule*> 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", "GridLinesMgr", "NebulaMgr"}).contains(module->objectName()))
module->draw(core);
}
}

core->postDraw();
Expand Down Expand Up @@ -1375,6 +1389,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;
Expand Down
19 changes: 18 additions & 1 deletion src/core/StelCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
, de441Available(false)
, de440Active(false)
, de441Active(false)
, flagClearSky(true)
{
setObjectName("StelCore");
registerMathMetaTypes();
Expand Down Expand Up @@ -355,6 +356,9 @@

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);

Check notice on line 361 in src/core/StelCore.cpp

View check run for this annotation

codefactor.io / CodeFactor

src/core/StelCore.cpp#L361

Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
}

QString StelCore::getDefaultProjectionTypeKey() const
Expand Down Expand Up @@ -530,7 +534,13 @@
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();
}
Expand Down Expand Up @@ -3044,3 +3054,10 @@
}
program.setUniformValue("STELCORE_currentPlanetHeliocentricEclipticVelocity", velocity.toQVector());
}

void StelCore::setFlagClearSky(const bool state)
{
flagClearSky = state;
qDebug() << "flagClearSky now" << state;
emit flagClearSkyChanged(state);
}
10 changes: 10 additions & 0 deletions src/core/StelCore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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&);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
14 changes: 12 additions & 2 deletions src/core/StelViewportEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<n)*(1<<n), for instance 1022*1022. With a viewport size
// of 512*512 and viewportFovDiameter=512 you will get clamping
// artefacts in the 3 otherwise black hills on the bottom of the image.
Expand Down Expand Up @@ -177,7 +177,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
QTextStream in;
QString fName = StelFileMgr::findFile(custom_distortion_file);
if (fName.isEmpty()) {
qWarning() << "WARNING: could not open custom_distortion_file:" << custom_distortion_file;
qWarning() << "WARNING: could not find custom_distortion_file:" << custom_distortion_file;
} else {
file.setFileName(fName);
if(file.open(QIODevice::ReadOnly))
Expand Down Expand Up @@ -345,3 +345,13 @@ void StelViewportDistorterFisheyeToSphericMirror::paintViewportBuffer(const QOpe
GL(gl->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
}

void StelViewportFaderEffect::paintViewportBuffer(const QOpenGLFramebufferObject* buf) const
{
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());
}
11 changes: 11 additions & 0 deletions src/core/StelViewportEffect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,16 @@ class StelViewportDistorterFisheyeToSphericMirror : public StelViewportEffect
QVector<Vec2f> displayTexCoordList;
};

class StelViewportFaderEffect : public StelViewportEffect
{
public:
StelViewportFaderEffect() {}
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;
};

#endif // STELVIEWPORTEFFECT_HPP

2 changes: 1 addition & 1 deletion src/core/modules/LandscapeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(screenRd));
}
Expand Down Expand Up @@ -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<float>(getSpheroidAngularRadius(core))*60.f;
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/ZoneArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void SpecialZoneArray<Star>::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;
Expand Down
Loading