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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#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 "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelTextureMgr.hpp" #include "renderer/StelTextureNew.hpp"
#include "renderer/StelRenderer.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 <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.25f) #define EYE_RESOLUTION (0.25f)
#define MAX_LINEAR_RADIUS 8.f #define MAX_LINEAR_RADIUS (8.f)
StelSkyDrawer::StelSkyDrawer(StelCore* acore) : core(acore), starsShaderPro StelSkyDrawer::StelSkyDrawer(StelCore* acore, StelRenderer* renderer)
gram(NULL) : core(acore)
, renderer(renderer)
, texHalo(NULL)
, starPointBuffer(NULL)
, starSpriteBuffer(NULL)
, drawing(false)
, texBigHalo(NULL)
, texSunHalo(NULL)
, texCorona(NULL)
, statisticsInitialized(false)
, bigHaloStatID(-1)
, sunHaloStatID(-1)
, starStatID(-1)
{ {
eye = core->getToneReproducer(); eye = core->getToneReproducer();
inScale = 1.f; inScale = 1.f;
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);
skipping to change at line 79 skipping to change at line 78
starLinearScale = 19.569f; starLinearScale = 19.569f;
big3dModelHaloRadius = 150.f; big3dModelHaloRadius = 150.f;
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
initColorTableFromConfigFile(conf); initColorTableFromConfigFile(conf);
setFlagHasAtmosphere(conf->value("landscape/flag_atmosphere", true). toBool()); setFlagHasAtmosphere(conf->value("landscape/flag_atmosphere", true). toBool());
setTwinkleAmount(conf->value("stars/star_twinkle_amount",0.3).toFloa t()); setTwinkleAmount(conf->value("stars/star_twinkle_amount",0.3).toFloa t());
setFlagTwinkle(conf->value("stars/flag_star_twinkle",true).toBool()) ; setFlagTwinkle(conf->value("stars/flag_star_twinkle",true).toBool()) ;
setFlagPointStar(conf->value("stars/flag_point_star",false).toBool() ); setDrawStarsAsPoints(conf->value("stars/flag_point_star",false).toBo ol());
setMaxAdaptFov(conf->value("stars/mag_converter_max_fov",70.0).toFlo at()); setMaxAdaptFov(conf->value("stars/mag_converter_max_fov",70.0).toFlo at());
setMinAdaptFov(conf->value("stars/mag_converter_min_fov",0.1).toFloa t()); setMinAdaptFov(conf->value("stars/mag_converter_min_fov",0.1).toFloa t());
setFlagLuminanceAdaptation(conf->value("viewing/use_luminance_adapta tion",true).toBool()); setFlagLuminanceAdaptation(conf->value("viewing/use_luminance_adapta tion",true).toBool());
bool ok=true; bool ok=true;
setBortleScale(conf->value("stars/init_bortle_scale",3).toInt(&ok)); setBortleScale(conf->value("stars/init_bortle_scale",3).toInt(&ok));
if (!ok) if (!ok)
{ {
conf->setValue("stars/init_bortle_scale",3); conf->setValue("stars/init_bortle_scale",3);
skipping to change at line 133 skipping to change at line 132
ok = true; ok = true;
} }
setAtmospherePressure(conf->value("landscape/pressure_mbar",1013.0). toDouble(&ok)); setAtmospherePressure(conf->value("landscape/pressure_mbar",1013.0). toDouble(&ok));
if (!ok) if (!ok)
{ {
conf->setValue("landscape/pressure_mbar",1013.0); conf->setValue("landscape/pressure_mbar",1013.0);
setAtmospherePressure(1013.0); setAtmospherePressure(1013.0);
ok = true; ok = true;
} }
// Initialize buffers for use by gl vertex array starPointBuffer = renderer->createVertexBuffer<ColoredVertex>(Prim
nbPointSources = 0; itiveType_Points);
maxPointSources = 1000; starSpriteBuffer = renderer->createVertexBuffer<ColoredTexturedVert
verticesGrid = new Vec2f[maxPointSources*6]; ex>(PrimitiveType_Triangles);
colorGrid = new Vec3f[maxPointSources*6]; bigHaloBuffer = renderer->createVertexBuffer<ColoredTexturedVert
textureGrid = new Vec2f[maxPointSources*6]; ex>(PrimitiveType_Triangles);
for (unsigned int i=0;i<maxPointSources; ++i) sunHaloBuffer = renderer->createVertexBuffer<ColoredTexturedVert
{ ex>(PrimitiveType_Triangles);
textureGrid[i*6].set(0,0); coronaBuffer = renderer->createVertexBuffer<ColoredTexturedVert
textureGrid[i*6+1].set(1,0); ex>(PrimitiveType_Triangles);
textureGrid[i*6+2].set(1,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(NULL != starPointBuffer) {delete starPointBuffer;}
delete[] verticesGrid; if(NULL != starSpriteBuffer) {delete starSpriteBuffer;}
verticesGrid = NULL; if(NULL != bigHaloBuffer) {delete bigHaloBuffer;}
if (colorGrid) if(NULL != sunHaloBuffer) {delete sunHaloBuffer;}
delete[] colorGrid; if(NULL != coronaBuffer) {delete coronaBuffer;}
colorGrid = NULL; if(NULL != texBigHalo) {delete texBigHalo;}
if (textureGrid) if(NULL != texSunHalo) {delete texSunHalo;}
delete[] textureGrid; if(NULL != texHalo) {delete texHalo;}
textureGrid = NULL; if(NULL != texCorona) {delete texCorona;}
if (useShader)
{
delete starsShaderProgram;
}
} }
// Init parameters from config file // Init parameters from config file
void StelSkyDrawer::init() void StelSkyDrawer::init()
{ {
StelPainter::makeMainGLContextCurrent();
// Load star texture no mipmap: // Load star texture no mipmap:
texHalo = StelApp::getInstance().getTextureManager().createTexture(" texHalo = renderer->createTexture("textures/star16x16.png");
textures/star16x16.png"); texBigHalo = renderer->createTexture("textures/haloLune.png");
texBigHalo = StelApp::getInstance().getTextureManager().createTextur texSunHalo = renderer->createTexture("textures/halo.png");
e("textures/haloLune.png"); texCorona = renderer->createTexture("textures/corona.png");
texSunHalo = StelApp::getInstance().getTextureManager().createTextur
e("textures/halo.png");
useShader = StelApp::getInstance().getUseGLShaders();
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) void StelSkyDrawer::update(double)
{ {
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 402 skipping to change at line 333
// 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(StelPainter* p) void StelSkyDrawer::preDrawPointSource()
{ {
Q_ASSERT(p); Q_ASSERT_X(!drawing, Q_FUNC_INFO,
Q_ASSERT(nbPointSources==0); "Attempting to start drawing point sources when it is alr
eady started");
// Blending is really important. Otherwise faint stars in the vicini drawing = true;
ty of }
// bright star will cause tiny black squares on the bright star, e.g
. see Procyon.
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
if (getFlagPointStar()) // Helper function that sets Add blend mode, then draws and clears a vertex
{ buffer.
p->enableTexture2d(false); //
p->setPointSize(0.1); // The buffer is cleared since we re-add the stars on each frame.
} template<class VB>
else void drawStars(StelTextureNew* texture, VB* vertices, StelRenderer* rendere
{ r, StelProjectorP projector)
p->enableTexture2d(true); {
} if(NULL != texture){texture->bind();}
renderer->setBlendMode(BlendMode_Add);
vertices->lock();
// Vertices are already projected, so we use the dontProject
// argument of drawVertexBuffer.
//
// This is a hack - it would be better to refactor StelSkyDrawer,
// ZoneArray, etc, so projection gets done by the projector
// during drawing like elsewhere.
renderer->drawVertexBuffer(vertices, NULL, projector, true);
vertices->unlock();
vertices->clear();
} }
// Finalize the drawing of point sources // Finalize the drawing of point sources
void StelSkyDrawer::postDrawPointSource(StelPainter* sPainter) void StelSkyDrawer::postDrawPointSource(StelProjectorP projector)
{ {
Q_ASSERT(sPainter); StelRendererStatistics& stats = renderer->getStatistics();
if(!statisticsInitialized)
if (nbPointSources==0) {
return; bigHaloStatID = stats.addStatistic("big_halo_draws", Statist
texHalo->bind(); icSwapMode_SetToZero);
sPainter->enableTexture2d(true); sunHaloStatID = stats.addStatistic("sun_halo_draws", Statist
glBlendFunc(GL_ONE, GL_ONE); icSwapMode_SetToZero);
glEnable(GL_BLEND); starStatID = stats.addStatistic("star_draws", Statist
icSwapMode_SetToZero);
if (useShader) statisticsInitialized = true;
{
Q_ASSERT(starsShaderProgram);
#ifndef USE_OPENGL_ES2
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glEnable(GL_POINT_SPRITE);
#endif
starsShaderProgram->bind();
const Mat4f& m = sPainter->getProjector()->getProjectionMatr
ix();
starsShaderProgram->setUniformValue("projectionMatrix",
QMatrix4x4(m[0], m[4], m[8], m[12], m[1], m[5], m[9]
, m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]));
starsShaderProgram->setAttributeArray("skyVertex", (const GL
float*)verticesGrid, 2, 0);
starsShaderProgram->setAttributeArray("starColor", (const GL
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 if(bigHaloBuffer->length() > 0)
{
drawStars(texBigHalo, bigHaloBuffer, renderer, projector);
stats[bigHaloStatID] += 1.0;
}
if(sunHaloBuffer->length() > 0)
{
drawStars(texSunHalo, sunHaloBuffer, renderer, projector);
stats[sunHaloStatID] += 1.0;
}
if(drawStarsAsPoints && starPointBuffer->length() > 0)
{
stats[starStatID] += 1.0;
drawStars(NULL, starPointBuffer, renderer, projector);
}
else if(starSpriteBuffer->length() > 0)
{ {
#ifndef USE_OPENGL_ES2 stats[starStatID] += 1.0;
glEnableClientState(GL_VERTEX_ARRAY); drawStars(texHalo, starSpriteBuffer, renderer, projector);
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;
drawing = false;
} }
static Vec3d win; //Helper function that adds the halo of a star/other point source to given
// Draw a point source halo. vertex buffer.
bool StelSkyDrawer::drawPointSource(StelPainter* sPainter, const Vec3d& v, //
const float rcMag[2], const Vec3f& bcolor, bool checkInScreen) //The template parameter is only used so we don't need to write ColoredText
uredVertex
//every time, this function is only meant to be used from drawPointSource.
template<class V>
static void addStar(StelVertexBuffer<V>* vertices,
const float x, const float y,
const float radius, const Vec3f& color)
{ {
Q_ASSERT(sPainter); // 1 triangle around the star sprite. We use the fact
Vec3f color(bcolor); // that edges of the halo textures are transparent and
if (StelApp::getInstance().getVisionModeNight()) // the clamp to edge draw mode. With that, we can draw 1
{ // larger triangle around the sprite quad instead of drawing
color[1] = 0; // the quad as 2 triangles.
color[2] = 0;
}
if (rcMag[0]<=0.f) const float yBase = y - radius;
return false; const float yTop = y + radius * 2.6666666;
const float xLeft = x - radius * 2.3333333;
const float xRight = x + radius * 2.3333333;
// TODO: compute Vec3f v_refr (position including refraction) --> NO vertices->addVertex(V(Vec2f(xLeft, yBase), color, Vec2f(-0.6666666f
: This is done in ZoneArray! , 0.0f)));
vertices->addVertex(V(Vec2f(xRight, yBase), color, Vec2f(1.6666666f,
0.0f)));
vertices->addVertex(V(Vec2f(x, yTop), color, Vec2f(0.5f,
1.83333333f)));
}
if (!(checkInScreen ? sPainter->getProjector()->projectCheck(v, win) // Draw a point source halo.
: sPainter->getProjector()->project(v, win))) void StelSkyDrawer::drawPointSource
return false; (const Vec3f& win, const float rcMag[2], const Vec3f& bcolor)
{
Q_ASSERT_X(drawing, Q_FUNC_INFO,
"Attempting to draw a point source without calling preDra
wPointSource first.");
const float radius = rcMag[0];
const float luminance = rcMag[1];
const float radius = rcMag[0]; const Vec3f color = StelApp::getInstance().getVisionModeNight()
? Vec3f(bcolor[0], 0, 0) : bcolor;
// Random coef for star twinkling // Random coef for star twinkling
const float tw = (flagStarTwinkle && flagHasAtmosphere) ? (1.f-twink const float tw = (flagStarTwinkle && flagHasAtmosphere)
leAmount*rand()/RAND_MAX)*rcMag[1] : rcMag[1]; ? (1.0f - twinkleAmount * rand() / RAND_MAX) * lumi
nance
: luminance;
const float x = win[0];
const float y = win[1];
// If the rmag is big, draw a big halo // If the rmag is big, draw a big halo
if (radius>MAX_LINEAR_RADIUS+5.f) if (radius > MAX_LINEAR_RADIUS + 5.0f)
{ {
float cmag = qMin(rcMag[1],(float)(radius-(MAX_LINEAR_RADIUS const float cmag = qMin(1.0f, qMin(luminance, (radius - MAX_
+5.f))/30.f); LINEAR_RADIUS + 5.0f) / 30.f));
float rmag = 150.f; addStar(bigHaloBuffer, x, y, 150.0f, color * cmag);
if (cmag>1.f)
cmag = 1.f;
texBigHalo->bind();
sPainter->enableTexture2d(true);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
if (StelApp::getInstance().getVisionModeNight())
sPainter->setColor(color[0]*cmag, 0.0, 0.0);
else
sPainter->setColor(color[0]*cmag, color[1]*cmag, col
or[2]*cmag);
sPainter->drawSprite2dMode(win[0], win[1], rmag);
} }
#ifndef USE_OPENGL_ES2 if (drawStarsAsPoints)
if (useShader)
{ {
#endif starPointBuffer->addVertex(ColoredVertex(Vec2f(x, y), color
// Use point based rendering * tw));
verticesGrid[nbPointSources].set(win[0], win[1]);
colorGrid[nbPointSources].set(color[0]*tw, color[1]*tw, colo
r[2]*tw);
textureGrid[nbPointSources][0]=radius;
#ifndef USE_OPENGL_ES2
} }
else else
{ {
if (flagPointStar) addStar(starSpriteBuffer, x, y, radius, color * tw);
{
// Draw the star rendered as GLpoint. This may be fa
ster but it is not so nice
sPainter->setColor(color[0]*tw, color[1]*tw, color[2
]*tw);
sPainter->drawPoint2d(win[0], win[1]);
}
else
{
// Store the drawing instructions in the vertex arra
ys
Vec2f* v = &(verticesGrid[nbPointSources*6]);
v->set(win[0]-radius,win[1]-radius); ++v;
v->set(win[0]+radius,win[1]-radius); ++v;
v->set(win[0]+radius,win[1]+radius); ++v;
v->set(win[0]-radius,win[1]-radius); ++v;
v->set(win[0]+radius,win[1]+radius); ++v;
v->set(win[0]-radius,win[1]+radius); ++v;
Vec3f w = color;
w = color;
w*=tw;
Vec3f* cv = &(colorGrid[nbPointSources*6]);
*cv = w; ++cv;
*cv = w; ++cv;
*cv = w; ++cv;
*cv = w; ++cv;
*cv = w; ++cv;
*cv = w; ++cv;
win = Vec3d(w[0],w[1],w[2]);
}
} }
#endif }
++nbPointSources; // Draw's the sun's corona during a solar eclipse on earth.
if (nbPointSources>=maxPointSources) void StelSkyDrawer::drawSunCorona(StelProjectorP projector, const Vec3d &v,
{ float radius, float alpha)
// Flush the buffer (draw all buffered stars) {
postDrawPointSource(sPainter); Vec3d win;
} projector->project(v, win);
return true; addStar(coronaBuffer, win[0], win[1], radius * 2, Vec3f(alpha, alpha
, alpha));
drawStars(texCorona, coronaBuffer, renderer, projector);
} }
// Terminate drawing of a 3D model, draw the halo // Terminate drawing of a 3D model, draw the halo
void StelSkyDrawer::postDrawSky3dModel(StelPainter* painter, const Vec3d& v void StelSkyDrawer::postDrawSky3dModel
, float illuminatedArea, float mag, const Vec3f& color) (StelProjectorP projector, const Vec3d& v, float illuminatedArea,
float mag, const Vec3f& color)
{ {
const float pixPerRad = painter->getProjector()->getPixelPerRadAtCen ter(); const float pixPerRad = projector->getPixelPerRadAtCenter();
// 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 const float rmag = big3dModelHaloRadius*(mag+15.f)/-11.f;
e sun as seen from pluto should look dimmer
// as the sun as seen from earth
texSunHalo->bind();
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
painter->enableTexture2d(true);
float rmag = big3dModelHaloRadius*(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.0f)
{
cmag = qMax(0.f, 1.f-(pixRadius*3.f+100-rmag)/100); cmag = qMax(0.f, 1.f-(pixRadius*3.f+100-rmag)/100);
painter->getProjector()->project(v, win); }
Vec3d win;
projector->project(v, win);
Vec3f c = color; Vec3f c = color;
if (StelApp::getInstance().getVisionModeNight()) if (StelApp::getInstance().getVisionModeNight())
c = StelUtils::getNightColor(c); c = StelUtils::getNightColor(c);
painter->setColor(c[0]*cmag, c[1]*cmag, c[2]*cmag); addStar(sunHaloBuffer, win[0], win[1], rmag, c * cmag);
painter->drawSprite2dMode(win[0], win[1], rmag);
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 659 skipping to change at line 541
float wl = findWorldLumForMag(mag, rcm[0]); float wl = findWorldLumForMag(mag, rcm[0]);
if (wl>0) if (wl>0)
{ {
const float f = core->getMovementMgr()->getCurrentFo v(); const float f = core->getMovementMgr()->getCurrentFo v();
reportLuminanceInFov(qMin(700.f, qMin(wl/50, (60.f*6 0.f)/(f*f)*6.f))); reportLuminanceInFov(qMin(700.f, qMin(wl/50, (60.f*6 0.f)/(f*f)*6.f)));
} }
} }
if (!noStarHalo) if (!noStarHalo)
{ {
preDrawPointSource(painter); preDrawPointSource();
drawPointSource(painter, v,rcm,color); const Vec3f vf(v[0], v[1], v[2]);
postDrawPointSource(painter); Vec3f win;
if(pointSourceVisible(&(*projector), vf, rcm, false, win))
{
drawPointSource(win, rcm, color);
}
postDrawPointSource(projector);
} }
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;
 End of changes. 40 change blocks. 
310 lines changed or deleted 181 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/