diff options
author | Georg Zotti <Georg.Zotti@univie.ac.at> | 2022-01-31 09:39:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-31 09:39:44 +0100 |
commit | c787c1e3e1bd33d3a3d312f398dc67931cd64112 (patch) | |
tree | 882ecfb0ea6d3b09f877476434983430d560e490 | |
parent | 42948620a6c462850d873eb939c40ea101985a04 (diff) |
Martian Poles (#2220)
* Let shader colorize the poles based on texture t coordinate.
* Apply soft edges for polar caps, with a slight undulation.
* Avoid polar caps on planet when rendered with survey (texture coordinates different in HiPS!)
* SUG: Add references
-rw-r--r-- | data/shaders/planet.frag | 17 | ||||
-rw-r--r-- | guide/app_acknowledgements.tex | 1 | ||||
-rw-r--r-- | guide/guide.bib | 24 | ||||
-rw-r--r-- | src/core/modules/Planet.cpp | 27 | ||||
-rw-r--r-- | src/core/modules/Planet.hpp | 3 |
5 files changed, 71 insertions, 1 deletions
diff --git a/data/shaders/planet.frag b/data/shaders/planet.frag index 6c39cba4f7..ed6f2c70d8 100644 --- a/data/shaders/planet.frag +++ b/data/shaders/planet.frag @@ -25,6 +25,7 @@ varying mediump vec2 texc; //texture coord varying highp vec3 P; //original vertex pos in model space
uniform sampler2D tex;
+uniform mediump vec2 poleLat; //latitudes of pole caps, in terms of texture coordinate. x>0...north, y<1...south.
uniform mediump vec3 ambientLight;
uniform mediump vec3 diffuseLight;
uniform highp vec4 sunInfo;
@@ -298,7 +299,23 @@ void main() //litColor.xyz = clamp( litColor.xyz + vec3(outgas), 0.0, 1.0);
lowp vec4 texColor = texture2D(tex, texc);
+
mediump vec4 finalColor = texColor;
+ // apply (currently only Martian) pole caps. texc.t=0 at south pole, 1 at north pole.
+ if (texc.t>poleLat.x-0.01+0.001*sin(texc.s*18.*M_PI)) { // North pole near t=1
+ mediump float mixfactor=1.;
+ if (texc.t<poleLat.x+0.01+0.001*sin(texc.s*18.*M_PI))
+ mixfactor=(texc.t-poleLat.x+0.01-0.001*sin(texc.s*18.*M_PI))/0.02;
+ //finalColor.xyz=mix(vec3(1., 1., 1.), finalColor.xyz, 1.-mixfactor);
+ finalColor.xyz=mix(vec3(1., 1., 1.), finalColor.xyz, smoothstep(0., 1., 1.-mixfactor));
+ }
+ if (texc.t<poleLat.y+0.01+0.001*sin(texc.s*18.*M_PI)) { // South pole near texc.t~0
+ mediump float mixfactor=1.;
+ if (texc.t>poleLat.y-0.01+0.001*sin(texc.s*18.*M_PI))
+ mixfactor=(poleLat.y+0.01-texc.t-0.001*sin(texc.s*18.*M_PI))/0.02;
+ //finalColor.xyz=mix(vec3(1., 1., 1.), finalColor.xyz, 1.-mixfactor);
+ finalColor.xyz=mix(vec3(1., 1., 1.), finalColor.xyz, smoothstep(0., 1., 1.-mixfactor));
+ }
#ifdef IS_MOON
if(final_illumination < 0.9999)
{
diff --git a/guide/app_acknowledgements.tex b/guide/app_acknowledgements.tex index 27da884b22..23960882d6 100644 --- a/guide/app_acknowledgements.tex +++ b/guide/app_acknowledgements.tex @@ -96,6 +96,7 @@ Stellarium would not look the same and work without these works from computer gr \item[Nutation:] \citetp{Nutation:IAU2000B} %Dennis D. McCarthy and Brian J. Luzum: An Abridged Model of the Precession-Nutation of the Celestial Pole. This model provides accuracy better than 1 milli-arcsecond in the time 1995-2050. It is applied for years -4000..+8000 only. + \item[Martian polar caps:] Based on data from \citet{MarsPoles:2009} and \citet{MarsRotation:2015}.\newFeature{0.22.0} \end{description} \section{Included Source Code} diff --git a/guide/guide.bib b/guide/guide.bib index b4e7d265ee..fe5a0c0b29 100644 --- a/guide/guide.bib +++ b/guide/guide.bib @@ -646,12 +646,34 @@ OPTnextEntry = {CD-ROM ISBN if this makes a difference}, doi = {10.1007/s10569-019-9925-1} } +@Article{MarsRotation:2015, + author = {Sylvain Piqueux and Shane Byrne and Hugh H. Kieffer and Timothy N. Titus and Candice J. Hansen}, + title = {{Enumeration of Mars years and seasons since the beginning of telescopic exploration}}, + journal = {Icarus}, + year = {2015}, + OPTkey = {}, + number = {251}, + pages = {332-338}, + doi = {10.1016/j.icarus.2014.12.014} +} + +@Article{MarsPoles:2009, + author = {David E. Smith and Maria T. Zuber and Mark H. Torrence and Peter J. Dunn and Gregory A. Neumann and Frank G. Lemoine and Susan K. Fricke}, + title = {{Time variations of Mars’ gravitational field and seasonal changes in the masses of the polar ice caps}}, + journal = {Journal of Geophysical Research}, + year = {2009}, + OPTkey = {}, + volume = {114}, + number = {E05002}, + doi = {10.1029/2008je003267} +} + @Article{Mallama:2007, author = {Anthony Mallama}, title = {{The magnitude and albedo of Mars}}, journal = {Icarus}, year = {2007}, - Ovolume = {192}, + number = {192}, pages = {404-416}, OPTannote = {} } diff --git a/src/core/modules/Planet.cpp b/src/core/modules/Planet.cpp index 23b71848e4..698aee1f76 100644 --- a/src/core/modules/Planet.cpp +++ b/src/core/modules/Planet.cpp @@ -2768,6 +2768,7 @@ void Planet::PlanetShaderVars::initLocations(QOpenGLShaderProgram* p) //common uniforms GL(projectionMatrix = p->uniformLocation("projectionMatrix")); GL(tex = p->uniformLocation("tex")); + GL(poleLat = p->uniformLocation("poleLat")); GL(lightDirection = p->uniformLocation("lightDirection")); GL(eyeDirection = p->uniformLocation("eyeDirection")); GL(diffuseLight = p->uniformLocation("diffuseLight")); @@ -3791,6 +3792,30 @@ void Planet::drawSphere(StelPainter* painter, float screenRd, bool drawOnlyRing) } } + if (englishName=="Mars") + { + // Compute Ls for Mars. From Piqueux et al., Icarus 251 (2015) 332-8 (9). Short algorithm with good approximation. + const double t=lastJDE-J2000; + const double M = (19.38095 + 0.524020769 * t)*M_PI_180; + const double sinM=sin(M); + const double sin2M=sin(2.*M); + const double sin3M=sin(3.*M); + const double Ls = 270.38859 + 0.524038542*t + 10.67848*sinM + 0.62077*sin2M + 0.05031*sin3M; + // Then compute latitudes of polar caps: Fig.10 in Smith, David E. et al. "Time Variations of + // Mars’ Gravitational Field and Seasonal Changes in the Masses of the Polar Ice Caps." + // Journal of Geophysical Research 114.E5 (2009): E05002. DOI:10.1029/2008je003267 + //double latN= 70.-18.*sin((Ls-195.)*M_PI_180); + //double latS=-70.+18.*sin((Ls- 15.)*M_PI_180); + double latN= 70.+18.*cos((Ls-125.)*M_PI_180); // goes down to 52° + double latS=-68.+19.*cos((Ls-105.)*M_PI_180); // goes up to -49° + + // Finally convert to texture coordinates. + float tNorth=static_cast<float>((latN+90.)/180.); + float tSouth=static_cast<float>((latS+90.)/180.); + GL(shader->setUniformValue(shaderVars->poleLat, tNorth, tSouth)); + } + else + GL(shader->setUniformValue(shaderVars->poleLat, 1.1f, -0.1f)); // add some security margin. GL(shader->setAttributeArray(shaderVars->vertex, static_cast<const GLfloat*>(projectedVertexArr.constData()), 3)); GL(shader->enableAttributeArray(shaderVars->vertex)); GL(shader->setAttributeArray(shaderVars->unprojectedVertex, static_cast<const GLfloat*>(model.vertexArr.constData()), 3)); @@ -3917,6 +3942,8 @@ void Planet::drawSurvey(StelCore* core, StelPainter* painter) } } + GL(shader->setUniformValue(shaderVars->poleLat, 1.1f, -0.1f)); // Avoid streaks across Mars + // Apply a rotation otherwize the hips surveys don't get rendered at the // proper position. Not sure why... painter->getProjector()->getModelViewTransform()->combine(Mat4d::zrotation(M_PI * 0.5)); diff --git a/src/core/modules/Planet.hpp b/src/core/modules/Planet.hpp index 863c671335..dc155bf01e 100644 --- a/src/core/modules/Planet.hpp +++ b/src/core/modules/Planet.hpp @@ -786,6 +786,9 @@ private: int orenNayarParameters; int outgasParameters; + // For Mars poles + int poleLat; // latitudes of edges of northern (x) and southern (y) polar cap [texture y, moving from 0 (S) to 1 (N)]. Only used for Mars, use [1, 0] for other objects. + // Moon-specific variables int earthShadow; int eclipsePush; // apparent brightness push for partial Lunar Eclipse (make bright rim overbright) |