Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PreethamTexture.h
Go to the documentation of this file.
1#pragma once
2
5#include "Math/TVector3.h"
6
7#include <Common/primitive_type.h>
8
9#include <memory>
10#include <cmath>
11
12namespace ph
13{
14
15class PreethamTexture : public TTexture<math::Spectrum>
16{
17public:
19 real phiSun,
20 real thetaSun,
21 real turbidity,
22 real energyScale = 1.0_r);
23
24 void sample(const SampleLocation& sampleLocation, math::Spectrum* out_value) const override;
25
26private:
27 real m_phiSun;
28 real m_thetaSun;
29 math::Vector3R m_A_xyY;
30 math::Vector3R m_B_xyY;
31 math::Vector3R m_C_xyY;
32 math::Vector3R m_D_xyY;
33 math::Vector3R m_E_xyY;
34 math::Vector3R m_Yabs_xyY;
35 real m_energyScale;
36
37 math::Vector3R F(real theta, real cosGamma) const;
38};
39
40// In-header Implementations:
41
42inline math::Vector3R PreethamTexture::F(const real theta, const real cosGamma) const
43{
44 const auto rcpCosTheta = 1.0_r / std::cos(theta);
45
46 // Gamma is the angle between direction to sun and view vector
47 const auto gamma = std::acos(cosGamma);
48 const auto cos2Gamma = cosGamma * cosGamma;
49
50 return {
51 (1.0_r + m_A_xyY.x() * std::exp(m_B_xyY.x() * rcpCosTheta)) * (1.0_r + m_C_xyY.x() * std::exp(m_D_xyY.x() * gamma) + m_E_xyY.x() * cos2Gamma),
52 (1.0_r + m_A_xyY.y() * std::exp(m_B_xyY.y() * rcpCosTheta)) * (1.0_r + m_C_xyY.y() * std::exp(m_D_xyY.y() * gamma) + m_E_xyY.y() * cos2Gamma),
53 (1.0_r + m_A_xyY.z() * std::exp(m_B_xyY.z() * rcpCosTheta)) * (1.0_r + m_C_xyY.z() * std::exp(m_D_xyY.z() * gamma) + m_E_xyY.z() * cos2Gamma)};
54}
55
56}// end namespace ph
Definition PreethamTexture.h:16
void sample(const SampleLocation &sampleLocation, math::Spectrum *out_value) const override
Definition PreethamTexture.cpp:91
PreethamTexture(real phiSun, real thetaSun, real turbidity, real energyScale=1.0_r)
Definition PreethamTexture.cpp:17
Definition SampleLocation.h:22
Definition TTexture.h:12
Definition TTristimulusSpectrum.h:11
T & y()
Definition TVector3.ipp:189
T & z()
Definition TVector3.ipp:195
T & x()
Definition TVector3.ipp:183
The root for all renderer implementations.
Definition EEngineProject.h:6