CalcMySky  v0.1.0
AtmosphereRenderer.hpp
Go to the documentation of this file.
1 #ifndef INCLUDE_ONCE_02040F35_0604_4759_A47D_71849AAC953D
2 #define INCLUDE_ONCE_02040F35_0604_4759_A47D_71849AAC953D
3 
6 #include <memory>
7 #include <functional>
8 
9 #include <QObject>
10 #include <QVector4D>
11 #include <qopengl.h>
12 
13 #include "Settings.hpp"
14 #include "Exception.hpp"
15 
17 #ifdef SHOWMYSKY_COMPILING_SHARED_LIB
18 # define SHOWMYSKY_DLL_PUBLIC Q_DECL_EXPORT
19 #elif defined SHOWMYSKY_COMPILING_CALCMYSKY
20 # define SHOWMYSKY_DLL_PUBLIC
21 #else
22 # define SHOWMYSKY_DLL_PUBLIC Q_DECL_IMPORT
23 #endif
24 
27 class QString;
28 class QOpenGLShaderProgram;
29 class QOpenGLFunctions_3_3_Core;
30 
31 namespace ShowMySky
32 {
33 
35 {
36 public:
41  {
42  std::vector<float> wavelengths;
43  std::vector<float> radiances;
44 
45  float azimuth;
46  float elevation;
47 
49  unsigned size() const { return wavelengths.size(); }
51  bool empty() const { return wavelengths.empty(); }
52  };
53 
57  struct Direction
58  {
59  float azimuth;
60  float elevation;
61  };
62 
67  {
68  int stepsDone;
69  int stepsToDo;
70  };
71 
72 public:
84  virtual void setDrawSurfaceCallback(std::function<void(QOpenGLShaderProgram& shprog)> const& drawSurface) = 0;
97  virtual int initDataLoading(QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc,
98  std::vector<std::pair<std::string,GLuint>> viewDirBindAttribLocations={}) = 0;
105  virtual LoadingStatus stepDataLoading() = 0;
119  virtual int initPreparationToDraw() = 0;
126  virtual LoadingStatus stepPreparationToDraw() = 0;
132  virtual QString currentActivity() const = 0;
137  virtual bool isReadyToRender() const = 0;
142  virtual bool isLoading() const = 0;
147  virtual bool canGrabRadiance() const = 0;
152  virtual bool canSetSolarSpectrum() const = 0;
160  virtual bool canRenderPrecomputedEclipsedDoubleScattering() const = 0;
168  virtual GLuint getLuminanceTexture() = 0;
177  virtual void draw(double brightness, bool clear) = 0;
186  virtual void resizeEvent(int width, int height) = 0;
198  virtual QVector4D getPixelLuminance(QPoint const& pixelPos) = 0;
207  virtual SpectralRadiance getPixelSpectralRadiance(QPoint const& pixelPos) = 0;
212  virtual std::vector<float> getWavelengths() = 0;
222  virtual void setSolarSpectrum(std::vector<float> const& spectralIrradianceAtTOA) = 0;
228  virtual void resetSolarSpectrum() = 0;
237  virtual Direction getViewDirection(QPoint const& pixelPos) = 0;
238 
239  virtual ~AtmosphereRenderer() = default;
240 
248  virtual int initShaderReloading() = 0;
254  virtual LoadingStatus stepShaderReloading() = 0;
265  virtual void setScattererEnabled(QString const& name, bool enable) = 0;
266 };
267 
268 }
269 
270 extern "C"
271 {
279 SHOWMYSKY_DLL_PUBLIC ShowMySky::AtmosphereRenderer*
280  ShowMySky_AtmosphereRenderer_create(QOpenGLFunctions_3_3_Core* gl,
281  QString const* pathToData,
282  ShowMySky::Settings* tools,
283  std::function<void(QOpenGLShaderProgram&)> const* drawSurface);
291 #define ShowMySky_ABI_version (13+QT_VERSION_MAJOR*100000000u)
292 
298 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
299 # define SHOWMYSKY_LIB_NAME "ShowMySky-Qt5"
300 #else
301 # define SHOWMYSKY_LIB_NAME "ShowMySky-Qt6"
302 #endif
303 }
304 
305 #endif
virtual bool canGrabRadiance() const =0
Tell whether radiance of a pixel can be queried.
virtual int initPreparationToDraw()=0
Initialize step-by-step process of preparation to render.
virtual void resetSolarSpectrum()=0
Reset solar spectrum to the default.
Scene settings for AtmosphereRenderer.
Definition: Settings.hpp:9
virtual bool canSetSolarSpectrum() const =0
Tell whether solar spectrum can be changed.
Definition: AtmosphereRenderer.hpp:34
virtual void draw(double brightness, bool clear)=0
Do the drawing.
virtual LoadingStatus stepPreparationToDraw()=0
Perform a single step of preparation to draw.
virtual SpectralRadiance getPixelSpectralRadiance(QPoint const &pixelPos)=0
Get spectral radiance of a pixel.
virtual LoadingStatus stepDataLoading()=0
Perform a single step of data loading.
virtual LoadingStatus stepShaderReloading()=0
Perform a single step of reloading of shaders.
Status of data loading process.
Definition: AtmosphereRenderer.hpp:66
float azimuth
Azimuth from which this radiance was measured, in degrees.
Definition: AtmosphereRenderer.hpp:45
virtual void setDrawSurfaceCallback(std::function< void(QOpenGLShaderProgram &shprog)> const &drawSurface)=0
Set the callback that will draw the screen surface.
float elevation
View elevation angle, in degrees.
Definition: AtmosphereRenderer.hpp:60
virtual Direction getViewDirection(QPoint const &pixelPos)=0
Get view direction of a pixel.
virtual void setSolarSpectrum(std::vector< float > const &spectralIrradianceAtTOA)=0
Set a custom solar spectrum.
virtual QVector4D getPixelLuminance(QPoint const &pixelPos)=0
Get luminance of a pixel.
int stepsDone
Number of steps done.
Definition: AtmosphereRenderer.hpp:68
float elevation
Elevation angle from which this radiance was measured, in degrees.
Definition: AtmosphereRenderer.hpp:46
virtual bool isLoading() const =0
Tell whether the renderer is in process of loading data.
unsigned size() const
Number of points in the spectrum.
Definition: AtmosphereRenderer.hpp:49
virtual int initShaderReloading()=0
Initialize step-by-step process of reloading of shaders.
virtual void setScattererEnabled(QString const &name, bool enable)=0
Enable or disable a single-scattering layer.
SHOWMYSKY_DLL_PUBLIC ShowMySky::AtmosphereRenderer * ShowMySky_AtmosphereRenderer_create(QOpenGLFunctions_3_3_Core *gl, QString const *pathToData, ShowMySky::Settings *tools, std::function< void(QOpenGLShaderProgram &)> const *drawSurface)
Entry point for the creator of AtmosphereRenderer.
Definition: AtmosphereRenderer.cpp:12
std::vector< float > radiances
Spectral radiance in .
Definition: AtmosphereRenderer.hpp:43
virtual bool canRenderPrecomputedEclipsedDoubleScattering() const =0
Tell whether precomputed eclipsed double scattering can be rendered.
bool empty() const
true if the spectrum has no points.
Definition: AtmosphereRenderer.hpp:51
virtual bool isReadyToRender() const =0
Tell whether the renderer is ready for a draw call.
virtual void resizeEvent(int width, int height)=0
Update render target size.
virtual int initDataLoading(QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc, std::vector< std::pair< std::string, GLuint >> viewDirBindAttribLocations={})=0
Initialize step-by-step process of loading of data.
float azimuth
View azimuth, in degrees.
Definition: AtmosphereRenderer.hpp:59
Spectral radiance of a pixel.
Definition: AtmosphereRenderer.hpp:40
virtual GLuint getLuminanceTexture()=0
Get OpenGL name of the luminance render target.
View direction of a pixel.
Definition: AtmosphereRenderer.hpp:57
virtual std::vector< float > getWavelengths()=0
Get the wavelengths used in computations.
virtual QString currentActivity() const =0
Get a string describing current activity.
std::vector< float > wavelengths
Wavelengths in nanometers.
Definition: AtmosphereRenderer.hpp:42
int stepsToDo
Total number of steps to do. Negative in case of error (e.g. when a step function was called at inapp...
Definition: AtmosphereRenderer.hpp:69