Merge lp:~stellarium/stellarium/corona into lp:stellarium

Proposed by Alexander Wolf
Status: Superseded
Proposed branch: lp:~stellarium/stellarium/corona
Merge into: lp:stellarium
Diff against target: 202 lines (+128/-4) (has conflicts)
6 files modified
src/core/StelCore.cpp (+8/-2)
src/core/StelSkyDrawer.cpp (+19/-0)
src/core/StelSkyDrawer.hpp (+5/-0)
src/core/modules/Planet.cpp (+19/-2)
src/core/modules/SolarSystem.cpp (+74/-0)
src/core/modules/SolarSystem.hpp (+3/-0)
Text conflict in src/core/StelSkyDrawer.cpp
Text conflict in src/core/StelSkyDrawer.hpp
Text conflict in src/core/modules/Planet.cpp
To merge this branch: bzr merge lp:~stellarium/stellarium/corona
Reviewer Review Type Date Requested Status
gzotti Needs Fixing
Guillaume Chereau Pending
Fabien Chéreau Pending
Review via email: mp+268163@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-03.

Description of the change

I tried restore a lost feature - showing the Sun's corona during total solar eclipse.

To post a comment you must log in.
lp:~stellarium/stellarium/corona updated
7823. By Alexander Wolf

obvious fix for scaling texture of the corona

7824. By Alexander Wolf

Fixed Sun's magnitude during solar eclipse

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Fabien, is it possible reuse the calculations from shaders (I mean final_illumination)?

Revision history for this message
gzotti (georg-zotti) wrote :

Very welcome! Some improvements noted below.
During totality sky is dark, to see text you should also fix StelCore::isBrightDaylight().

review: Needs Fixing
lp:~stellarium/stellarium/corona updated
7825. By Alexander Wolf

few improvements for Sun's corona drawing and calculate brightness of the Sun during solar eclipse

7826. By Alexander Wolf

sunc with trunk

7827. By gzotti

better balancing for Corona brightness
Added Planet infostring on eclipse percentage

7828. By gzotti

