-
Notifications
You must be signed in to change notification settings - Fork 3
/
llightprobe.h
88 lines (68 loc) · 1.56 KB
/
llightprobe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "lvector.h"
#include "llighttypes.h"
namespace LM
{
class LightMapper;
class LightProbe
{
public:
void Save(FileAccess *f);
void Save_Secondary(FileAccess *f);
struct Contribution
{
uint32_t light_id;
float power; // linear
};
// LightProbe()
// {
// m_fLight = 0.0f;
// }
// float m_fLight;
LVector<Contribution> m_Contributions;
FColor m_Color_Indirect;
};
class LightProbes
{
public:
int Create(LightMapper &lm);
void Process(int stage);
void Save();
private:
void Normalize_Indirect();
void Save(String pszFilename);
void CalculateProbe(const Vec3i &pt);
void CalculateProbe_Old(const Vec3i &pt);
float CalculatePower(const LightMapper_Base::LLight &light, float dist, const Vector3 &pos) const;
void Save_Vector3(FileAccess *f, const Vector3 &v);
LightProbe * GetProbe(const Vec3i &pt)
{
unsigned int ui = GetProbeNum(pt);
if (ui < m_Probes.size())
{
return &m_Probes[ui];
}
return nullptr;
}
void GetProbePosition(const Vec3i &pt, Vector3 &pos) const
{
pos = m_ptMin;
pos.x += pt.x * m_VoxelSize.x;
pos.y += pt.y * m_VoxelSize.y;
pos.z += pt.z * m_VoxelSize.z;
}
unsigned int GetProbeNum(const Vec3i &pt) const
{
return (pt.z * m_DimXTimesY) + (pt.y * m_Dims.x) + pt.x;
}
// number of probes on each axis
Vec3i m_Dims;
int m_DimXTimesY;
// world size of each voxel separating probes
Vector3 m_VoxelSize;
// bottom left probe point, can be used to derive the other points using the voxel size
Vector3 m_ptMin;
LVector<LightProbe> m_Probes;
LightMapper * m_pLightMapper;
};
} // namespace