MilkyWay.cpp   MilkyWay.cpp 
skipping to change at line 35 skipping to change at line 35
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelModuleMgr.hpp"
#include "LandscapeMgr.hpp"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
// Class which manages the displaying of the Milky Way // Class which manages the displaying of the Milky Way
MilkyWay::MilkyWay() MilkyWay::MilkyWay()
: color(1.f, 1.f, 1.f) : color(1.f, 1.f, 1.f)
, intensity(1.) , intensity(1.)
, vertexArray() , vertexArray()
{ {
skipping to change at line 93 skipping to change at line 95
void MilkyWay::draw(StelCore* core) void MilkyWay::draw(StelCore* core)
{ {
if (!getFlagShow()) if (!getFlagShow())
return; return;
StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT ransform(); StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT ransform();
const StelProjectorP prj = core->getProjection(transfo); // GZ: Mayb e this can now be simplified? const StelProjectorP prj = core->getProjection(transfo); // GZ: Mayb e this can now be simplified?
StelToneReproducer* eye = core->getToneReproducer(); StelToneReproducer* eye = core->getToneReproducer();
StelSkyDrawer *drawer=core->getSkyDrawer();
Q_ASSERT(tex); // A texture must be loaded before calling this Q_ASSERT(tex); // A texture must be loaded before calling this
// This RGB color corresponds to the night blue scotopic color = 0.2 5, 0.25 in xyY mode. // This RGB color corresponds to the night blue scotopic color = 0.2 5, 0.25 in xyY mode.
// since milky way is always seen white RGB value in the texture (1. 0,1.0,1.0) // since milky way is always seen white RGB value in the texture (1. 0,1.0,1.0)
// Vec3f c = Vec3f(0.34165f, 0.429666f, 0.63586f); // Vec3f c = Vec3f(0.34165f, 0.429666f, 0.63586f);
// This is the same color, just brighter to have Blue=1. // This is the same color, just brighter to have Blue=1.
//Vec3f c = Vec3f(0.53730381f, .675724216f, 1.0f); //Vec3f c = Vec3f(0.53730381f, .675724216f, 1.0f);
// The new texture (V0.13.1) is quite blue to start with. It is bett er to apply white color for it. // The new texture (V0.13.1) is quite blue to start with. It is bett er to apply white color for it.
Vec3f c = Vec3f(1.0f, 1.0f, 1.0f); Vec3f c = Vec3f(1.0f, 1.0f, 1.0f);
float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(11.5f // We must also adjust milky way to light pollution.
); // Source? How to calibrate the new texture? // Is there any way to calibrate this?
int bortle=drawer->getBortleScaleIndex();
//aLum*=(11.0f-bortle)*0.1f;
float lum = drawer->surfacebrightnessToLuminance(12.f+0.15*bortle);
// was 11.5; Source? How to calibrate the new texture?
// 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. GZ: Is there any reference/reason, or just trial and error? // Bound a maximum luminance. GZ: Is there any reference/reason, or just trial and error?
aLum = qMin(0.38f, aLum*2.f); aLum = qMin(0.38f, aLum*2.f);
// We must also adjust milky way to light pollution.
// Is there any way to calibrate this?
int bortle=core->getSkyDrawer()->getBortleScaleIndex();
aLum*=(11.0f-bortle)*0.1f;
// 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;
// TODO: Find an even better balance with sky brightness, MW should
be hard to see during Full Moon and at least somewhat reduced in smaller ph
ases.
// adapt brightness by atmospheric brightness. This block developed
for ZodiacalLight, hopefully similarly applicable...
const float atmLum = GETSTELMODULE(LandscapeMgr)->getAtmosphereAvera
geLuminance();
// 10cd/m^2 at sunset, 3.3 at civil twilight (sun at -6deg). 0.0145
sun at -12, 0.0004 sun at -18, 0.01 at Full Moon!?
//qDebug() << "AtmLum: " << atmLum;
float atmFactor=qMax(0.35f, 50.0f*(0.02f-atmLum)); // keep visible i
n twilight, but this is enough for some effect with the moon.
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.
// Note that there is a visible boost of extinction for high er Bortle indices. I must reflect that as well. // Note that there is a visible boost of extinction for high er Bortle indices. I must reflect that as well.
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(fabs(vertAltAz.lengthSquared()-1.0) < 0.001 ); Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001 );
float oneMag=0.0f; float oneMag=0.0f;
extinction.forward(vertAltAz, &oneMag); extinction.forward(vertAltAz, &oneMag);
float extinctionFactor=std::pow(0.4f , oneMag) * (1. 1f-bortle*0.1f); // drop of one magnitude: factor 2.5 or 40% float extinctionFactor=std::pow(0.3f , oneMag) * (1. 1f-bortle*0.1f); // drop of one magnitude: should be factor 2.5 or 40%. We take 30%, it looks more realistic.
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]));
StelPainter sPainter(prj); StelPainter sPainter(prj);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
 End of changes. 8 change blocks. 
10 lines changed or deleted 27 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/