CalcMySky  v0.3.1
Classes | Public Member Functions | List of all members
ShowMySky::AtmosphereRenderer Class Referenceabstract
Inheritance diagram for ShowMySky::AtmosphereRenderer:
AtmosphereRenderer

Classes

struct  Direction
 View direction of a pixel. More...
 
struct  LoadingStatus
 Status of data loading process. More...
 
struct  SpectralRadiance
 Spectral radiance of a pixel. More...
 

Public Member Functions

virtual void setDrawSurfaceCallback (std::function< void(QOpenGLShaderProgram &shprog)> const &drawSurface)=0
 Set the callback that will draw the screen surface. More...
 
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. More...
 
virtual void setViewDirShaders (QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc, std::vector< std::pair< std::string, GLuint >> viewDirBindAttribLocations={})=0
 Replace the current view direction shaders with a new set. More...
 
virtual LoadingStatus stepDataLoading ()=0
 Perform a single step of data loading. More...
 
virtual int initPreparationToDraw ()=0
 Initialize step-by-step process of preparation to render. More...
 
virtual LoadingStatus stepPreparationToDraw ()=0
 Perform a single step of preparation to draw. More...
 
virtual QString currentActivity () const =0
 Get a string describing current activity. More...
 
virtual bool isReadyToRender () const =0
 Tell whether the renderer is ready for a draw call. More...
 
virtual bool isLoading () const =0
 Tell whether the renderer is in process of loading data. More...
 
virtual bool canGrabRadiance () const =0
 Tell whether radiance of a pixel can be queried. More...
 
virtual bool canSetSolarSpectrum () const =0
 Tell whether solar spectrum can be changed. More...
 
virtual bool canRenderPrecomputedEclipsedDoubleScattering () const =0
 Tell whether precomputed eclipsed double scattering can be rendered. More...
 
virtual GLuint getLuminanceTexture ()=0
 Get OpenGL name of the luminance render target. More...
 
virtual void draw (double brightness, bool clear)=0
 Do the drawing. More...
 
virtual void resizeEvent (int width, int height)=0
 Update render target size. More...
 
virtual QVector4D getPixelLuminance (QPoint const &pixelPos)=0
 Get luminance of a pixel. More...
 
virtual SpectralRadiance getPixelSpectralRadiance (QPoint const &pixelPos)=0
 Get spectral radiance of a pixel. More...
 
virtual std::vector< float > getWavelengths ()=0
 Get the wavelengths used in computations. More...
 
virtual void setSolarSpectrum (std::vector< float > const &spectralIrradianceAtTOA)=0
 Set a custom solar spectrum. More...
 
virtual void resetSolarSpectrum ()=0
 Reset solar spectrum to the default. More...
 
virtual Direction getViewDirection (QPoint const &pixelPos)=0
 Get view direction of a pixel. More...
 
virtual int initShaderReloading ()=0
 Initialize step-by-step process of reloading of shaders. More...
 
virtual LoadingStatus stepShaderReloading ()=0
 Perform a single step of reloading of shaders. More...
 
virtual void setScattererEnabled (QString const &name, bool enable)=0
 Enable or disable a single-scattering layer. More...
 

Member Function Documentation

◆ canGrabRadiance()

virtual bool ShowMySky::AtmosphereRenderer::canGrabRadiance ( ) const
pure virtual
Returns
Whether radiance of a pixel can be queried by a call to getPixelSpectralRadiance.

Implemented in AtmosphereRenderer.

◆ canRenderPrecomputedEclipsedDoubleScattering()

virtual bool ShowMySky::AtmosphereRenderer::canRenderPrecomputedEclipsedDoubleScattering ( ) const
pure virtual

The calcmysky utility has an option to disable generation of the texture for second-order scattering during solar eclipse. If this option was used for generation of the current atmosphere model, this function will return false. In this case, it is only valid for ShowMySky::Settings::multipleScatteringEnabled to return true either with ShowMySky::Settings::onTheFlyPrecompDoubleScatteringEnabled returning true, or ShowMySky::Settings::usingEclipseShader returning false.

Returns
Whether precomputed eclipsed double scattering can be rendered.

Implemented in AtmosphereRenderer.

◆ canSetSolarSpectrum()

virtual bool ShowMySky::AtmosphereRenderer::canSetSolarSpectrum ( ) const
pure virtual
Returns
Whether solar spectrum can be set by a call to setSolarSpectrum.

