Planet.cpp   Planet.cpp 
skipping to change at line 155 skipping to change at line 155
pTypeMap.insert(Planet::isUNDEFINED, "UNDEFINED"); // something m ust be broken before we ever see this! pTypeMap.insert(Planet::isUNDEFINED, "UNDEFINED"); // something m ust be broken before we ever see this!
if (vMagAlgorithmMap.count() > 0) if (vMagAlgorithmMap.count() > 0)
{ {
qDebug() << "Planet::init(): Non-empty static map. This is a programming error, but we can fix that."; qDebug() << "Planet::init(): Non-empty static map. This is a programming error, but we can fix that.";
vMagAlgorithmMap.clear(); vMagAlgorithmMap.clear();
} }
vMagAlgorithmMap.insert(Planet::Planesas, "planesas"); vMagAlgorithmMap.insert(Planet::Planesas, "planesas");
vMagAlgorithmMap.insert(Planet::Mueller, "mueller"); vMagAlgorithmMap.insert(Planet::Mueller, "mueller");
vMagAlgorithmMap.insert(Planet::Harris, "harris"); vMagAlgorithmMap.insert(Planet::Harris, "harris");
vMagAlgorithmMap.insert(Planet::Generic, "generic"),
vMagAlgorithmMap.insert(Planet::UndefinedAlgorithm, ""); vMagAlgorithmMap.insert(Planet::UndefinedAlgorithm, "");
} }
Planet::~Planet() Planet::~Planet()
{ {
if (rings) if (rings)
delete rings; delete rings;
} }
void Planet::translateName(const StelTranslator& trans) void Planet::translateName(const StelTranslator& trans)
skipping to change at line 626 skipping to change at line 627
double t = jd - re.epoch; double t = jd - re.epoch;
// oops... avoid division by zero (typical case for moons with chaot ic period of rotation) // oops... avoid division by zero (typical case for moons with chaot ic period of rotation)
double rotations = 1.f; // NOTE: Maybe 1e-3 will be better? double rotations = 1.f; // NOTE: Maybe 1e-3 will be better?
if (re.period!=0.) // OK, it's not a moon with chaotic period of rot ation :) if (re.period!=0.) // OK, it's not a moon with chaotic period of rot ation :)
{ {
rotations = t / (double) re.period; rotations = t / (double) re.period;
} }
double wholeRotations = floor(rotations); double wholeRotations = floor(rotations);
double remainder = rotations - wholeRotations; double remainder = rotations - wholeRotations;
// TODO: This block need rewrite
if (englishName=="Jupiter") if (englishName=="Jupiter")
{ {
// use semi-empirical coefficient for GRS drift if( re.offset >= 0.0 )
return remainder * 360. + re.offset - 0.2483 * qAbs(jd - 245 {
6172); // use semi-empirical coefficient for GRS drift
// qDebug() << "Jupiter: offset = " << re.offset <<
" --> rotation = " << (remainder * 360. + re.offset - 0.2483 * qAbs(jd - 24
56172));
return remainder * 360. + re.offset - 0.2483 * qAbs(
jd - 2456172);
}
else
{
// http://www.projectpluto.com/grs_form.htm
// CM( System II) = 181.62 + 870.1869147 * jd + cor
rection [870d rotation every day]
const double rad = M_PI/180.;
double jup_mean = (jd - 2455636.938) * 360. / 4332.8
9709;
double eqn_center = 5.55 * sin( rad*jup_mean);
double angle = (jd - 2451870.628) * 360. / 398.884 -
eqn_center;
//double correction = 11 * sin( rad*angle) + 5 * cos
( rad*angle)- 1.25 * cos( rad*jup_mean) - eqn_center; // original correctio
n
double correction = 25.8 + 11 * sin( rad*angle) - 2.
5 * cos( rad*jup_mean) - eqn_center; // light speed correction not used bec
ause in stellarium the jd is manipulated for that
double cm2=181.62 + 870.1869147 * jd + correction;
cm2=cm2 - 360.0*(int)(cm2/360.);
// http://www.skyandtelescope.com/observing/transit-
times-of-jupiters-great-red-spot/ writes:
// The predictions assume the Red Spot was at Jovian
System II longitude 216° in September 2014 and continues to drift 1.25° pe
r month, based on historical trends noted by JUPOS.
// GRS longitude was at 2014-09-08 216d with a drift
of 1.25d every month
double longitudeGRS=216+1.25*( jd - 2456908)/30;
// qDebug() << "Jupiter: CM2 = " << cm2 << " longitu
deGRS = " << longitudeGRS << " --> rotation = " << (cm2 - longitudeGRS);
return cm2 - longitudeGRS + 25.; // + 25 = Jupiter T
exture not 0d
// To verify:
// GRS at 2015-02-26 23:07 UT on picture at https://
maximusphotography.files.wordpress.com/2015/03/jupiter-febr-26-2015.jpg
// 2014-02-25 19:03 UT http://www.damianpe
ach.com/jup1314/2014_02_25rgb0305.jpg
// 2013-05-01 10:29 UT http://astro.christ
one.net/jupiter/jupiter2012/jupiter20130501.jpg
// 2012-10-26 00:12 UT at http://www.lunar-ca
ptures.com//jupiter2012_files/121026_JupiterGRS_Tar.jpg
// 2011-08-28 02:29 UT at http://www.damianpe
ach.com/jup1112/2011_08_28rgb.jpg
// stellarium 2h too early: 2010-09-21 23:37 UT http
://www.digitalsky.org.uk/Jupiter/2010-09-21_23-37-30_R-G-B_800.jpg
}
} }
else else
return remainder * 360. + re.offset; return remainder * 360. + re.offset;
} }
double Planet::getMeanSolarDay() const double Planet::getMeanSolarDay() const
{ {
double msd = 0.; double msd = 0.;
if (englishName=="Sun") if (englishName=="Sun")
skipping to change at line 734 skipping to change at line 764
return distance; return distance;
} }
// Get the phase angle (radians) for an observer at pos obsPos in heliocent ric coordinates (dist in AU) // Get the phase angle (radians) for an observer at pos obsPos in heliocent ric coordinates (dist in AU)
double Planet::getPhaseAngle(const Vec3d& obsPos) const double Planet::getPhaseAngle(const Vec3d& obsPos) const
{ {
const double observerRq = obsPos.lengthSquared(); const double observerRq = obsPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red(); const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red();
return std::acos((observerPlanetRq + planetRq - observerRq)/(2.0*sqr t(observerPlanetRq*planetRq))); return std::acos((observerPlanetRq + planetRq - observerRq)/(2.0*std ::sqrt(observerPlanetRq*planetRq)));
} }
// Get the planet phase for an observer at pos obsPos in heliocentric coord inates (in AU) // Get the planet phase for an observer at pos obsPos in heliocentric coord inates (in AU)
float Planet::getPhase(const Vec3d& obsPos) const float Planet::getPhase(const Vec3d& obsPos) const
{ {
const double observerRq = obsPos.lengthSquared(); const double observerRq = obsPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red(); const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red();
const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*sqrt(observerPlanetRq*planetRq)); const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*std::sqrt(observerPlanetRq*planetRq));
return 0.5f * qAbs(1.f + cos_chi); return 0.5f * qAbs(1.f + cos_chi);
} }
// Get the elongation angle (radians) for an observer at pos obsPos in heli ocentric coordinates (dist in AU) // Get the elongation angle (radians) for an observer at pos obsPos in heli ocentric coordinates (dist in AU)
double Planet::getElongation(const Vec3d& obsPos) const double Planet::getElongation(const Vec3d& obsPos) const
{ {
const double observerRq = obsPos.lengthSquared(); const double observerRq = obsPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red(); const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red();
skipping to change at line 793 skipping to change at line 823
const double pos_times_parent_pos = planetHelioPos * parentH eliopos; const double pos_times_parent_pos = planetHelioPos * parentH eliopos;
if (pos_times_parent_pos > parent_Rq) if (pos_times_parent_pos > parent_Rq)
{ {
// The satellite is farther away from the sun than t he parent planet. // The satellite is farther away from the sun than t he parent planet.
const double sun_radius = parent->parent->radius; const double sun_radius = parent->parent->radius;
const double sun_minus_parent_radius = sun_radius - parent->radius; const double sun_minus_parent_radius = sun_radius - parent->radius;
const double quot = pos_times_parent_pos/parent_Rq; const double quot = pos_times_parent_pos/parent_Rq;
// Compute d = distance from satellite center to bor der of inner shadow. // Compute d = distance from satellite center to bor der of inner shadow.
// d>0 means inside the shadow cone. // d>0 means inside the shadow cone.
double d = sun_radius - sun_minus_parent_radius*quot - std::sqrt((1.-sun_minus_parent_radius/sqrt(parent_Rq)) * (planetRq-pos_t imes_parent_pos*quot)); double d = sun_radius - sun_minus_parent_radius*quot - std::sqrt((1.-sun_minus_parent_radius/std::sqrt(parent_Rq)) * (planetRq- pos_times_parent_pos*quot));
if (d>=radius) if (d>=radius)
{ {
// The satellite is totally inside the inner shadow. // The satellite is totally inside the inner shadow.
if (englishName=="Moon") if (englishName=="Moon")
{ {
// Fit a more realistic magnitude fo r the Moon case. // Fit a more realistic magnitude fo r the Moon case.
// I used some empirical data for fi tting. --AW // I used some empirical data for fi tting. --AW
// TODO: This factor should be impro ved! // TODO: This factor should be impro ved!
shadowFactor = 2.718e-5; shadowFactor = 2.718e-5;
} }
skipping to change at line 821 skipping to change at line 851
d /= radius; d /= radius;
shadowFactor = (0.5 - (std::asin(d)+d*std::s qrt(1.0-d*d))/M_PI); shadowFactor = (0.5 - (std::asin(d)+d*std::s qrt(1.0-d*d))/M_PI);
} }
} }
} }
// Use empirical formulae for main planets when seen from earth // Use empirical formulae for main planets when seen from earth
if (core->getCurrentLocation().planetName=="Earth") if (core->getCurrentLocation().planetName=="Earth")
{ {
const double phaseDeg=phase*180./M_PI; const double phaseDeg=phase*180./M_PI;
const double d = 5. * log10(sqrt(observerPlanetRq*planetRq)) ; const double d = 5. * log10(std::sqrt(observerPlanetRq*plane tRq));
// GZ: I prefer the values given by Meeus, Astronomical Algo rithms (1992). // GZ: I prefer the values given by Meeus, Astronomical Algo rithms (1992).
// There are two solutions: // There are two solutions:
// (1) G. Mueller, based on visual observations 1877-91. [Ex pl.Suppl.1961] // (1) G. Mueller, based on visual observations 1877-91. [Ex pl.Suppl.1961]
// (2) Astronomical Almanac 1984 and later. These give V (in strumental) magnitudes. // (2) Astronomical Almanac 1984 and later. These give V (in strumental) magnitudes.
// The structure is almost identical, just the numbers are d ifferent! // The structure is almost identical, just the numbers are d ifferent!
// I activate (1) for now, because we want to simulate the e ye's impression. (Esp. Venus!) // I activate (1) for now, because we want to simulate the e ye's impression. (Esp. Venus!)
// AW: (2) activated by default // AW: (2) activated by default
switch (core->getCurrentPlanet()->getApparentMagnitudeAlgori thm()) switch (core->getCurrentPlanet()->getApparentMagnitudeAlgori thm())
skipping to change at line 860 skipping to change at line 890
{ {
// add rings computation // add rings computation
// implemented from Meeus, Astr.Alg. 1992 // implemented from Meeus, Astr.Alg. 1992
const double jd=core->getJDay(); const double jd=core->getJDay();
const double T=(jd-2451545.0)/36525. 0; const double T=(jd-2451545.0)/36525. 0;
const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0; const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0;
const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0; const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0;
static SolarSystem *ssystem=GETSTELM ODULE(SolarSystem); static SolarSystem *ssystem=GETSTELM ODULE(SolarSystem);
const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1], saturnEarth[0]); double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], sq rt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinx=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta); const double sinx=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta);
double rings = -2.6*sinx + 1.25*sinx *sinx; double rings = -2.6*sinx + 1.25*sinx *sinx;
return -8.88 + d + 0.044*phaseDeg + rings; return -8.88 + d + 0.044*phaseDeg + rings;
} }
if (englishName=="Uranus") if (englishName=="Uranus")
return -7.19 + d + 0.0028*phaseDeg; return -7.19 + d + 0.0028*phaseDeg;
if (englishName=="Neptune") if (englishName=="Neptune")
return -6.87 + d; return -6.87 + d;
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.01 + d + 0.041*phaseDeg; return -1.01 + d + 0.041*phaseDeg;
skipping to change at line 899 skipping to change at line 929
{ {
// add rings computation // add rings computation
// implemented from Meeus, Astr.Alg. 1992 // implemented from Meeus, Astr.Alg. 1992
const double jd=core->getJDay(); const double jd=core->getJDay();
const double T=(jd-2451545.0)/36525. 0; const double T=(jd-2451545.0)/36525. 0;
const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0; const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0;
const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0; const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0;
SolarSystem *ssystem=GETSTELMODULE(S olarSystem); SolarSystem *ssystem=GETSTELMODULE(S olarSystem);
const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1], saturnEarth[0]); double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], sq rt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinB=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta); const double sinB=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta);
double rings = -2.6*fabs(sinB) + 1.2 5*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see M eeus. double rings = -2.6*fabs(sinB) + 1.2 5*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see M eeus.
return -8.68 + d + 0.044*phaseDeg + rings; return -8.68 + d + 0.044*phaseDeg + rings;
} }
if (englishName=="Uranus") if (englishName=="Uranus")
return -6.85 + d; return -6.85 + d;
if (englishName=="Neptune") if (englishName=="Neptune")
return -7.05 + d; return -7.05 + d;
// Original formulae doesn't have equeation for Pluto
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.0 + d; return -1.0 + d;
break; break;
} }
case Harris: case Harris:
case UndefinedAlgorithm: // activated by defa ult case UndefinedAlgorithm: // activated by defa ult
{ {
// (2) // (2)
if (englishName=="Mercury") if (englishName=="Mercury")
skipping to change at line 936 skipping to change at line 967
{ {
// add rings computation // add rings computation
// implemented from Meeus, Astr.Alg. 1992 // implemented from Meeus, Astr.Alg. 1992
const double jd=core->getJDay(); const double jd=core->getJDay();
const double T=(jd-2451545.0)/36525. 0; const double T=(jd-2451545.0)/36525. 0;
const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0; const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0;
const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0; const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0;
static SolarSystem *ssystem=GETSTELM ODULE(SolarSystem); static SolarSystem *ssystem=GETSTELM ODULE(SolarSystem);
const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1], saturnEarth[0]); double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], sq rt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinB=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta); const double sinB=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta);
double rings = -2.6*fabs(sinB) + 1.2 5*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see M eeus. double rings = -2.6*fabs(sinB) + 1.2 5*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see M eeus.
return -8.88 + d + 0.044*phaseDeg + rings; return -8.88 + d + 0.044*phaseDeg + rings;
} }
if (englishName=="Uranus") if (englishName=="Uranus")
return -7.19f + d; return -7.19f + d;
if (englishName=="Neptune") if (englishName=="Neptune")
return -6.87f + d; return -6.87f + d;
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.00f + d; return -1.00f + d;
break; break;
} }
case Generic:
{
// Calculation visual magnitude from phase a
ngle and albedo of the planet
break;
}
} }
} }
// This formula seems to give wrong results // This formula seems to give wrong results
const double p = (1.0 - phase/M_PI) * cos_chi + std::sqrt(1.0 - cos_ chi*cos_chi) / M_PI; const double p = (1.0 - phase/M_PI) * cos_chi + std::sqrt(1.0 - cos_ chi*cos_chi) / M_PI;
double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetR q*planetRq) * shadowFactor; double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetR q*planetRq) * shadowFactor;
return -26.73 - 2.5 * std::log10(F); return -26.73 - 2.5 * std::log10(F);
} }
double Planet::getAngularSize(const StelCore* core) const double Planet::getAngularSize(const StelCore* core) const
skipping to change at line 984 skipping to change at line 1020
{ {
if (hidden) if (hidden)
return; return;
// Try to improve speed for minor planets: test if visible at all. // Try to improve speed for minor planets: test if visible at all.
// For a full catalog of NEAs (11000 objects), with this and resetti ng deltaJD according to distance, rendering time went 4.5fps->12fps. // For a full catalog of NEAs (11000 objects), with this and resetti ng deltaJD according to distance, rendering time went 4.5fps->12fps.
// TBD: Note that taking away the asteroids at this stage breaks dim -asteroid occultation of stars! // TBD: Note that taking away the asteroids at this stage breaks dim -asteroid occultation of stars!
// Maybe make another configurable flag for those interested? // Maybe make another configurable flag for those interested?
// Problematic: Early-out here of course disables the wanted hint ci rcles for dim asteroids. // Problematic: Early-out here of course disables the wanted hint ci rcles for dim asteroids.
// The line makes hints for asteroids 5 magnitudes below sky limitin g magnitude visible. // The line makes hints for asteroids 5 magnitudes below sky limitin g magnitude visible.
// If asteroid is too faint to be seen, don't bother rendering. (Mas sive speedup if people have hundreds of orbital elements!) // If asteroid is too faint to be seen, don't bother rendering. (Mas sive speedup if people have hundreds of orbital elements!)
if (((getVMagnitude(core)-5.0f) > core->getSkyDrawer()->getLimitMagn itude()) && pType==Planet::isAsteroid) if (((getVMagnitude(core)-5.0f) > core->getSkyDrawer()->getLimitMagn itude()) && pType>=Planet::isAsteroid)
{ {
return; return;
} }
Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent; Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent;
PlanetP p = parent; PlanetP p = parent;
while (p && p->parent) while (p && p->parent)
{ {
mat = Mat4d::translation(p->eclipticPos) * mat * p->rotLocal ToParent; mat = Mat4d::translation(p->eclipticPos) * mat * p->rotLocal ToParent;
p = p->parent; p = p->parent;
skipping to change at line 1178 skipping to change at line 1214
" }\n" " }\n"
"#endif\n" "#endif\n"
"\n" "\n"
" highp float sunRadius = sunInfo.w;\n" " highp float sunRadius = sunInfo.w;\n"
" highp float L = length(sunPosition - P);\n" " highp float L = length(sunPosition - P);\n"
" highp float R = asin(sunRadius / L);\n" " highp float R = asin(sunRadius / L);\n"
" for (int i = 0; i < 4; ++i)\n" " for (int i = 0; i < 4; ++i)\n"
" {\n" " {\n"
" if (shadowCount>i)\n" " if (shadowCount>i)\n"
" {\n" " {\n"
" highp vec3 satellitePosition = shadowData[0 " highp vec3 satellitePosition = shadowData[i
].xyz;\n" ].xyz;\n"
" highp float satelliteRadius = shadowData[0] " highp float satelliteRadius = shadowData[i]
.w;\n" .w;\n"
" highp float l = length(satellitePosition - P);\n" " highp float l = length(satellitePosition - P);\n"
" highp float r = asin(satelliteRadius / l);\ n" " highp float r = asin(satelliteRadius / l);\ n"
" highp float d = acos(min(1.0, dot(normalize (sunPosition - P), normalize(satellitePosition - P))));\n" " highp float d = acos(min(1.0, dot(normalize (sunPosition - P), normalize(satellitePosition - P))));\n"
"\n" "\n"
" mediump float illumination = 1.0;\n" " mediump float illumination = 1.0;\n"
" if(d >= R + r)\n" " if(d >= R + r)\n"
" {\n" " {\n"
" // distance too far\n" " // distance too far\n"
" illumination = 1.0;\n" " illumination = 1.0;\n"
" }\n" " }\n"
skipping to change at line 1225 skipping to change at line 1261
" mediump float AS = R * R * 2.0 * 1.5707 9633;\n" " mediump float AS = R * R * 2.0 * 1.5707 9633;\n"
" illumination = 1.0 - (AR + Ar) / AS;\n" " illumination = 1.0 - (AR + Ar) / AS;\n"
"#endif\n" "#endif\n"
" }\n" " }\n"
" final_illumination = min(illumination, fina l_illumination);\n" " final_illumination = min(illumination, fina l_illumination);\n"
" }\n" " }\n"
" }\n" " }\n"
" }\n" " }\n"
"\n" "\n"
"#ifdef IS_MOON\n" "#ifdef IS_MOON\n"
" highp vec3 normal = texture2D(normalMap, texc).rgb-vec3 (0.5, 0.5, 0);\n" " mediump vec3 normal = texture2D(normalMap, texc).rgb-ve c3(0.5, 0.5, 0);\n"
" normal = normalize(normalX*normal.x+normalY*normal.y+no rmalZ*normal.z);\n" " normal = normalize(normalX*normal.x+normalY*normal.y+no rmalZ*normal.z);\n"
" // normal now contains the real surface normal taking n ormal map into account\n" " // normal now contains the real surface normal taking n ormal map into account\n"
" // Use an Oren-Nayar model for rough surfaces\n" " // Use an Oren-Nayar model for rough surfaces\n"
" // Ref: http://content.gpwiki.org/index.php/D3DBook:(Li ghting)_Oren-Nayar\n" " // Ref: http://content.gpwiki.org/index.php/D3DBook:(Li ghting)_Oren-Nayar\n"
" highp float cosAngleLightNormal = dot(normal, lightDire // GZ next 2 don't require highp IMHO
ction);\n" " mediump float cosAngleLightNormal = dot(normal, lightDi
" highp float cosAngleEyeNormal = dot(normal, eyeDirectio rection);\n"
n);\n" " mediump float cosAngleEyeNormal = dot(normal, eyeDirect
ion);\n"
" mediump float angleLightNormal = acos(cosAngleLightNorm al);\n" " mediump float angleLightNormal = acos(cosAngleLightNorm al);\n"
" mediump float angleEyeNormal = acos(cosAngleEyeNormal); \n" " mediump float angleEyeNormal = acos(cosAngleEyeNormal); \n"
" mediump float alpha = max(angleEyeNormal, angleLightNor mal);\n" " mediump float alpha = max(angleEyeNormal, angleLightNor mal);\n"
" mediump float beta = min(angleEyeNormal, angleLightNorm al);\n" " mediump float beta = min(angleEyeNormal, angleLightNorm al);\n"
" mediump float gamma = dot(eyeDirection - normal * cosAn gleEyeNormal, lightDirection - normal * cosAngleLightNormal);\n" " mediump float gamma = dot(eyeDirection - normal * cosAn gleEyeNormal, lightDirection - normal * cosAngleLightNormal);\n"
" mediump float roughness = 1.0;\n" // GZ next 5 can be lowp instead of mediump. Roughness origi
" mediump float roughnessSquared = roughness * roughness; nal 1.0
\n" " lowp float roughness = 0.8;\n"
" mediump float A = 1.0 - 0.5 * (roughnessSquared / (roug " lowp float roughnessSquared = roughness * roughness;\n"
hnessSquared + 0.57));\n" " lowp float A = 1.0 - 0.5 * (roughnessSquared / (roughne
" mediump float B = 0.45 * (roughnessSquared / (roughness ssSquared + 0.57));\n"
Squared + 0.09));\n" " lowp float B = 0.45 * (roughnessSquared / (roughnessSqu
" mediump float C = sin(alpha) * tan(beta);\n" ared + 0.09));\n"
" lowp float C = sin(alpha) * tan(beta);\n"
// GZ final number was 2, but this causes overly bright moon
.
" lum = max(0.0, cosAngleLightNormal) * (A + B * max(0.0, gamma) * C) * 1.5;\n" " lum = max(0.0, cosAngleLightNormal) * (A + B * max(0.0, gamma) * C) * 1.5;\n"
"#endif\n" "#endif\n"
" mediump vec4 litColor = vec4(lum * final_illumination * diffuseLight + ambientLight, 2.0);\n" " mediump vec4 litColor = vec4(lum * final_illumination * diffuseLight + ambientLight, 1.0);\n"
"#ifdef IS_MOON\n" "#ifdef IS_MOON\n"
" if(final_illumination < 0.99)\n" " if(final_illumination < 0.99)\n"
" {\n" " {\n"
" lowp vec4 shadowColor = texture2D(earthShadow, vec2 (final_illumination, 0.5));\n" " lowp vec4 shadowColor = texture2D(earthShadow, vec2 (final_illumination, 0.5));\n"
" gl_FragColor = mix(texture2D(tex, texc) * litColor, shadowColor, shadowColor.a);\n" " gl_FragColor = mix(texture2D(tex, texc) * litColor, shadowColor, shadowColor.a);\n"
" }\n" " }\n"
" else\n" " else\n"
"#endif\n" "#endif\n"
" {\n" " {\n"
" gl_FragColor = texture2D(tex, texc) * litColor;\n" " gl_FragColor = texture2D(tex, texc) * litColor;\n"
skipping to change at line 1606 skipping to change at line 1645
shadowCandidatesData(3, i) = shadowCandidates.at(i)->getRadi us(); shadowCandidatesData(3, i) = shadowCandidates.at(i)->getRadi us();
} }
const StelProjectorP& projector = painter->getProjector(); const StelProjectorP& projector = painter->getProjector();
Vec3f lightPos3(light.position[0], light.position[1], light.position [2]); Vec3f lightPos3(light.position[0], light.position[1], light.position [2]);
projector->getModelViewTransform()->backward(lightPos3); projector->getModelViewTransform()->backward(lightPos3);
lightPos3.normalize(); lightPos3.normalize();
Vec3d eyePos = StelApp::getInstance().getCore()->getObserverHeliocen tricEclipticPos(); Vec3d eyePos = StelApp::getInstance().getCore()->getObserverHeliocen tricEclipticPos();
StelApp::getInstance().getCore()->getHeliocentricEclipticModelViewTr //qDebug() << eyePos[0] << " " << eyePos[1] << " " << eyePos[2] << "
ansform()->forward(eyePos); --> ";
// Use refractionOff for avoiding flickering Moon. (Bug #1411958)
StelApp::getInstance().getCore()->getHeliocentricEclipticModelViewTr
ansform(StelCore::RefractionOff)->forward(eyePos);
//qDebug() << "-->" << eyePos[0] << " " << eyePos[1] << " " << eyePo
s[2];
projector->getModelViewTransform()->backward(eyePos); projector->getModelViewTransform()->backward(eyePos);
eyePos.normalize(); eyePos.normalize();
//qDebug() << " -->" << eyePos[0] << " " << eyePos[1] << " " << eyeP os[2];
GL(shader->setUniformValue(shaderVars->projectionMatrix, qMat)); GL(shader->setUniformValue(shaderVars->projectionMatrix, qMat));
GL(shader->setUniformValue(shaderVars->lightDirection, lightPos3[0], lightPos3[1], lightPos3[2])); GL(shader->setUniformValue(shaderVars->lightDirection, lightPos3[0], lightPos3[1], lightPos3[2]));
GL(shader->setUniformValue(shaderVars->eyeDirection, eyePos[0], eyeP os[1], eyePos[2])); GL(shader->setUniformValue(shaderVars->eyeDirection, eyePos[0], eyeP os[1], eyePos[2]));
GL(shader->setUniformValue(shaderVars->diffuseLight, light.diffuse[0 ], light.diffuse[1], light.diffuse[2])); GL(shader->setUniformValue(shaderVars->diffuseLight, light.diffuse[0 ], light.diffuse[1], light.diffuse[2]));
GL(shader->setUniformValue(shaderVars->ambientLight, light.ambient[0 ], light.ambient[1], light.ambient[2])); GL(shader->setUniformValue(shaderVars->ambientLight, light.ambient[0 ], light.ambient[1], light.ambient[2]));
GL(shader->setUniformValue(shaderVars->texture, 0)); GL(shader->setUniformValue(shaderVars->texture, 0));
GL(shader->setUniformValue(shaderVars->shadowCount, shadowCandidates .size())); GL(shader->setUniformValue(shaderVars->shadowCount, shadowCandidates .size()));
GL(shader->setUniformValue(shaderVars->shadowData, shadowCandidatesD ata)); GL(shader->setUniformValue(shaderVars->shadowData, shadowCandidatesD ata));
GL(shader->setUniformValue(shaderVars->sunInfo, mTarget[12], mTarget [13], mTarget[14], ssm->getSun()->getRadius())); GL(shader->setUniformValue(shaderVars->sunInfo, mTarget[12], mTarget [13], mTarget[14], ssm->getSun()->getRadius()));
 End of changes. 20 change blocks. 
32 lines changed or deleted 100 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/