Radium Engine  1.5.20
Loading...
Searching...
No Matches
EnvironmentTexture.hpp
1#pragma once
2#include <Engine/RaEngine.hpp>
3
4#include <Core/Types.hpp>
5#include <Engine/Data/Mesh.hpp>
6#include <Engine/Data/Texture.hpp>
7
8#include <string>
9
10namespace Ra {
11namespace Engine {
12namespace Data {
13class ShaderProgram;
14struct ViewingParameters;
15
19class RA_ENGINE_API EnvironmentTexture
20{
21 public:
31 enum class EnvMapType { ENVMAP_PFM, ENVMAP_CUBE, ENVMAP_LATLON };
65 explicit EnvironmentTexture( const std::string& mapName, bool isSkybox = false );
66 EnvironmentTexture( const EnvironmentTexture& ) = delete;
67 EnvironmentTexture& operator=( const EnvironmentTexture& ) = delete;
69 EnvironmentTexture& operator=( EnvironmentTexture&& ) = default;
78 inline const std::string& getImageName() const { return m_name; }
84 inline EnvMapType getImageType() const { return m_type; }
85
90 void saveShProjection( const std::string& filename );
91
103 const Ra::Core::Matrix4& getShMatrix( int channel );
104
109 void render( const Ra::Engine::Data::ViewingParameters& viewParams );
110
115 inline void setSkybox( bool state ) { m_isSkyBox = state; }
116
121 void setStrength( float s );
122
127 float getStrength() const;
128
132 inline bool isSkybox() const { return m_isSkyBox; }
133
140 Ra::Engine::Data::Texture* getEnvironmentTexture();
141
145 void updateGL();
146
147 private:
149 void initializeTexture();
150
152 void setupTexturesFromPfm();
154 void setupTexturesFromCube();
156 void setupTexturesFromSphericalEquiRectangular();
157
160 void computeSHMatrices();
161
168 void updateCoeffs( float* hdr, float x, float y, float z, float domega );
169 float* getPixel( float x, float y, float z );
170 void tomatrix();
171 Ra::Engine::Data::Texture* getSHImage();
172
173 std::string m_name;
174 EnvMapType m_type;
175
176 // The raw pixel values of the envmap
178 size_t m_width { 0 };
179 size_t m_height { 0 };
180 float m_shcoefs[9][3];
181 Ra::Core::Matrix4 m_shMatrices[3];
182 std::unique_ptr<Ra::Engine::Data::Texture> m_shtexture { nullptr };
184 bool m_isSkyBox { false };
186 std::unique_ptr<Ra::Engine::Data::Mesh> m_displayMesh { nullptr };
188 std::unique_ptr<Ra::Engine::Data::Texture> m_skyTexture { nullptr };
190 float m_environmentStrength { 1 };
192 const Ra::Engine::Data::ShaderProgram* m_skyShader { nullptr };
193 bool m_glReady { false };
194};
195
196} // namespace Data
197} // namespace Engine
198} // 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:3
the set of viewing parameters extracted from the camera and given to the renderer