/
light_source.h
46 lines (38 loc) · 979 Bytes
/
light_source.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
#ifndef LIGHT_SOURCE_H
#define LIGHT_SOURCE_H
#include "util.h"
#include "icache.h"
#include "random.h"
#include "photonmap.h"
class Raytracer;
// Base class for a light source.
class LightSource
{
public:
virtual void shade(Ray3D&, bool getDirectly) = 0;
virtual ~LightSource()
{ };
};
// Square photon mapping light
class SquarePhotonLight : public LightSource
{
private:
BalancedPhotonMap *bmap;
BalancedPhotonMap *cmap;
Colour col;
Random r;
Raytracer *raytracer;
ICache icache;
Colour light_col;
void globalIllumination(Ray3D& ray, bool getDirectly);
void causticIllumination(Ray3D& ray);
void directIllumination(Ray3D& ray);
public:
SquarePhotonLight(Colour col, Raytracer *raytracer);
~SquarePhotonLight();
void initTransformMatrix(Matrix4x4 mat, Vector3D& w);
void shade(Ray3D& ray, bool getDirectly);
Vector3D getRandLambertianDir(Vector3D& normal);
void tracePhotons(int num, int castics_num);
};
#endif