Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnvironmentTexture.hpp
1#pragma once
2#include <Core/Types.hpp>
3#include <Engine/Data/Mesh.hpp>
4#include <Engine/Data/Texture.hpp>
5#include <Engine/RaEngine.hpp>
6
7#include <array>
8#include <memory>
9#include <string>
10
11namespace Ra {
12namespace Engine {
13namespace Data {
14class ShaderProgram;
15struct ViewingParameters;
16
20class RA_ENGINE_API EnvironmentTexture
21{
22 public:
32 enum class EnvMapType { ENVMAP_PFM, ENVMAP_CUBE, ENVMAP_LATLON };
66 explicit EnvironmentTexture( const std::string& mapName, bool isSkybox = false );
67 EnvironmentTexture( const EnvironmentTexture& ) = delete;
68 EnvironmentTexture& operator=( const EnvironmentTexture& ) = delete;
70 EnvironmentTexture& operator=( EnvironmentTexture&& ) = default;
79 inline const std::string& getImageName() const { return m_name; }
85 inline EnvMapType getImageType() const { return m_type; }
86
91 void saveShProjection( const std::string& filename );
92
104 const Ra::Core::Matrix4& getShMatrix( int channel );
105
110 void render( const Ra::Engine::Data::ViewingParameters& viewParams );
111
116 inline void setSkybox( bool state ) { m_isSkyBox = state; }
117
122 void setStrength( float s );
123
128 float getStrength() const;
129
133 inline bool isSkybox() const { return m_isSkyBox; }
134
141 Ra::Engine::Data::Texture* getEnvironmentTexture();
142
146 void updateGL();
147
148 private:
150 void initializeTexture();
151
153 void setupTexturesFromPfm();
155 void setupTexturesFromCube();
157 void setupTexturesFromSphericalEquiRectangular();
158
161 void computeSHMatrices();
162
169 void updateCoeffs( float* hdr, float x, float y, float z, float domega );
170 float* getPixel( float x, float y, float z );
171 void tomatrix();
172 Ra::Engine::Data::Texture* getSHImage();
173
174 std::string m_name;
175 EnvMapType m_type;
176
177 // The raw pixel values of the envmap
179 size_t m_width { 0 };
180 size_t m_height { 0 };
181 float m_shcoefs[9][3];
182 Ra::Core::Matrix4 m_shMatrices[3];
183 std::unique_ptr<Ra::Engine::Data::Texture> m_shtexture { nullptr };
185 bool m_isSkyBox { false };
187 std::unique_ptr<Ra::Engine::Data::Mesh> m_displayMesh { nullptr };
189 std::unique_ptr<Ra::Engine::Data::Texture> m_skyTexture { nullptr };
191 float m_environmentStrength { 1 };
193 const Ra::Engine::Data::ShaderProgram* m_skyShader { nullptr };
194 bool m_glReady { false };
195};
196
197} // namespace Data
198} // namespace Engine
199} // namespace Ra
Defines a spherical, infinite light sources and, optionally, sky boxes. An operator to convert an Env...
void setSkybox(bool state)
Set the state of the skybox.
const std::string & getImageName() const
Get the name used to construct the environment texture.
~EnvironmentTexture()=default
destructor
EnvMapType
Environment map type inferred from file names and format. Supported environment type.
EnvMapType getImageType() const
Get the type of the environment texture.
Represent a Texture of the engine.
Definition Texture.hpp:120
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:4
the set of viewing parameters extracted from the camera and given to the renderer