|
| AtmosphereRenderer (QOpenGLFunctions_3_3_Core &gl, QString const &pathToData, ShowMySky::Settings *tools, std::function< void(QOpenGLShaderProgram &shprog)> const &drawSurface) |
|
| AtmosphereRenderer (AtmosphereRenderer const &)=delete |
|
| AtmosphereRenderer (AtmosphereRenderer &&)=delete |
|
void | setDrawSurfaceCallback (std::function< void(QOpenGLShaderProgram &shprog)> const &drawSurface) override |
| Set the callback that will draw the screen surface. More...
|
|
int | initDataLoading (QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc, std::vector< std::pair< std::string, GLuint >> viewDirBindAttribLocations) override |
| Initialize step-by-step process of loading of data. More...
|
|
void | setViewDirShaders (QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc, std::vector< std::pair< std::string, GLuint >> viewDirBindAttribLocations) override |
| Replace the current view direction shaders with a new set. More...
|
|
LoadingStatus | stepDataLoading () override |
| Perform a single step of data loading. More...
|
|
int | initPreparationToDraw () override |
| Initialize step-by-step process of preparation to render. More...
|
|
LoadingStatus | stepPreparationToDraw () override |
| Perform a single step of preparation to draw. More...
|
|
QString | currentActivity () const override |
| Get a string describing current activity. More...
|
|
bool | isLoading () const override |
| Tell whether the renderer is in process of loading data. More...
|
|
bool | isReadyToRender () const override |
| Tell whether the renderer is ready for a draw call. More...
|
|
bool | canGrabRadiance () const override |
| Tell whether radiance of a pixel can be queried. More...
|
|
bool | canSetSolarSpectrum () const override |
| Tell whether solar spectrum can be changed. More...
|
|
bool | canRenderPrecomputedEclipsedDoubleScattering () const override |
| Tell whether precomputed eclipsed double scattering can be rendered. More...
|
|
GLuint | getLuminanceTexture () override |
| Get OpenGL name of the luminance render target. More...
|
|
void | draw (double brightness, bool clear) override |
| Do the drawing. More...
|
|
void | resizeEvent (int width, int height) override |
| Update render target size. More...
|
|
QVector4D | getPixelLuminance (QPoint const &pixelPos) override |
| Get luminance of a pixel. More...
|
|
SpectralRadiance | getPixelSpectralRadiance (QPoint const &pixelPos) override |
| Get spectral radiance of a pixel. More...
|
|
std::vector< float > | getWavelengths () override |
| Get the wavelengths used in computations. More...
|
|
void | setSolarSpectrum (std::vector< float > const &solarIrradianceAtTOA) override |
| Set a custom solar spectrum. More...
|
|
void | resetSolarSpectrum () override |
| Reset solar spectrum to the default. More...
|
|
Direction | getViewDirection (QPoint const &pixelPos) override |
| Get view direction of a pixel. More...
|
|
void | setScattererEnabled (QString const &name, bool enable) override |
| Enable or disable a single-scattering layer. More...
|
|
int | initShaderReloading () override |
| Initialize step-by-step process of reloading of shaders. More...
|
|
LoadingStatus | stepShaderReloading () override |
| Perform a single step of reloading of shaders. More...
|
|
AtmosphereParameters const & | atmosphereParameters () const |
|
AtmosphereRenderer::AtmosphereRenderer |
( |
QOpenGLFunctions_3_3_Core & |
gl, |
|
|
QString const & |
pathToData, |
|
|
ShowMySky::Settings * |
tools, |
|
|
std::function< void(QOpenGLShaderProgram &shprog)> const & |
drawSurface |
|
) |
| |
This is the constructor of the renderer. It saves the reference to gl
, tools
for later use (so these objects must outlive AtmosphereRenderer), also saves the drawSurface
callback. Then the model description file params.atmo
inside the directory pointed to pathToData
is parsed.
If an error occurs while parsing the model description file, ShowMySky::Error is thrown.
The callback function drawSurface
has one parameter: a shader program shprog
that includes, aside from the core atmosphere model GLSL code, the shaders viewDirVertShaderSrc
and viewDirFragShaderSrc
that have been passed to initDataLoading method (this should be done by the application before any other calls). By the point when this callback is called, shprog
has already been bound to current OpenGL context (via glUseProgram
).
The purpose of shprog
is to enable setting of the necessary uniform values via the glUniform*
family of functions to make the drawing work. It also includes the calcViewDir
function implemented in viewDirVertShaderSrc
shader, so the necessary uniform values (if any) for the operation of calcViewDir
should also to be set in this callback before issuing any draw calls.
To create an instance of AtmosphereRenderer indirectly having dlopen
ed the ShowMySky
library, use ShowMySky_AtmosphereRenderer_create.
- Parameters
-
gl | QtOpenGL-provided OpenGL 3.3 function resolver; |
pathToData | path to the data directory of the atmosphere model that contains params.atmo ; |
tools | pointer to an implementation of the ShowMySky::Settings interface; |
drawSurface | a callback function that will be called each time a surface is to be rendered. |
QVector4D AtmosphereRenderer::getPixelLuminance |
( |
QPoint const & |
pixelPos | ) |
|
|
overridevirtual |
This method obtains luminance of the pixel specified by pixelPos
. First three components of the 4D vector are the CIE 1931 tristimulus values in lumens, while the fourth one is the scotopic luminance in lumens (CIE 1951).
Maximum luminous efficacy is 683.002 lm/W for photopic values and 1700.13 lm/W for scotopic ones. Reference: Rapport BIPM-2019/05. Principles Governing Photometry, 2nd edition. Sections 6.2, 6.3.
- Parameters
-
pixelPos | pixel position in window coordinates: (0,0) corresponds to top-left point. |
- Returns
- Luminance of the pixel specified.
Implements ShowMySky::AtmosphereRenderer.
int AtmosphereRenderer::initPreparationToDraw |
( |
| ) |
|
|
overridevirtual |
The renderer loads different slices of textures depending on current scene parameters (e.g. altitude). Whenever such parameters change, it may become necessary to reload another slice.
The application might want to show a progress indicator for this reloading process. In this case, calling this method will initialize the process if it's needed and tell whether there's anything to do (return value is positive). If the return value is positive, stepPreparationToDraw should be called repeatedly until its return value indicates completion (or failure).
If there's no need for progress indication, this function (and stepPreparationToDraw) can be ignored. Otherwise, use this method to initialize the process of reloading data.
This method can also be called during the preparation to render to find out the number of steps to do.
- Returns
- Total number of loading steps to complete the preparation.
Implements ShowMySky::AtmosphereRenderer.
void AtmosphereRenderer::setDrawSurfaceCallback |
( |
std::function< void(QOpenGLShaderProgram &shprog)> const & |
drawSurface | ) |
|
|
overridevirtual |
This method sets a callback function that will be called each time a surface is to be rendered.
The callback has one parameter: a shader program shprog
that includes, aside from the core atmosphere model GLSL code, the shaders viewDirVertShaderSrc
and viewDirFragShaderSrc
that were passed to initDataLoading method (or to the constructor of AtmosphereRenderer). By the point when this callback is called, shprog
has already been bound to current OpenGL context (via glUseProgram
).
The purpose of shprog
is to enable setting of the necessary uniform values via the glUniform*
family of functions to make the drawing work. It also includes the calcViewDir
function implemented in viewDirVertShaderSrc
shader, so the necessary uniform values (if any) for the operation of calcViewDir
should also to be set in this callback before issuing any draw calls.
- Parameters
-
drawSurface | the callback that renders the surface. |
Implements ShowMySky::AtmosphereRenderer.