Implemented in AtmosphereRenderer.

◆ currentActivity()

virtual QString ShowMySky::AtmosphereRenderer::currentActivity ( ) const
pure virtual

This is a string intended for the user to see what's going on, e.g. "Loading textures and shaders...".

Implemented in AtmosphereRenderer.

◆ draw()

virtual void ShowMySky::AtmosphereRenderer::draw ( double  brightness,
bool  clear 
)
pure virtual

This is the method that performs all the drawing logic.

Parameters
brightnessrelative brightness of the scene. 0 effectively means draw nothing (or NaNs in case of broken textures or shaders), 1 means normal brightness.
clearwhether to clear the screen surface to zeros prior to drawing. This can be set to false to accumulate subsequent draws, and to true to draw the first render.

Implemented in AtmosphereRenderer.

◆ getLuminanceTexture()

virtual GLuint ShowMySky::AtmosphereRenderer::getLuminanceTexture ( )
pure virtual

This method returns the OpenGL name suitable for use with glBindTexture for the render target containing photopic and scotopic luminance values packed into vec4 pixels (see getPixelLuminance for details). This is the main output of draw that can be used to finally render the data to screen in the desired color space.

Returns
OpenGL name of the luminance render target.

Implemented in AtmosphereRenderer.

◆ getPixelLuminance()

virtual QVector4D ShowMySky::AtmosphereRenderer::getPixelLuminance ( QPoint const &  pixelPos)
pure virtual

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
pixelPospixel position in window coordinates: (0,0) corresponds to top-left point.
Returns
Luminance of the pixel specified.

Implemented in AtmosphereRenderer.

◆ getPixelSpectralRadiance()

virtual SpectralRadiance ShowMySky::AtmosphereRenderer::getPixelSpectralRadiance ( QPoint const &  pixelPos)
pure virtual

This method obtains spectral radiance of the pixel specified by pixelPos.

Parameters
pixelPospixel position in window coordinates: (0,0) corresponds to top-left point.
Returns
Spectral radiance of the pixel specified.

Implemented in AtmosphereRenderer.

◆ getViewDirection()

virtual Direction ShowMySky::AtmosphereRenderer::getViewDirection ( QPoint const &  pixelPos)
pure virtual

This method obtains view direction corresponding to the pixel specified by pixelPos.

Parameters
pixelPospixel position in window coordinates: (0,0) corresponds to top-left point.
Returns
View direction of the pixel specified.

Implemented in AtmosphereRenderer.

◆ getWavelengths()

virtual std::vector<float> ShowMySky::AtmosphereRenderer::getWavelengths ( )
pure virtual
Returns
All the wavelengths used in computations, in nanometers.

Implemented in AtmosphereRenderer.

◆ initDataLoading()

virtual int ShowMySky::AtmosphereRenderer::initDataLoading ( QByteArray  viewDirVertShaderSrc,
QByteArray  viewDirFragShaderSrc,
std::vector< std::pair< std::string, GLuint >>  viewDirBindAttribLocations = {} 
)
pure virtual

This method initializes the process of loading of shaders and textures for the current atmosphere model. The actual loading is done step-by-step by calling stepDataLoading.

The fragment shader viewDirFragShaderSrc passed here implements vec3 calcViewDir(void) function that is used as an application-agnostic way of determining view direction of the ray associated with a given fragment of the surface being rendered.

Parameters
viewDirVertShaderSrca vertex shader that will be used by all the shader programs that implement the atmosphere model;
viewDirFragShaderSrca fragment shader that implements calcViewDir function;
viewDirBindAttribLocationslocations of vertex attributes necessary to render the screen surface. Each pair consists of an attribute name and its location.
Returns
Total number of loading steps to complete the loading.

Implemented in AtmosphereRenderer.

◆ initPreparationToDraw()

virtual int ShowMySky::AtmosphereRenderer::initPreparationToDraw ( )
pure virtual

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.

Implemented in AtmosphereRenderer.

◆ initShaderReloading()

virtual int ShowMySky::AtmosphereRenderer::initShaderReloading ( )
pure virtual

This is a debug method. It initializes the process of reloading of shaders for the current atmosphere model. The actual reloading is done step-by-step by calling stepShaderReloading.

The reloading can be used to quickly update the current model when a shader has been edited or regenerated with another parameters.

