Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Data::EnvironmentTexture Class Reference

Defines a spherical, infinite light sources and, optionally, sky boxes. An operator to convert an EnvironmentTexture to SH matrices for irradiance mapping is defined. An operator to draw a textured sky box is defined. More...

#include <Engine/Data/EnvironmentTexture.hpp>

+ Collaboration diagram for Ra::Engine::Data::EnvironmentTexture:

Public Types

enum class  EnvMapType { ENVMAP_PFM , ENVMAP_CUBE , ENVMAP_LATLON }
 Environment map type inferred from file names and format. Supported environment type. More...
 

Public Member Functions

const std::stringgetImageName () const
 Get the name used to construct the environment texture.
 
EnvMapType getImageType () const
 Get the type of the environment texture.
 
void saveShProjection (const std::string &filename)
 Saves the spherical image representing the SH-encoded envmap.
 
const Ra::Core::Matrix4 & getShMatrix (int channel)
 Return the SH Matrix corresponding to the given color channel. The SH matrix is computed according to the paper An Efficient Representation for Irradiance Environment Maps, Ramamoorthi, Ravi and Hanrahan, Pat SIGGRAPH 2001 https://doi.org/10.1145/383259.383317.
 
void render (const Ra::Engine::Data::ViewingParameters &viewParams)
 Render the envmap as a textured cube. This method does nothing if the envmap is not a skybox.
 
void setSkybox (bool state)
 Set the state of the skybox.
 
void setStrength (float s)
 Set the multiplicative factor which defined the power of the light source.
 
float getStrength () const
 Get the multiplicative factor which defined the power of the light source.
 
bool isSkybox () const
 
Ra::Engine::Data::TexturegetEnvironmentTexture ()
 
void updateGL ()
 Update the OpenGL state of the envmap : texture, skybox and shaders if needed.
 
 EnvironmentTexture (const std::string &mapName, bool isSkybox=false)
 Construct an envmap from a file. Supported image component of the envmap are the following.
 
 EnvironmentTexture (const EnvironmentTexture &)=delete
 
EnvironmentTextureoperator= (const EnvironmentTexture &)=delete
 
 EnvironmentTexture (EnvironmentTexture &&)=default
 
EnvironmentTextureoperator= (EnvironmentTexture &&)=default
 
 ~EnvironmentTexture ()=default
 destructor
 

Detailed Description

Defines a spherical, infinite light sources and, optionally, sky boxes. An operator to convert an EnvironmentTexture to SH matrices for irradiance mapping is defined. An operator to draw a textured sky box is defined.

Definition at line 19 of file EnvironmentTexture.hpp.

Member Enumeration Documentation

◆ EnvMapType

Environment map type inferred from file names and format. Supported environment type.

Definition at line 31 of file EnvironmentTexture.hpp.

Constructor & Destructor Documentation

◆ EnvironmentTexture()

Ra::Engine::Data::EnvironmentTexture::EnvironmentTexture ( const std::string & mapName,
bool isSkybox = false )
explicit

Construct an envmap from a file. Supported image component of the envmap are the following.

Constructors and destructor follow the 'rule of five' https://en.cppreference.com/w/cpp/language/rule_of_three

  • a pfm file for cross cubemap
  • a list of image files for individual cube map faces (see below for naming convention).
  • a single png, exr, hdr, jpg file for Spherical equirectangular envmap
    See also
    EnvMapType
    If the cubemap is defined by a list of files, they must be named according to the corresponding face of the cube : posx or -X-plux : +X face of the cube
    negx or -X-minux : -X face of the cube
    posy or -Y-plux : +Y face of the cube
    negy or -Y-minux : -Y face of the cube
    posz or -Z-plux : +Z face of the cube
    negz or -Z-minux : -Z face of the cube
    Parameters
    mapNameThe list of filenames
    typeThe file type. Supported file types are PFM for single files or whatever is supported by stb for per-face files.
    isSkyboxindicates if the envmap must be associated with a skybox and rendered like this.
    Note
    The envmap is transformed at loading/build time to the Radium global frame.
    Precondition
    The file(s) given as mapName must exist.
    Todo
    : if the file given to the constructor does not exist, generates a white envmap ?

