Stellarium 0.13.0
Atmosphere.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2003 Fabien Chereau
4  * Copyright (C) 2012 Timothy Reaves
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _ATMOSTPHERE_HPP_
22 #define _ATMOSTPHERE_HPP_
23 
24 #include "Skylight.hpp"
25 #include "VecMath.hpp"
26 
27 #include "Skybright.hpp"
28 #include "StelFader.hpp"
29 
30 #include <QOpenGLBuffer>
31 
32 class StelProjector;
33 class StelToneReproducer;
34 class StelCore;
35 
40 {
41 public:
42  Atmosphere();
43  virtual ~Atmosphere();
44 
45  void computeColor(double JD, Vec3d _sunPos, Vec3d moonPos, float moonPhase, StelCore* core,
46  float latitude = 45.f, float altitude = 200.f,
47  float temperature = 15.f, float relativeHumidity = 40.f);
48  void draw(StelCore* core);
49  void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
50 
52  void setFadeDuration(float duration) {fader.setDuration((int)(duration*1000.f));}
54  float getFadeDuration() {return (float)fader.getDuration()/1000.f;}
55 
57  void setFlagShow(bool b){fader = b;}
59  bool getFlagShow() const {return fader;}
60 
63  float getRealDisplayIntensityFactor() const {return fader.getInterstate()*eclipseFactor;}
64 
65  // let's you know how far faded in or out the atm is (0-1)
66  float getFadeIntensity() const {return fader.getInterstate();}
67 
72  float getAverageLuminance() const {return averageLuminance;}
73 
75  void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
77  float getLightPollutionLuminance() const { return lightPollutionLuminance; }
78 
79 private:
80  Vec4i viewport;
81  Skylight sky;
82  Skybright skyb;
83  int skyResolutionY,skyResolutionX;
84 
85  Vec2f* posGrid;
86  QOpenGLBuffer posGridBuffer;
87  QOpenGLBuffer indicesBuffer;
88  Vec4f* colorGrid;
89  QOpenGLBuffer colorGridBuffer;
90 
92  float averageLuminance;
93  float eclipseFactor;
94  LinearFader fader;
95  float lightPollutionLuminance;
96 
98  class QOpenGLShaderProgram* atmoShaderProgram;
99  struct {
100  int alphaWaOverAlphaDa;
101  int oneOverGamma;
102  int term2TimesOneOverMaxdLpOneOverGamma;
103  int brightnessScale;
104  int sunPos;
105  int term_x, Ax, Bx, Cx, Dx, Ex;
106  int term_y, Ay, By, Cy, Dy, Ey;
107  int projectionMatrix;
108  int skyVertex;
109  int skyColor;
110  } shaderAttribLocations;
111 };
112 
113 #endif // _ATMOSTPHERE_HPP_
void setFlagShow(bool b)
Define whether to display atmosphere.
Definition: Atmosphere.hpp:57
float getRealDisplayIntensityFactor() const
Get the actual atmosphere intensity due to eclipses + fader.
Definition: Atmosphere.hpp:63
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:79
Compute and display the daylight sky color using openGL.
Definition: Atmosphere.hpp:39
bool getFlagShow() const
Get whether atmosphere is displayed.
Definition: Atmosphere.hpp:59
void setLightPollutionLuminance(float f)
Set the light pollution luminance in cd/m^2.
Definition: Atmosphere.hpp:75
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
Converts tones in function of the eye adaptation to luminance.
float getLightPollutionLuminance() const
Get the light pollution luminance in cd/m^2.
Definition: Atmosphere.hpp:77
float getFadeDuration()
Get fade in/out duration in seconds.
Definition: Atmosphere.hpp:54
Provide the main interface to all operations of projecting coordinates from sky to screen...
A templatized 4d vector compatible with openGL.
Definition: VecMath.hpp:34
This class makes use of the 1998 sky brightness model by Bradley Schaefer.
Definition: Skybright.hpp:39
void setFadeDuration(float duration)
Set fade in/out duration in seconds.
Definition: Atmosphere.hpp:52
float getAverageLuminance() const
Get the average luminance of the atmosphere in cd/m2 If atmosphere is off, the luminance includes the...
Definition: Atmosphere.hpp:72