StelSkyDrawer.cpp   StelSkyDrawer.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifdef USE_OPENGL_ES2
#include "GLES2/gl2.h"
#endif
#ifndef GL_POINT_SPRITE
#define GL_POINT_SPRITE 0x8861
#endif
#ifndef GL_VERTEX_PROGRAM_POINT_SIZE
#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
#endif
#include <QGLShaderProgram>
#include <QtOpenGL>
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include <QStringList> #include <QStringList>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QtGlobal> #include <QtGlobal>
// The 0.025 corresponds to the maximum eye resolution in degree // The 0.025 corresponds to the maximum eye resolution in degree
#define EYE_RESOLUTION (0.25) #define EYE_RESOLUTION (0.25)
#define MAX_LINEAR_RADIUS 8.f #define MAX_LINEAR_RADIUS 8.f
StelSkyDrawer::StelSkyDrawer(StelCore* acore) : core(acore) StelSkyDrawer::StelSkyDrawer(StelCore* acore) : core(acore), starsShaderPro gram(NULL)
{ {
eye = core->getToneReproducer(); eye = core->getToneReproducer();
sPainter = NULL;
inScale = 1.; inScale = 1.;
bortleScaleIndex = 3; bortleScaleIndex = 3;
limitMagnitude = -100.f; limitMagnitude = -100.f;
limitLuminance = 0; limitLuminance = 0;
oldLum=-1.f; oldLum=-1.f;
maxLum = 0.f; maxLum = 0.f;
setMaxAdaptFov(180.f); setMaxAdaptFov(180.f);
setMinAdaptFov(0.1f); setMinAdaptFov(0.1f);
starAbsoluteScaleF = 1.f; starAbsoluteScaleF = 1.f;
skipping to change at line 98 skipping to change at line 110
if (!ok) if (!ok)
{ {
conf->setValue("stars/absolute_scale",1.0); conf->setValue("stars/absolute_scale",1.0);
setAbsoluteStarScale(1.0); setAbsoluteStarScale(1.0);
ok = true; ok = true;
} }
// Initialize buffers for use by gl vertex array // Initialize buffers for use by gl vertex array
nbPointSources = 0; nbPointSources = 0;
maxPointSources = 1000; maxPointSources = 1000;
verticesGrid = new Vec2f[maxPointSources*4]; verticesGrid = new Vec2f[maxPointSources*6];
colorGrid = new Vec3f[maxPointSources*4]; colorGrid = new Vec3f[maxPointSources*6];
textureGrid = new Vec2f[maxPointSources*4]; textureGrid = new Vec2f[maxPointSources*6];
for (unsigned int i=0;i<maxPointSources; ++i) for (unsigned int i=0;i<maxPointSources; ++i)
{ {
textureGrid[i*4].set(0,0); textureGrid[i*6].set(0,0);
textureGrid[i*4+1].set(1,0); textureGrid[i*6+1].set(1,0);
textureGrid[i*4+2].set(1,1); textureGrid[i*6+2].set(1,1);
textureGrid[i*4+3].set(0,1); textureGrid[i*6+3].set(0,0);
textureGrid[i*6+4].set(1,1);
textureGrid[i*6+5].set(0,1);
} }
} }
StelSkyDrawer::~StelSkyDrawer() StelSkyDrawer::~StelSkyDrawer()
{ {
if (verticesGrid) if (verticesGrid)
delete[] verticesGrid; delete[] verticesGrid;
verticesGrid = NULL; verticesGrid = NULL;
if (colorGrid) if (colorGrid)
delete[] colorGrid; delete[] colorGrid;
colorGrid = NULL; colorGrid = NULL;
if (textureGrid) if (textureGrid)
delete[] textureGrid; delete[] textureGrid;
textureGrid = NULL; textureGrid = NULL;
if (useShader)
{
delete starsShaderProgram;
}
} }
// Init parameters from config file // Init parameters from config file
void StelSkyDrawer::init() void StelSkyDrawer::init()
{ {
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::makeMainGLContextCurrent();
// Load star texture no mipmap: // Load star texture no mipmap:
texHalo = StelApp::getInstance().getTextureManager().createTexture(" star16x16.png"); texHalo = StelApp::getInstance().getTextureManager().createTexture(" star16x16.png");
texBigHalo = StelApp::getInstance().getTextureManager().createTextur e("haloLune.png"); texBigHalo = StelApp::getInstance().getTextureManager().createTextur e("haloLune.png");
texSunHalo = StelApp::getInstance().getTextureManager().createTextur e("halo.png"); texSunHalo = StelApp::getInstance().getTextureManager().createTextur e("halo.png");
useShader = StelApp::getInstance().getUseGLShaders() && (QGLFormat::
openGLVersionFlags().testFlag(QGLFormat::OpenGL_Version_2_1) || QGLFormat::
openGLVersionFlags().testFlag(QGLFormat::OpenGL_ES_Version_2_0));
if (useShader)
{
qDebug() << "Use vertex shader for stars rendering";
QGLShader* vShader = new QGLShader(QGLShader::Vertex);
vShader->compileSourceCode(
"uniform mediump mat4 projec
tionMatrix;\n"
"attribute mediump vec2 skyV
ertex;\n"
"attribute mediump vec3 star
Color;\n"
"attribute mediump vec2 star
Size;\n"
"varying mediump vec4 outCol
or;\n"
"void main()\n"
"{ gl_Position = projec
tionMatrix*vec4(skyVertex[0], skyVertex[1], 0., 1.);\n"
" gl_PointSize = starS
ize[0]*2.;\n"
" outColor = vec4(star
Color, 1.);}");
starsShaderProgram = new QGLShaderProgram();
if (!vShader->isCompiled())
{
qWarning() << "Error while compiling shader: " << vS
hader->log();
useShader = false;
}
if (!vShader->log().isEmpty())
{
qWarning() << "Warnings while compiling vertex shade
r: " << vShader->log();
}
QGLShader* fShader = new QGLShader(QGLShader::Fragment);
if (!fShader->compileSourceCode(
"uniform sampler2D tex;\n"
"varying mediump vec4 outColor;\n"
"void main(){gl_FragColor = texture2D(tex,gl
_PointCoord)*outColor;}"))
{
qWarning() << "Error while compiling fragment shader
: " << fShader->log();
useShader = false;
}
if (!fShader->log().isEmpty())
{
qWarning() << "Warnings while compiling fragment sha
der: " << vShader->log();
}
starsShaderProgram->addShader(vShader);
starsShaderProgram->addShader(fShader);
if (!starsShaderProgram->link())
{
qWarning() << "Error while linking shader program: "
<< starsShaderProgram->log();
useShader = false;
}
if (!starsShaderProgram->log().isEmpty())
{
qWarning() << "Warnings while linking shader: " << s
tarsShaderProgram->log();
}
maxPointSources*=6;
}
update(0); update(0);
} }
void StelSkyDrawer::update(double deltaTime) void StelSkyDrawer::update(double deltaTime)
{ {
float fov = core->getMovementMgr()->getCurrentFov(); float fov = core->getMovementMgr()->getCurrentFov();
if (fov > maxAdaptFov) if (fov > maxAdaptFov)
{ {
fov = maxAdaptFov; fov = maxAdaptFov;
} }
skipping to change at line 181 skipping to change at line 254
float b=30.f; float b=30.f;
float rcmag[2]; float rcmag[2];
float lim = 0.f; float lim = 0.f;
int safety=0; int safety=0;
while (std::fabs(lim-a)>0.05) while (std::fabs(lim-a)>0.05)
{ {
computeRCMag(lim, rcmag); computeRCMag(lim, rcmag);
if (rcmag[0]<=0.f) if (rcmag[0]<=0.f)
{ {
float tmp = lim; float tmp = lim;
lim=(a+lim)/2; lim=(a+lim)*0.5;
b=tmp; b=tmp;
} }
else else
{ {
float tmp = lim; float tmp = lim;
lim=(b+lim)/2; lim=(b+lim)*0.5;
a=tmp; a=tmp;
} }
++safety; ++safety;
if (safety>20) if (safety>20)
{ {
lim=-99; lim=-99;
break; break;
} }
} }
return lim; return lim;
skipping to change at line 214 skipping to change at line 287
float b=500000.f; float b=500000.f;
float lim=40.f; float lim=40.f;
int safety=0; int safety=0;
float adaptL; float adaptL;
while (std::fabs(lim-a)>0.05) while (std::fabs(lim-a)>0.05)
{ {
adaptL = eye->adaptLuminanceScaled(lim); adaptL = eye->adaptLuminanceScaled(lim);
if (adaptL<=0.05f) // Object considered not visible if its a dapted scaled luminance<0.05 if (adaptL<=0.05f) // Object considered not visible if its a dapted scaled luminance<0.05
{ {
float tmp = lim; float tmp = lim;
lim=(b+lim)/2; lim=(b+lim)*0.5;
a=tmp; a=tmp;
} }
else else
{ {
float tmp = lim; float tmp = lim;
lim=(a+lim)/2; lim=(a+lim)*0.5;
b=tmp; b=tmp;
} }
++safety; ++safety;
if (safety>30) if (safety>30)
{ {
lim=500000; lim=500000;
break; break;
} }
} }
return lim; return lim;
skipping to change at line 293 skipping to change at line 366
// cmag: // cmag:
rcMag[1] = 1.0f; rcMag[1] = 1.0f;
if (rcMag[0]>MAX_LINEAR_RADIUS) if (rcMag[0]>MAX_LINEAR_RADIUS)
{ {
rcMag[0]=MAX_LINEAR_RADIUS+std::sqrt(1.f+rcMag[0]-MA X_LINEAR_RADIUS)-1.f; rcMag[0]=MAX_LINEAR_RADIUS+std::sqrt(1.f+rcMag[0]-MA X_LINEAR_RADIUS)-1.f;
} }
} }
return true; return true;
} }
void StelSkyDrawer::preDrawPointSource(const StelPainter* p) void StelSkyDrawer::preDrawPointSource(StelPainter* p)
{ {
Q_ASSERT(p); Q_ASSERT(p);
Q_ASSERT(sPainter==NULL);
sPainter=p;
Q_ASSERT(nbPointSources==0); Q_ASSERT(nbPointSources==0);
glDisable(GL_LIGHTING);
// Blending is really important. Otherwise faint stars in the vicini ty of // Blending is really important. Otherwise faint stars in the vicini ty of
// bright star will cause tiny black squares on the bright star, e.g . see Procyon. // bright star will cause tiny black squares on the bright star, e.g . see Procyon.
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
if (getFlagPointStar()) if (getFlagPointStar())
{ {
glDisable(GL_TEXTURE_2D); p->enableTexture2d(false);
glPointSize(0.1); p->setPointSize(0.1);
} }
else else
{ {
glEnable(GL_TEXTURE_2D); p->enableTexture2d(true);
} }
} }
// Finalize the drawing of point sources // Finalize the drawing of point sources
void StelSkyDrawer::postDrawPointSource() void StelSkyDrawer::postDrawPointSource(StelPainter* sPainter)
{ {
Q_ASSERT(sPainter); Q_ASSERT(sPainter);
sPainter = NULL;
if (nbPointSources==0) if (nbPointSources==0)
return; return;
texHalo->bind(); texHalo->bind();
sPainter->enableTexture2d(true);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
glEnableClientState(GL_VERTEX_ARRAY); if (useShader)
glEnableClientState(GL_COLOR_ARRAY); {
glEnableClientState(GL_TEXTURE_COORD_ARRAY); Q_ASSERT(starsShaderProgram);
#ifndef USE_OPENGL_ES2
// Load the color components glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glColorPointer(3, GL_FLOAT, 0, colorGrid); glEnable(GL_POINT_SPRITE);
// Load the vertex array #endif
glVertexPointer(2, GL_FLOAT, 0, verticesGrid); starsShaderProgram->bind();
// Load the vertex array const Mat4f& m = sPainter->getProjector()->getProjectionMatr
glTexCoordPointer(2, GL_FLOAT, 0, textureGrid); ix();
starsShaderProgram->setUniformValue("projectionMatrix",
// And draw everything at once QMatrix4x4(m[0], m[4], m[8], m[12], m[1], m[5], m[9]
glDrawArrays(GL_QUADS, 0, nbPointSources*4); , m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]));
starsShaderProgram->setAttributeArray("skyVertex", (const GL
glDisableClientState(GL_VERTEX_ARRAY); float*)verticesGrid, 2, 0);
glDisableClientState(GL_COLOR_ARRAY); starsShaderProgram->setAttributeArray("starColor", (const GL
glDisableClientState(GL_TEXTURE_COORD_ARRAY); float*)colorGrid, 3, 0);
starsShaderProgram->setAttributeArray("starSize", (const GLf
loat*)textureGrid, 2, 0);
starsShaderProgram->enableAttributeArray("skyVertex");
starsShaderProgram->enableAttributeArray("starColor");
starsShaderProgram->enableAttributeArray("starSize");
glDrawArrays(GL_POINTS, 0, nbPointSources);
starsShaderProgram->disableAttributeArray("skyVertex");
starsShaderProgram->disableAttributeArray("starColor");
starsShaderProgram->disableAttributeArray("starSize");
starsShaderProgram->release();
#ifndef USE_OPENGL_ES2
glDisable(GL_POINT_SPRITE);
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif
}
else
{
#ifndef USE_OPENGL_ES2
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// Load the color components
glColorPointer(3, GL_FLOAT, 0, colorGrid);
// Load the vertex array
glVertexPointer(2, GL_FLOAT, 0, verticesGrid);
// Load the texture coordinates array
glTexCoordPointer(2, GL_FLOAT, 0, textureGrid);
// And draw everything at once
glDrawArrays(GL_TRIANGLES, 0, nbPointSources*6);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
}
nbPointSources = 0; nbPointSources = 0;
} }
static Vec3d win;
// Draw a point source halo. // Draw a point source halo.
bool StelSkyDrawer::drawPointSource(double x, double y, const float rcMag[2 ], const Vec3f& color) bool StelSkyDrawer::drawPointSource(StelPainter* sPainter, const Vec3d& v, const float rcMag[2], const Vec3f& color, bool checkInScreen)
{ {
Q_ASSERT(sPainter); Q_ASSERT(sPainter);
if (rcMag[0]<=0.f) if (rcMag[0]<=0.f)
return false; return false;
if (!(checkInScreen ? sPainter->getProjector()->projectCheck(v, win)
: sPainter->getProjector()->project(v, win)))
return false;
const double radius = rcMag[0];
// Random coef for star twinkling // Random coef for star twinkling
const float tw = flagStarTwinkle ? (1.f-twinkleAmount*rand()/RAND_MA const float tw = flagStarTwinkle ? (1.f-twinkleAmount*rand()/RAND_MA
X) : 1.f; X)*rcMag[1] : 1.f*rcMag[1];
// If the rmag is big, draw a big halo
if (radius>MAX_LINEAR_RADIUS+5.f)
{
float cmag = qMin(rcMag[1],(float)(radius-(MAX_LINEAR_RADIUS
+5.))/30.f);
float rmag = 150.f;
if (cmag>1.f)
cmag = 1.f;
texBigHalo->bind();
sPainter->enableTexture2d(true);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
sPainter->setColor(color[0]*cmag, color[1]*cmag, color[2]*cm
ag);
sPainter->drawSprite2dMode(win[0], win[1], rmag);
}
if (flagPointStar) if (useShader)
{ {
// Draw the star rendered as GLpoint. This may be faster but // Use point based rendering
it is not so nice verticesGrid[nbPointSources].set(win[0], win[1]);
glColor3fv(color*(rcMag[1]*tw)); colorGrid[nbPointSources]=color;
sPainter->drawPoint2d(x, y); colorGrid[nbPointSources]*=tw;
textureGrid[nbPointSources][0]=radius;
} }
else else
{ {
// Store the drawing instructions in the vertex arrays if (flagPointStar)
colorGrid[nbPointSources*4+3] = color*(rcMag[1]*tw); {
const double radius = rcMag[0]; // Draw the star rendered as GLpoint. This may be fa
Vec2f* v = &(verticesGrid[nbPointSources*4]); ster but it is not so nice
v->set(x-radius,y-radius); ++v; sPainter->setColor(color[0]*tw, color[1]*tw, color[2
v->set(x+radius,y-radius); ++v; ]*tw);
v->set(x+radius,y+radius); ++v; sPainter->drawPoint2d(win[0], win[1]);
v->set(x-radius,y+radius); ++v; }
else
// If the rmag is big, draw a big halo {
if (radius>MAX_LINEAR_RADIUS+5.f) // Store the drawing instructions in the vertex arra
{ ys
float cmag = qMin(rcMag[1],(float)(radius-(MAX_LINEA Vec2f* v = &(verticesGrid[nbPointSources*6]);
R_RADIUS+5.))/30.f); v->set(win[0]-radius,win[1]-radius); ++v;
float rmag = 150.f; v->set(win[0]+radius,win[1]-radius); ++v;
if (cmag>1.f) v->set(win[0]+radius,win[1]+radius); ++v;
cmag = 1.f; v->set(win[0]-radius,win[1]-radius); ++v;
v->set(win[0]+radius,win[1]+radius); ++v;
texBigHalo->bind(); v->set(win[0]-radius,win[1]+radius); ++v;
glEnable(GL_TEXTURE_2D);
glColor3f(color[0]*cmag, color[1]*cmag, color[2]*cma win = color;
g); win*=tw;
Vec3f* cv = &(colorGrid[nbPointSources*6]);
glBegin(GL_QUADS); *cv = win; ++cv;
glTexCoord2i(0,0); glVertex2f(x-rmag,y-rmag) *cv = win; ++cv;
; *cv = win; ++cv;
glTexCoord2i(1,0); glVertex2f(x+rmag,y-rmag) *cv = win; ++cv;
; *cv = win; ++cv;
glTexCoord2i(1,1); glVertex2f(x+rmag,y+rmag) *cv = win; ++cv;
;
glTexCoord2i(0,1); glVertex2f(x-rmag,y+rmag)
;
glEnd();
}
++nbPointSources;
if (nbPointSources>=maxPointSources)
{
// Flush the buffer (draw all buffered stars)
const StelPainter* savePainter = sPainter;
postDrawPointSource();
sPainter = savePainter;
} }
} }
++nbPointSources;
if (nbPointSources>=maxPointSources)
{
// Flush the buffer (draw all buffered stars)
postDrawPointSource(sPainter);
}
return true; return true;
} }
// Terminate drawing of a 3D model, draw the halo // Terminate drawing of a 3D model, draw the halo
void StelSkyDrawer::postDrawSky3dModel(double x, double y, double illuminat edArea, float mag, const StelPainter* painter, const Vec3f& color) void StelSkyDrawer::postDrawSky3dModel(StelPainter* painter, const Vec3d& v , double illuminatedArea, float mag, const Vec3f& color)
{ {
Q_ASSERT(painter); const float pixPerRad = painter->getProjector()->getPixelPerRadAtCen
Q_ASSERT(sPainter==NULL); ter();
glDisable(GL_LIGHTING);
const float pixPerRad = core->getProjection(StelCore::FrameJ2000)->g
etPixelPerRadAtCenter();
// Assume a disk shape // Assume a disk shape
float pixRadius = std::sqrt(illuminatedArea/(60.*60.)*M_PI/180.*M_PI /180.*(pixPerRad*pixPerRad))/M_PI; float pixRadius = std::sqrt(illuminatedArea/(60.*60.)*M_PI/180.*M_PI /180.*(pixPerRad*pixPerRad))/M_PI;
bool noStarHalo = false; bool noStarHalo = false;
if (mag<-15.f) if (mag<-15.f)
{ {
// Sun, halo size varies in function of the magnitude becaus e sun as seen from pluto should look dimmer // Sun, halo size varies in function of the magnitude becaus e sun as seen from pluto should look dimmer
// as the sun as seen from earth // as the sun as seen from earth
texSunHalo->bind(); texSunHalo->bind();
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_TEXTURE_2D); painter->enableTexture2d(true);
float rmag = 150.f*(mag+15.f)/-11.f; float rmag = 150.f*(mag+15.f)/-11.f;
float cmag = 1.f; float cmag = 1.f;
if (rmag<pixRadius*3.f+100.) if (rmag<pixRadius*3.f+100.)
cmag = qMax(0.f, 1.f-(pixRadius*3.f+100-rmag)/100); cmag = qMax(0.f, 1.f-(pixRadius*3.f+100-rmag)/100);
glColor3f(color[0]*cmag, color[1]*cmag, color[2]*cmag); painter->getProjector()->project(v, win);
glBegin(GL_QUADS); painter->setColor(color[0]*cmag, color[1]*cmag, color[2]*cma
glTexCoord2i(0,0); glVertex2f(x-rmag,y-rmag); g);
glTexCoord2i(1,0); glVertex2f(x+rmag,y-rmag); painter->drawSprite2dMode(win[0], win[1], rmag);
glTexCoord2i(1,1); glVertex2f(x+rmag,y+rmag);
glTexCoord2i(0,1); glVertex2f(x-rmag,y+rmag);
glEnd();
noStarHalo = true; noStarHalo = true;
} }
// Now draw the halo according the object brightness // Now draw the halo according the object brightness
bool save = flagStarTwinkle; bool save = flagStarTwinkle;
flagStarTwinkle = false; flagStarTwinkle = false;
float rcm[2]; float rcm[2];
computeRCMag(mag, rcm); computeRCMag(mag, rcm);
skipping to change at line 478 skipping to change at line 592
if (pixRadius>=tStop) if (pixRadius>=tStop)
{ {
rcm[1]=0.f; rcm[1]=0.f;
} }
if (pixRadius>tStart && pixRadius<tStop) if (pixRadius>tStart && pixRadius<tStop)
{ {
rcm[1]=(tStop-pixRadius)/(tStop-tStart); rcm[1]=(tStop-pixRadius)/(tStop-tStart);
} }
if (truncated && flagLuminanceAdaptation) if (truncated && flagLuminanceAdaptation)
{ {
float wl = findWorldLumForMag(mag, rcm[0]); float wl = findWorldLumForMag(mag, rcm[0]);
if (wl>0) if (wl>0)
{ {
const double f = core->getMovementMgr()->getCurrentF ov(); const double f = core->getMovementMgr()->getCurrentF ov();
reportLuminanceInFov(qMin(700., qMin((double)wl/50, (60.*60.)/(f*f)*6.))); reportLuminanceInFov(qMin(700., qMin((double)wl/50, (60.*60.)/(f*f)*6.)));
} }
} }
if (!noStarHalo) if (!noStarHalo)
{ {
preDrawPointSource(painter); preDrawPointSource(painter);
drawPointSource(x,y,rcm,color); drawPointSource(painter, v,rcm,color);
postDrawPointSource(); postDrawPointSource(painter);
} }
flagStarTwinkle=save; flagStarTwinkle=save;
} }
float StelSkyDrawer::findWorldLumForMag(float mag, float targetRadius) float StelSkyDrawer::findWorldLumForMag(float mag, float targetRadius)
{ {
const float saveLum = eye->getWorldAdaptationLuminance(); // s ave const float saveLum = eye->getWorldAdaptationLuminance(); // s ave
// Compute the luminance by dichotomy // Compute the luminance by dichotomy
float a=0.001f; float a=0.001f;
skipping to change at line 595 skipping to change at line 709
} }
bortleScaleIndex = bIndex; bortleScaleIndex = bIndex;
// These value have been calibrated by hand, looking at the faintest star in stellarium at around 40 deg FOV // These value have been calibrated by hand, looking at the faintest star in stellarium at around 40 deg FOV
// They should roughly match the scale described at http://en.wikipe dia.org/wiki/Bortle_Dark-Sky_Scale // They should roughly match the scale described at http://en.wikipe dia.org/wiki/Bortle_Dark-Sky_Scale
static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0.40 , 0.24, 0.23, 0.145, 0.09}; static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0.40 , 0.24, 0.23, 0.145, 0.09};
setInputScale(bortleToInScale[bIndex-1]); setInputScale(bortleToInScale[bIndex-1]);
} }
// Old colors
// Vec3f StelSkyDrawer::colorTable[128] = {
// Vec3f(0.587877,0.755546,1.000000),
// Vec3f(0.609856,0.750638,1.000000),
// Vec3f(0.624467,0.760192,1.000000),
// Vec3f(0.639299,0.769855,1.000000),
// Vec3f(0.654376,0.779633,1.000000),
// Vec3f(0.669710,0.789527,1.000000),
// Vec3f(0.685325,0.799546,1.000000),
// Vec3f(0.701229,0.809688,1.000000),
// Vec3f(0.717450,0.819968,1.000000),
// Vec3f(0.733991,0.830383,1.000000),
// Vec3f(0.750857,0.840932,1.000000),
// Vec3f(0.768091,0.851637,1.000000),
// Vec3f(0.785664,0.862478,1.000000),
// Vec3f(0.803625,0.873482,1.000000),
// Vec3f(0.821969,0.884643,1.000000),
// Vec3f(0.840709,0.895965,1.000000),
// Vec3f(0.859873,0.907464,1.000000),
// Vec3f(0.879449,0.919128,1.000000),
// Vec3f(0.899436,0.930956,1.000000),
// Vec3f(0.919907,0.942988,1.000000),
// Vec3f(0.940830,0.955203,1.000000),
// Vec3f(0.962231,0.967612,1.000000),
// Vec3f(0.984110,0.980215,1.000000),
// Vec3f(1.000000,0.986617,0.993561),
// Vec3f(1.000000,0.977266,0.971387),
// Vec3f(1.000000,0.967997,0.949602),
// Vec3f(1.000000,0.958816,0.928210),
// Vec3f(1.000000,0.949714,0.907186),
// Vec3f(1.000000,0.940708,0.886561),
// Vec3f(1.000000,0.931787,0.866303),
// Vec3f(1.000000,0.922929,0.846357),
// Vec3f(1.000000,0.914163,0.826784),
// Vec3f(1.000000,0.905497,0.807593),
// Vec3f(1.000000,0.896884,0.788676),
// Vec3f(1.000000,0.888389,0.770168),
// Vec3f(1.000000,0.879953,0.751936),
// Vec3f(1.000000,0.871582,0.733989),
// Vec3f(1.000000,0.863309,0.716392),
// Vec3f(1.000000,0.855110,0.699088),
// Vec3f(1.000000,0.846985,0.682070),
// Vec3f(1.000000,0.838928,0.665326),
// Vec3f(1.000000,0.830965,0.648902),
// Vec3f(1.000000,0.823056,0.632710),
// Vec3f(1.000000,0.815254,0.616856),
// Vec3f(1.000000,0.807515,0.601243),
// Vec3f(1.000000,0.799820,0.585831),
// Vec3f(1.000000,0.792222,0.570724),
// Vec3f(1.000000,0.784675,0.555822),
// Vec3f(1.000000,0.777212,0.541190),
// Vec3f(1.000000,0.769821,0.526797),
// Vec3f(1.000000,0.762496,0.512628),
// Vec3f(1.000000,0.755229,0.498664),
// Vec3f(1.000000,0.748032,0.484926),
// Vec3f(1.000000,0.740897,0.471392),
// Vec3f(1.000000,0.733811,0.458036),
// Vec3f(1.000000,0.726810,0.444919),
// Vec3f(1.000000,0.719856,0.431970),
// Vec3f(1.000000,0.712983,0.419247),
// Vec3f(1.000000,0.706154,0.406675),
// Vec3f(1.000000,0.699375,0.394265),
// Vec3f(1.000000,0.692681,0.382075),
// Vec3f(1.000000,0.686003,0.369976),
// Vec3f(1.000000,0.679428,0.358120),
// Vec3f(1.000000,0.672882,0.346373),
// Vec3f(1.000000,0.666372,0.334740),
// Vec3f(1.000000,0.659933,0.323281),
// Vec3f(1.000000,0.653572,0.312004),
// Vec3f(1.000000,0.647237,0.300812),
// Vec3f(1.000000,0.640934,0.289709),
// Vec3f(1.000000,0.634698,0.278755),
// Vec3f(1.000000,0.628536,0.267954),
// Vec3f(1.000000,0.622390,0.257200),
// Vec3f(1.000000,0.616298,0.246551),
// Vec3f(1.000000,0.610230,0.235952),
// Vec3f(1.000000,0.604259,0.225522),
// Vec3f(1.000000,0.598288,0.215083),
// Vec3f(1.000000,0.592391,0.204756),
// Vec3f(1.000000,0.586501,0.194416),
// Vec3f(1.000000,0.580657,0.184120),
// Vec3f(1.000000,0.574901,0.173930),
// Vec3f(1.000000,0.569127,0.163645),
// Vec3f(1.000000,0.563449,0.153455),
// Vec3f(1.000000,0.557758,0.143147),
// Vec3f(1.000000,0.552134,0.132843),
// Vec3f(1.000000,0.546541,0.122458),
// Vec3f(1.000000,0.540984,0.111966),
// Vec3f(1.000000,0.535464,0.101340),
// Vec3f(1.000000,0.529985,0.090543),
// Vec3f(1.000000,0.524551,0.079292),
// Vec3f(1.000000,0.519122,0.068489),
// Vec3f(1.000000,0.513743,0.058236),
// Vec3f(1.000000,0.508417,0.048515),
// Vec3f(1.000000,0.503104,0.039232),
// Vec3f(1.000000,0.497805,0.030373),
// Vec3f(1.000000,0.492557,0.021982),
// Vec3f(1.000000,0.487338,0.014007),
// Vec3f(1.000000,0.482141,0.006417),
// Vec3f(1.000000,0.477114,0.000000),
// Vec3f(1.000000,0.473268,0.000000),
// Vec3f(1.000000,0.469419,0.000000),
// Vec3f(1.000000,0.465552,0.000000),
// Vec3f(1.000000,0.461707,0.000000),
// Vec3f(1.000000,0.457846,0.000000),
// Vec3f(1.000000,0.453993,0.000000),
// Vec3f(1.000000,0.450129,0.000000),
// Vec3f(1.000000,0.446276,0.000000),
// Vec3f(1.000000,0.442415,0.000000),
// Vec3f(1.000000,0.438549,0.000000),
// Vec3f(1.000000,0.434702,0.000000),
// Vec3f(1.000000,0.430853,0.000000),
// Vec3f(1.000000,0.426981,0.000000),
// Vec3f(1.000000,0.423134,0.000000),
// Vec3f(1.000000,0.419268,0.000000),
// Vec3f(1.000000,0.415431,0.000000),
// Vec3f(1.000000,0.411577,0.000000),
// Vec3f(1.000000,0.407733,0.000000),
// Vec3f(1.000000,0.403874,0.000000),
// Vec3f(1.000000,0.400029,0.000000),
// Vec3f(1.000000,0.396172,0.000000),
// Vec3f(1.000000,0.392331,0.000000),
// Vec3f(1.000000,0.388509,0.000000),
// Vec3f(1.000000,0.384653,0.000000),
// Vec3f(1.000000,0.380818,0.000000),
// Vec3f(1.000000,0.376979,0.000000),
// Vec3f(1.000000,0.373166,0.000000),
// Vec3f(1.000000,0.369322,0.000000),
// Vec3f(1.000000,0.365506,0.000000),
// Vec3f(1.000000,0.361692,0.000000),
// };
// New colors // New colors
Vec3f StelSkyDrawer::colorTable[128] = { Vec3f StelSkyDrawer::colorTable[128] = {
Vec3f(0.602745,0.713725,1.000000), Vec3f(0.602745,0.713725,1.000000),
Vec3f(0.604902,0.715294,1.000000), Vec3f(0.604902,0.715294,1.000000),
Vec3f(0.607059,0.716863,1.000000), Vec3f(0.607059,0.716863,1.000000),
Vec3f(0.609215,0.718431,1.000000), Vec3f(0.609215,0.718431,1.000000),
Vec3f(0.611372,0.720000,1.000000), Vec3f(0.611372,0.720000,1.000000),
Vec3f(0.613529,0.721569,1.000000), Vec3f(0.613529,0.721569,1.000000),
Vec3f(0.635490,0.737255,1.000000), Vec3f(0.635490,0.737255,1.000000),
Vec3f(0.651059,0.749673,1.000000), Vec3f(0.651059,0.749673,1.000000),
 End of changes. 37 change blocks. 
245 lines changed or deleted 249 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/