Definition at line 146 of file EnvironmentTexture.cpp.

Member Function Documentation

◆ getEnvironmentTexture()

Ra::Engine::Data::Texture * Ra::Engine::Data::EnvironmentTexture::getEnvironmentTexture ( )
Returns
the prefiltered cubemap texture defining the environment
Note
Prefiltering is made using standard mip-mapping.
Todo
Prefilter according to bsdf roughness values ? This will help for envmap lighting but might be wrong for skybox rendering

Definition at line 732 of file EnvironmentTexture.cpp.

◆ getImageName()

const std::string & Ra::Engine::Data::EnvironmentTexture::getImageName ( ) const
inline

Get the name used to construct the environment texture.

Returns
The file name, possibly ';' separated list of names, of the environment texture.

Definition at line 78 of file EnvironmentTexture.hpp.

◆ getImageType()

EnvMapType Ra::Engine::Data::EnvironmentTexture::getImageType ( ) const
inline

Get the type of the environment texture.

See also
EnvMapType
Returns
The type of the environment texture

Definition at line 84 of file EnvironmentTexture.hpp.

◆ getShMatrix()

const Ra::Core::Matrix4 & Ra::Engine::Data::EnvironmentTexture::getShMatrix ( int channel)

Return the SH Matrix corresponding to the given color channel. The SH matrix is computed according to the paper An Efficient Representation for Irradiance Environment Maps, Ramamoorthi, Ravi and Hanrahan, Pat SIGGRAPH 2001 https://doi.org/10.1145/383259.383317.

Parameters
channelThe number of the color channel (red = 0, green = 1, blue = 2)
Returns
the SH irradiance matrix for the channel

Definition at line 649 of file EnvironmentTexture.cpp.

◆ getStrength()

float Ra::Engine::Data::EnvironmentTexture::getStrength ( ) const

Get the multiplicative factor which defined the power of the light source.

Returns
the envmap power

Definition at line 728 of file EnvironmentTexture.cpp.

◆ isSkybox()

bool Ra::Engine::Data::EnvironmentTexture::isSkybox ( ) const
inline
Returns
true if the envmap is a skybox and might be rendered.

Definition at line 132 of file EnvironmentTexture.hpp.

◆ render()

void Ra::Engine::Data::EnvironmentTexture::render ( const Ra::Engine::Data::ViewingParameters & viewParams)

Render the envmap as a textured cube. This method does nothing if the envmap is not a skybox.

Parameters
viewParamsThe viewing parameter used to draw the scene

Definition at line 695 of file EnvironmentTexture.cpp.

+ Here is the call graph for this function:

◆ saveShProjection()

void Ra::Engine::Data::EnvironmentTexture::saveShProjection ( const std::string & filename)

Saves the spherical image representing the SH-encoded envmap.

Parameters
filenamethe file to write, in any format supported by stb library

Definition at line 643 of file EnvironmentTexture.cpp.

◆ setSkybox()

void Ra::Engine::Data::EnvironmentTexture::setSkybox ( bool state)
inline

Set the state of the skybox.

Parameters
statetrue to enable skybox rendering, false to just use the SH coefficients

Definition at line 115 of file EnvironmentTexture.hpp.

◆ setStrength()

void Ra::Engine::Data::EnvironmentTexture::setStrength ( float s)

Set the multiplicative factor which defined the power of the light source.

Parameters
sthe envmap power

Definition at line 724 of file EnvironmentTexture.cpp.

◆ updateGL()

void Ra::Engine::Data::EnvironmentTexture::updateGL ( )

Update the OpenGL state of the envmap : texture, skybox and shaders if needed.

Definition at line 653 of file EnvironmentTexture.cpp.

+ Here is the call graph for this function:

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