-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlight_transport_matrix.h
158 lines (122 loc) · 4.31 KB
/
light_transport_matrix.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef _LIGHT_TRANSPORT_H_
#define _LIGHT_TRANSPORT_H_
#include "common.h"
#include "matrix.h"
#include "matrix_c.h"
#include "vpl_interface.h"
#include "image_sampler.h"
namespace Renzoku {
/**
* A common interface for light transport matrix and its components like form factor and BRDF matrix.
*/
class TransportMatrix {
public:
/**
* Generate light transport matrix content from a set of pixel samples and a set of VPLs.
*/
virtual void fill(Scene *scene, IVirtualPointLightEvaluator *renderer,
BrdfPointLights &vpls, Pixels &pixels) = 0;
/**
* Return the distance between two columns
*/
virtual Float get_distance(int i, int j) { return 0.; }
/**
* Generate the probability distribution for clustering by sampling.
*
* Alpha vector is calculated by Hasan's SG07 approach.
*
* This function is written here for better performance.
*/
virtual void generate_alphas_for_clustering(vector<Float> &alphas) {}
/**
* Return the L2-norm of the column
*/
virtual Float get_magnitude_of_column(int i) { return 0.; }
virtual int get_cols() const = 0;
virtual int get_rows() const = 0;
virtual void save(const char *file) const = 0;
};
/**
* Light transport is a RGB matrix that stores the out-going radiance
* of each surface point due to each virtual point light.
*/
class LightTransportMatrix : public TransportMatrix {
public:
LightTransportMatrix(int rows, int cols);
virtual void fill(Scene *scene, IVirtualPointLightEvaluator *renderer,
BrdfPointLights &vpls, Pixels &pixels);
virtual void resize(int rows, int cols);
virtual void get_column(int i, vector<Float> &c) const;
virtual void set_column(int i, const vector<Float> &c);
virtual void generate_alphas_for_clustering(vector<Float> &alphas);
virtual Float get_column_norm(int i) const;
virtual void get_column_norms(vector<Float> &norms) const;
virtual int get_rows() const;
virtual int get_cols() const;
virtual MatrixC<Rgb> &get_matrix() { return m; }
virtual void save(const char *file) const;
protected:
/**
* Due to the frequent use of calculating distance between two columns,
* a column-major internal storage is prefered for this matrix.
*/
MatrixC<Rgb> m;
};
/**
* Form factor matrix stores form factor values between each virtual point light and each surface.
* No visibility tracing is done.
*/
class FormFactorMatrix : public TransportMatrix {
public:
virtual void fill(Scene *scene, IVirtualPointLightEvaluator *renderer,
BrdfPointLights &vpls, Pixels &pixels);
virtual void generate_alphas_for_clustering(vector<Float> &alphas);
virtual int get_rows() const;
virtual int get_cols() const;
virtual void save(const char *file) const;
protected:
MatrixC<Float> m;
};
/**
* Visibility matrix is a 0/1 matrix that denotes the visiblity between each virtual point light
* and each surface point.
*
* TODO:
* Derived from FormFactorMatrix class for code re-use. In fact, to save more storage,
* it can be derived directly from TransportMatrix and use a MatrixC<char> storage.
*/
class VisibilityMatrix : public FormFactorMatrix {
public:
virtual void fill(Scene *scene, IVirtualPointLightEvaluator *renderer,
BrdfPointLights &vpls, Pixels &pixels);
};
/**
* This matrix captures all BRDF values at every virtual point light
* that contributes to every surface.
*/
class BrdfLightMatrix : public LightTransportMatrix {
public:
virtual void fill(Scene *scene, IVirtualPointLightEvaluator *renderer,
BrdfPointLights &vpls, Pixels &pixels);
};
/*
* This matrix captures all BRDF values at every surface that receives
* contribution from every virtual point light.
*/
class BrdfSurfaceMatrix : public LightTransportMatrix {
public:
virtual void fill(Scene *scene, IVirtualPointLightEvaluator *renderer,
BrdfPointLights &vpls, Pixels &pixels);
};
/**
* A unified light transport class.
*/
class LightTransport {
protected:
LightTransportMatrix T;
FormFactorMatrix G;
BrdfLightMatrix F1;
BrdfSurfaceMatrix F2;
};
} // end namespace
#endif