Added new Corona texture (2008 eclipse, own work)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/StelCore.cpp'
2--- src/core/StelCore.cpp 2015-08-28 17:09:08 +0000
3+++ src/core/StelCore.cpp 2015-09-03 13:04:16 +0000
4@@ -1914,8 +1914,14 @@
5 // return if sky plus atmosphere is bright enough from sunlight so that e.g. screen labels should be rendered dark.
6 bool StelCore::isBrightDaylight() const
7 {
8- const Vec3d& sunPos = GETSTELMODULE(SolarSystem)->getSun()->getAltAzPosGeometric(this);
9- return sunPos[2] > -0.12; // Nautical twilight (0.12 > sin (6 deg),
10+ bool r = false;
11+ SolarSystem* ssys = GETSTELMODULE(SolarSystem);
12+ const Vec3d& sunPos = ssys->getSun()->getAltAzPosGeometric(this);
13+ if (sunPos[2] > -0.12) // Nautical twilight (0.12 > sin (6 deg))
14+ r = true;
15+ if (ssys->getEclipseFactor(this)<=0.01) // Total solar eclipse
16+ r = false;
17+ return r;
18 }
19
20 double StelCore::getCurrentEpoch() const
21
22=== modified file 'src/core/StelSkyDrawer.cpp'
23--- src/core/StelSkyDrawer.cpp 2015-08-16 14:07:29 +0000
24+++ src/core/StelSkyDrawer.cpp 2015-09-03 13:04:16 +0000
25@@ -466,6 +466,25 @@
26 return true;
27 }
28
29+<<<<<<< TREE
30+=======
31+// Draw's the Sun's corona during a solar eclipse on Earth.
32+void StelSkyDrawer::drawSunCorona(StelPainter* painter, const Vec3f& v, float radius, const Vec3f& color, const float alpha)
33+{
34+ texSunCorona->bind();
35+ glEnable(GL_BLEND);
36+ glBlendFunc(GL_ONE, GL_ONE);
37+ painter->enableTexture2d(true);
38+
39+ Vec3f win;
40+ painter->getProjector()->project(v, win);
41+ painter->setColor(color[0], color[1], color[2], alpha);
42+ painter->drawSprite2dMode(win[0], win[1], radius);
43+
44+ postDrawPointSource(painter);
45+}
46+
47+>>>>>>> MERGE-SOURCE
48
49 // Terminate drawing of a 3D model, draw the halo
50 void StelSkyDrawer::postDrawSky3dModel(StelPainter* painter, const Vec3f& v, float illuminatedArea, float mag, const Vec3f& color)
51
52=== modified file 'src/core/StelSkyDrawer.hpp'
53--- src/core/StelSkyDrawer.hpp 2015-08-16 14:07:29 +0000
54+++ src/core/StelSkyDrawer.hpp 2015-09-03 13:04:16 +0000
55@@ -80,6 +80,11 @@
56
57 bool drawPointSource(StelPainter* sPainter, const Vec3f& v, const RCMag &rcMag, const Vec3f& bcolor, bool checkInScreen=false);
58
59+<<<<<<< TREE
60+=======
61+ void drawSunCorona(StelPainter* painter, const Vec3f& v, float radius, const Vec3f& color, const float alpha);
62+
63+>>>>>>> MERGE-SOURCE
64 //! Terminate drawing of a 3D model, draw the halo
65 //! @param p the StelPainter instance to use for this drawing operation
66 //! @param v the 3d position of the source in J2000 reference frame
67
68=== modified file 'src/core/modules/Planet.cpp'
69--- src/core/modules/Planet.cpp 2015-08-23 19:16:48 +0000
70+++ src/core/modules/Planet.cpp 2015-09-03 13:04:16 +0000
71@@ -870,9 +870,19 @@
72 {
73 if (parent == 0)
74 {
75- // sun, compute the apparent magnitude for the absolute mag (4.83) and observer's distance
76+ // Sun, compute the apparent magnitude for the absolute mag (V: 4.83) and observer's distance
77+ // Hint: Absolute Magnitude of the Sun in Several Bands: http://mips.as.arizona.edu/~cnaw/sun.html
78 const double distParsec = std::sqrt(core->getObserverHeliocentricEclipticPos().lengthSquared())*AU/PARSEC;
79- return 4.83 + 5.*(std::log10(distParsec)-1.);
80+
81+ // check how much of it is visible
82+ const SolarSystem* ssm = GETSTELMODULE(SolarSystem);
83+ double shadowFactor = ssm->getEclipseFactor(core);
84+ // See: Hughes, D. W., Brightness during a solar eclipse // Journal of the British Astronomical Association, vol.110, no.4, p.203-205
85+ // URL: http://adsabs.harvard.edu/abs/2000JBAA..110..203H
86+ if(shadowFactor < 0.0128)
87+ shadowFactor = 0.0128;
88+
89+ return 4.83 + 5.*(std::log10(distParsec)-1.) - 2.5*(std::log10(shadowFactor));
90 }
91
92 // Compute the angular phase
93@@ -1515,6 +1525,13 @@
94 StelPainter sPainter(core->getProjection(StelCore::FrameJ2000));
95 Vec3d tmp = getJ2000EquatorialPos(core);
96 core->getSkyDrawer()->postDrawSky3dModel(&sPainter, Vec3f(tmp[0], tmp[1], tmp[2]), surfArcMin2, getVMagnitudeWithExtinction(core), color);
97+<<<<<<< TREE
98+=======
99+
100+ float eclipseFactor = ssm->getEclipseFactor(core);
101+ if (core->getCurrentLocation().planetName == "Earth" && eclipseFactor<0.001f)
102+ core->getSkyDrawer()->drawSunCorona(&sPainter, Vec3f(tmp[0], tmp[1], tmp[2]), 2.f*screenSz, color, 1.0 - eclipseFactor * 1000);
103+>>>>>>> MERGE-SOURCE
104 }
105 }
106
107
108=== modified file 'src/core/modules/SolarSystem.cpp'
109--- src/core/modules/SolarSystem.cpp 2015-08-18 18:33:37 +0000
110+++ src/core/modules/SolarSystem.cpp 2015-09-03 13:04:16 +0000
111@@ -1738,3 +1738,77 @@
112 {
113 return getEarth()->getApparentMagnitudeAlgorithmString();
114 }
115+
116+double SolarSystem::getEclipseFactor(const StelCore* core) const
117+{
118+ Vec3d Lp = sun->getEclipticPos();
119+ Vec3d P3 = core->getObserverHeliocentricEclipticPos();
120+ const double RS = sun->getRadius();
121+
122+ double final_illumination = 1.0;
123+
124+ foreach (const PlanetP& planet, systemPlanets)
125+ {
126+ if(planet == sun || planet == core->getCurrentPlanet())
127+ continue;
128+
129+ Mat4d trans;
130+ planet->computeModelMatrix(trans);
131+
132+ const Vec3d C = trans * Vec3d(0, 0, 0);
133+ const double radius = planet->getRadius();
134+
135+ Vec3d v1 = Lp - P3;
136+ Vec3d v2 = C - P3;
137+
138+ const double L = v1.length();
139+ const double l = v2.length();
140+
141+ v1 = v1 / L;
142+ v2 = v2 / l;
143+
144+ const double R = RS / L;
145+ const double r = radius / l;
146+ const double d = ( v1 - v2 ).length();
147+
148+ if(planet->englishName == "Moon")
149+ v1 = planet->getHeliocentricEclipticPos();
150+
151+ double illumination;
152+
153+ // distance too far
154+ if(d >= R + r)
155+ {
156+ illumination = 1.0;
157+ }
158+ // umbra
159+ else if(r >= R + d)
160+ {
161+ illumination = 0.0;
162+ }
163+ // penumbra completely inside
164+ else if(d + r <= R)
165+ {
166+ illumination = 1.0 - r * r / (R * R);
167+ }
168+ // penumbra partially inside
169+ else
170+ {
171+ const double x = (R * R + d * d - r * r) / (2.0 * d);
172+
173+ const double alpha = std::acos(x / R);
174+ const double beta = std::acos((d - x) / r);
175+
176+ const double AR = R * R * (alpha - 0.5 * std::sin(2.0 * alpha));
177+ const double Ar = r * r * (beta - 0.5 * std::sin(2.0 * beta));
178+ const double AS = R * R * 2.0 * std::asin(1.0);
179+
180+ illumination = 1.0 - (AR + Ar) / AS;
181+ }
182+
183+ if(illumination < final_illumination)
184+ final_illumination = illumination;
185+ }
186+
187+ return final_illumination;
188+}
189
190=== modified file 'src/core/modules/SolarSystem.hpp'
191--- src/core/modules/SolarSystem.hpp 2015-08-03 13:17:06 +0000
192+++ src/core/modules/SolarSystem.hpp 2015-09-03 13:04:16 +0000
193@@ -331,6 +331,9 @@
194 //! Reload the planets
195 void reloadPlanets();
196
197+ //! Determines relative amount of sun visible from the observer's position.
198+ double getEclipseFactor(const StelCore *core) const;
199+
200 ///////////////////////////////////////////////////////////////////////////////////////
201 // DEPRECATED
202 ///////////////////////////////////////////////////////////////////////////////////////