SuperTuxKart
Loading...
Searching...
No Matches
spherical_harmonics.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2015 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19#ifndef HEADER_SPHERICAL_HARMONICS_HPP
20#define HEADER_SPHERICAL_HARMONICS_HPP
21
22#include <ITexture.h>
23#include <vector>
24
25struct Color
26{
27 float Red;
28 float Green;
29 float Blue;
30};
31
33{
34 float blue_SH_coeff[9];
35 float green_SH_coeff[9];
36 float red_SH_coeff[9];
37};
38
39
41{
42private:
44 std::vector<irr::video::IImage *> m_spherical_harmonics_textures;
45
47 irr::video::SColor m_ambient;
48
51
52 void generateSphericalHarmonics(unsigned char *sh_rgba[6], unsigned int edge_size);
53
54public:
55 SphericalHarmonics(const std::vector<irr::video::IImage *> &spherical_harmonics_textures);
56 SphericalHarmonics(const irr::video::SColor &ambient);
58
59 void setTextures(const std::vector<irr::video::IImage *> &spherical_harmonics_textures);
60 void setAmbientLight(const irr::video::SColor &ambient);
61
62 inline const SHCoefficients* getCoefficients() const { return m_SH_coeff; }
63
64 inline bool has6Textures() const {return m_spherical_harmonics_textures.size()==6;}
65
66 void printCoeff();
67
68 void unprojectSH (unsigned int width, unsigned int height,
69 float *Y00[], float *Y1minus1[], float *Y10[],
70 float *Y11[], float *Y2minus2[], float *Y2minus1[],
71 float * Y20[], float *Y21[], float *Y22[],
72 float *output[]);
73};
74
75#endif //HEADER_SPHERICAL_HARMONICS_HPP
Definition: spherical_harmonics.hpp:41
void setTextures(const std::vector< irr::video::IImage * > &spherical_harmonics_textures)
Compute spherical harmonics coefficients from 6 textures.
Definition: spherical_harmonics.cpp:540
void printCoeff()
Print spherical harmonics coefficients (debug)
Definition: spherical_harmonics.cpp:619
irr::video::SColor m_ambient
Ambient light is used for tracks without spherical harmonics textures.
Definition: spherical_harmonics.hpp:47
void setAmbientLight(const irr::video::SColor &ambient)
Compute spherical harmonics coefficients from ambient light.
Definition: spherical_harmonics.cpp:573
void generateSphericalHarmonics(unsigned char *sh_rgba[6], unsigned int edge_size)
Compute m_SH_coeff->red_SH_coeff, m_SH_coeff->green_SH_coeff and m_SH_coeff->blue_SH_coeff from Yml v...
Definition: spherical_harmonics.cpp:234
std::vector< irr::video::IImage * > m_spherical_harmonics_textures
The 6 spherical harmonics textures.
Definition: spherical_harmonics.hpp:44
void unprojectSH(unsigned int width, unsigned int height, float *Y00[], float *Y1minus1[], float *Y10[], float *Y11[], float *Y2minus2[], float *Y2minus1[], float *Y20[], float *Y21[], float *Y22[], float *output[])
Compute the the environment map from the spherical harmonics coefficients.
Definition: spherical_harmonics.cpp:635
SHCoefficients * m_SH_coeff
The spherical harmonics coefficients.
Definition: spherical_harmonics.hpp:50
Definition: spherical_harmonics.hpp:26
Definition: spherical_harmonics.hpp:33