Implemented in AtmosphereRenderer.

◆ isLoading()

virtual bool ShowMySky::AtmosphereRenderer::isLoading ( ) const
pure virtual
Returns
Whether the renderer is in process of loading data.

Implemented in AtmosphereRenderer.

◆ isReadyToRender()

virtual bool ShowMySky::AtmosphereRenderer::isReadyToRender ( ) const
pure virtual
Returns
Whether the renderer is ready to render via the draw method.

Implemented in AtmosphereRenderer.

◆ resetSolarSpectrum()

virtual void ShowMySky::AtmosphereRenderer::resetSolarSpectrum ( )
pure virtual

This method undoes what setSolarSpectrum did, returning the current spectrum to the one used by calcmysky utility when generating the textures.

Implemented in AtmosphereRenderer.

◆ resizeEvent()

virtual void ShowMySky::AtmosphereRenderer::resizeEvent ( int  width,
int  height 
)
pure virtual

This method should be called whenever the render target changes its size.

Parameters
widthwidth of the render target;
heightheight of the rener target.

Implemented in AtmosphereRenderer.

◆ setDrawSurfaceCallback()

virtual void ShowMySky::AtmosphereRenderer::setDrawSurfaceCallback ( std::function< void(QOpenGLShaderProgram &shprog)> const &  drawSurface)
pure virtual

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
drawSurfacethe callback that renders the surface.

Implemented in AtmosphereRenderer.

◆ setScattererEnabled()

virtual void ShowMySky::AtmosphereRenderer::setScattererEnabled ( QString const &  name,
bool  enable 
)
pure virtual

This is a debug option that lets one toggle a single-scattering layer associated with a particular scattering species.

This option doesn't affect transmittance of air, it only controls whether first-order inscattered light from the species specified is included in the render.

Parameters
namename of the species, as given in the Scatterer section of the model description file;
enablewhether first-order inscattered light from this species should be rendered.

Implemented in AtmosphereRenderer.

◆ setSolarSpectrum()

virtual void ShowMySky::AtmosphereRenderer::setSolarSpectrum ( std::vector< float > const &  spectralIrradianceAtTOA)
pure virtual

This method lets one change the solar spectrum that was used in computations by calcmysky utility, to aid easy switching between types of the illuminating star.

This method can only be called if canSetSolarSpectrum returns true.

Parameters
spectralIrradianceAtTOASpectral irradiance at the top of atmosphere (i.e. at the highest altitude for which the model has data), in \(\mathrm{\frac{W}{m^2\,sr\,nm}}\).

Implemented in AtmosphereRenderer.

◆ setViewDirShaders()

virtual void ShowMySky::AtmosphereRenderer::setViewDirShaders ( QByteArray  viewDirVertShaderSrc,
QByteArray  viewDirFragShaderSrc,
std::vector< std::pair< std::string, GLuint >>  viewDirBindAttribLocations = {} 
)
pure virtual

This method lets the user change the way view direction is computed (e.g. to switch projections). The new vertex and fragment shaders replace the old ones that initially are passed to initDataLoading. This action may take some time because it causes relinking of all the shader programs in use.

Parameters
viewDirVertShaderSrca vertex shader that will be used by all the shader programs that implement the atmosphere model;
viewDirFragShaderSrca fragment shader that implements calcViewDir function;
viewDirBindAttribLocationslocations of vertex attributes necessary to render the screen surface. Each pair consists of an attribute name and its location.

Implemented in AtmosphereRenderer.

◆ stepDataLoading()

virtual LoadingStatus ShowMySky::AtmosphereRenderer::stepDataLoading ( )
pure virtual

This method performs a single step of data loading.

Returns
Status of data loading process: progress, error indication.

Implemented in AtmosphereRenderer.

◆ stepPreparationToDraw()

virtual LoadingStatus ShowMySky::AtmosphereRenderer::stepPreparationToDraw ( )
pure virtual

This method performs a single step of preparation to draw started by initPreparationToDraw.

Returns
Status of preparation process: progress, error indication.

Implemented in AtmosphereRenderer.

◆ stepShaderReloading()

virtual LoadingStatus ShowMySky::AtmosphereRenderer::stepShaderReloading ( )
pure virtual

This is a debug method. It performs a single step of the process of reloading of shaders initialized by initShaderReloading.

Implemented in AtmosphereRenderer.


The documentation for this class was generated from the following file: