Stellarium 0.15.2
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  // lets you know how far faded in or out the atmosphere is (0..1)
66  float getFadeIntensity() const {return fader.getInterstate();}
67 
72  float getAverageLuminance() const {return averageLuminance;}
73 
76  void setAverageLuminance(float overrideLum);
78  void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
80  float getLightPollutionLuminance() const { return lightPollutionLuminance; }
81 
82 private:
83  Vec4i viewport;
84  Skylight sky;
85  Skybright skyb;
86  int skyResolutionY,skyResolutionX;
87 
88  Vec2f* posGrid;
89  QOpenGLBuffer posGridBuffer;
90  QOpenGLBuffer indicesBuffer;
91  Vec4f* colorGrid;
92  QOpenGLBuffer colorGridBuffer;
93 
95  float averageLuminance;
96  bool overrideAverageLuminance; // if true, don't compute but keep value set via setAverageLuminance(float)
97  float eclipseFactor;
98  LinearFader fader;
99  float lightPollutionLuminance;
100 
102  class QOpenGLShaderProgram* atmoShaderProgram;
103  struct {
104  int alphaWaOverAlphaDa;
105  int oneOverGamma;
106  int term2TimesOneOverMaxdLpOneOverGamma;
107  int brightnessScale;
108  int sunPos;
109  int term_x, Ax, Bx, Cx, Dx, Ex;
110  int term_y, Ay, By, Cy, Dy, Ey;
111  int projectionMatrix;
112  int skyVertex;
113  int skyColor;
114  } shaderAttribLocations;
115 };
116 
117 #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:77
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:78
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
A templatized 2d vector compatible with openGL.
Definition: VecMath.hpp:32
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:80
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...
This class makes use of the 1998 sky brightness model by Bradley Schaefer.
Definition: Skybright.hpp:40
void setAverageLuminance(float overrideLum)
override computable luminance.
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