19 #include <nori/photon.h>
24 float PhotonData::m_cosTheta[256];
25 float PhotonData::m_sinTheta[256];
26 float PhotonData::m_cosPhi[256];
27 float PhotonData::m_sinPhi[256];
28 float PhotonData::m_expTable[256];
31 for (
int i=0; i<256; i++) {
32 float angle = (float) i * ((
float) M_PI / 256.0f);
33 m_cosPhi[i] = std::cos(2.0f * angle);
34 m_sinPhi[i] = std::sin(2.0f * angle);
35 m_cosTheta[i] = std::cos(angle);
36 m_sinTheta[i] = std::sin(angle);
37 m_expTable[i] = std::ldexp((
float) 1, i - (128+8));
45 std::cerr <<
"Creating an invalid photon with power: " << power << endl;
49 theta = (uint8_t) std::min(255,
50 (
int) (std::acos(dir.z()) * (256.0f / M_PI)));
52 int tmp = std::min(255,
53 (
int) (std::atan2(dir.y(), dir.x()) * (256.0f / (2.0f * M_PI))));
55 phi = (uint8_t) (tmp + 256);
60 float max = power.maxCoeff();
68 max = std::frexp(max, &e) * 256.0f / max;
69 rgbe[0] = (uint8_t) (power.
r() * max);
70 rgbe[1] = (uint8_t) (power.
g() * max);
71 rgbe[2] = (uint8_t) (power.
b() * max);
Represents a linear RGB color value.
bool isValid() const
Check if the color vector contains a NaN/Inf/negative value.
float & g()
Return a reference to the green channel.
float & b()
Return a reference to the blue channel.
float & r()
Return a reference to the red channel.
uint8_t rgbe[4]
Photon power stored in Greg Ward's RGBE format.
PhotonData()
Dummy constructor.
uint8_t theta
Discretized photon direction (theta component)
static bool initialize()
Initialize the precomputed lookup tables.
uint8_t phi
Discretized photon direction (phi component)