ZodiacalLight.cpp   ZodiacalLight.cpp 
skipping to change at line 95 skipping to change at line 95
{ {
fader->update((int)(deltaTime*1000)); fader->update((int)(deltaTime*1000));
if (!getFlagShow() || (getIntensity()<0.01) ) if (!getFlagShow() || (getIntensity()<0.01) )
return; return;
StelCore* core=StelApp::getInstance().getCore(); StelCore* core=StelApp::getInstance().getCore();
// Test if we are not on Earth. Texture would not fit, so don't draw then. // Test if we are not on Earth. Texture would not fit, so don't draw then.
if (core->getCurrentLocation().planetName != "Earth") return; if (core->getCurrentLocation().planetName != "Earth") return;
double currentJD=core->getJDay(); double currentJD=core->getJD();
if (qAbs(currentJD - lastJD) > 0.25f) // should be enough to update position every 6 hours. if (qAbs(currentJD - lastJD) > 0.25f) // should be enough to update position every 6 hours.
{ {
// update vertices // update vertices
Vec3d obsPos=core->getObserverHeliocentricEclipticPos(); Vec3d obsPos=core->getObserverHeliocentricEclipticPos();
// For solar-centered texture, take minus, else plus: // For solar-centered texture, take minus, else plus:
double solarLongitude=atan2(obsPos[1], obsPos[0]) - 0.5*M_PI ; double solarLongitude=atan2(obsPos[1], obsPos[0]) - 0.5*M_PI ;
Mat4d transMat=core->matVsop87ToJ2000 * Mat4d::zrotation(sol arLongitude); Mat4d transMat=core->matVsop87ToJ2000 * Mat4d::zrotation(sol arLongitude);
for (int i=0; i<eclipticalVertices.size(); ++i) for (int i=0; i<eclipticalVertices.size(); ++i)
{ {
Vec3d tmp=eclipticalVertices.at(i); Vec3d tmp=eclipticalVertices.at(i);
skipping to change at line 130 skipping to change at line 130
} }
void ZodiacalLight::draw(StelCore* core) void ZodiacalLight::draw(StelCore* core)
{ {
if (!getFlagShow() || (getIntensity()<0.01) ) if (!getFlagShow() || (getIntensity()<0.01) )
return; return;
// Test if we are not on Earth. Texture would not fit, so don't draw then. // Test if we are not on Earth. Texture would not fit, so don't draw then.
if (core->getCurrentLocation().planetName != "Earth") return; if (core->getCurrentLocation().planetName != "Earth") return;
int bortle=core->getSkyDrawer()->getBortleScaleIndex(); StelSkyDrawer *drawer=core->getSkyDrawer();
// Test for light pollution, return if too bad. (So fps stays high f int bortle=drawer->getBortleScaleIndex();
or really bad places.) // Test for light pollution, return if too bad.
if ( (core->getSkyDrawer()->getFlagHasAtmosphere()) && (bortle > 5) if ( (drawer->getFlagHasAtmosphere()) && (bortle > 5) ) return;
) return;
StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT ransform(); StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT ransform();
const StelProjectorP prj = core->getProjection(transfo); const StelProjectorP prj = core->getProjection(transfo);
StelToneReproducer* eye = core->getToneReproducer(); StelToneReproducer* eye = core->getToneReproducer();
Q_ASSERT(tex); // A texture must be loaded before calling this Q_ASSERT(tex); // A texture must be loaded before calling this
// Default ZL color is white (sunlight) // Default ZL color is white (sunlight)
Vec3f c = Vec3f(1.0f, 1.0f, 1.0f); Vec3f c = Vec3f(1.0f, 1.0f, 1.0f);
// ZL is quite sensitive to light pollution. I scale to make it less visible. // ZL is quite sensitive to light pollution. I scale to make it less visible.
float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(13.5f + 0.5f*bortle); // (8.0f + 0.5*bortle); float lum = drawer->surfacebrightnessToLuminance(13.5f + 0.5f*bortle ); // (8.0f + 0.5*bortle);
// Get the luminance scaled between 0 and 1 // Get the luminance scaled between 0 and 1
float aLum =eye->adaptLuminanceScaled(lum*fader->getInterstate()); float aLum =eye->adaptLuminanceScaled(lum*fader->getInterstate());
// Bound a maximum luminance // Bound a maximum luminance
aLum = qMin(0.15f, aLum*2.f); // 2*aLum at dark sky with mag13.5 at Bortle=1 gives 0.13 aLum = qMin(0.15f, aLum*2.f); // 2*aLum at dark sky with mag13.5 at Bortle=1 gives 0.13
//qDebug() << "aLum=" << aLum; //qDebug() << "aLum=" << aLum;
// intensity of 1.0 is "proper", but allow boost for dim screens // intensity of 1.0 is "proper", but allow boost for dim screens
c*=aLum*intensity; c*=aLum*intensity;
// // In brighter twilight we should tune brightness down. So for sun a bove -18 degrees, we must tweak here: // // In brighter twilight we should tune brightness down. So for sun a bove -18 degrees, we must tweak here:
// const Vec3d& sunPos = GETSTELMODULE(SolarSystem)->getSun()->getAltAz PosGeometric(core); // const Vec3d& sunPos = GETSTELMODULE(SolarSystem)->getSun()->getAltAz PosGeometric(core);
// if (core->getSkyDrawer()->getFlagHasAtmosphere()) // if (drawer->getFlagHasAtmosphere())
// { // {
// if (sunPos[2] > -0.1) return; // Make ZL invisible during ci vil twilight and daylight. // if (sunPos[2] > -0.1) return; // Make ZL invisible during ci vil twilight and daylight.
// if (sunPos[2] > -0.3) // if (sunPos[2] > -0.3)
// { // scale twilight down for sun altitude -18..-6, i.e. scal e -0.3..-0.1 to 1..0, // { // scale twilight down for sun altitude -18..-6, i.e. scal e -0.3..-0.1 to 1..0,
// float twilightScale= -5.0f* (sunPos[2]+0.1) ; // 0( if bright)..1(dark) // float twilightScale= -5.0f* (sunPos[2]+0.1) ; // 0( if bright)..1(dark)
// c*=twilightScale; // c*=twilightScale;
// } // }
// } // }
// Better: adapt brightness by atmospheric brightness // Better: adapt brightness by atmospheric brightness
const float atmLum = GETSTELMODULE(LandscapeMgr)->getAtmosphereAvera geLuminance(); const float atmLum = GETSTELMODULE(LandscapeMgr)->getAtmosphereAvera geLuminance();
if (atmLum>0.5f) return; // 10cd/m^2 at sunset, 3.3 at civil twiligh t (sun at -6deg). 0.0145 sun at -12, 0.0004 sun at -18, 0.01 at Full Moon! ? if (atmLum>0.05f) return; // 10cd/m^2 at sunset, 3.3 at civil twilig ht (sun at -6deg). 0.0145 sun at -12, 0.0004 sun at -18, 0.01 at Full Moon !?
//qDebug() << "AtmLum: " << atmLum; //qDebug() << "AtmLum: " << atmLum;
float atmFactor=2.0f*(0.5f-atmLum); float atmFactor=20.0f*(0.05f-atmLum);
Q_ASSERT(atmFactor<=1.0f);
Q_ASSERT(atmFactor>=0.0f);
c*=atmFactor*atmFactor; c*=atmFactor*atmFactor;
if (c[0]<0) c[0]=0; if (c[0]<0) c[0]=0;
if (c[1]<0) c[1]=0; if (c[1]<0) c[1]=0;
if (c[2]<0) c[2]=0; if (c[2]<0) c[2]=0;
const bool withExtinction=(core->getSkyDrawer()->getFlagHasAtmospher e() && core->getSkyDrawer()->getExtinction().getExtinctionCoefficient()>=0. 01f); const bool withExtinction=(drawer->getFlagHasAtmosphere() && drawer- >getExtinction().getExtinctionCoefficient()>=0.01f);
if (withExtinction) if (withExtinction)
{ {
// We must process the vertices to find geometric altitudes in order to compute vertex colors. // We must process the vertices to find geometric altitudes in order to compute vertex colors.
Extinction extinction=core->getSkyDrawer()->getExtinction(); const Extinction& extinction=drawer->getExtinction();
vertexArray->colors.clear(); vertexArray->colors.clear();
for (int i=0; i<vertexArray->vertex.size(); ++i) for (int i=0; i<vertexArray->vertex.size(); ++i)
{ {
Vec3d vertAltAz=core->j2000ToAltAz(vertexArray->vert ex.at(i), StelCore::RefractionOn); Vec3d vertAltAz=core->j2000ToAltAz(vertexArray->vert ex.at(i), StelCore::RefractionOn);
Q_ASSERT(vertAltAz.lengthSquared()-1.0 < 0.001f); Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001 f);
float oneMag=0.0f; float oneMag=0.0f;
extinction.forward(vertAltAz, &oneMag); extinction.forward(vertAltAz, &oneMag);
float extinctionFactor=std::pow(0.4f , oneMag)/bortl e; // drop of one magnitude: factor 2.5 or 40%, and further reduced by ligh t pollution float extinctionFactor=std::pow(0.4f , oneMag)/bortl e; // drop of one magnitude: factor 2.5 or 40%, and further reduced by ligh t pollution
Vec3f thisColor=Vec3f(c[0]*extinctionFactor, c[1]*ex tinctionFactor, c[2]*extinctionFactor); Vec3f thisColor=Vec3f(c[0]*extinctionFactor, c[1]*ex tinctionFactor, c[2]*extinctionFactor);
vertexArray->colors.append(thisColor); vertexArray->colors.append(thisColor);
} }
} }
else else
vertexArray->colors.fill(Vec3f(c[0], c[1], c[2])); vertexArray->colors.fill(Vec3f(c[0], c[1], c[2]));
 End of changes. 9 change blocks. 
13 lines changed or deleted 14 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/