-
Notifications
You must be signed in to change notification settings - Fork 0
/
light.h
62 lines (47 loc) · 1.36 KB
/
light.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
#pragma once
#include "redner.h"
#include "vector.h"
#include "buffer.h"
#include "ptr.h"
struct Light {
Light() {}
Light(int shape_id,
const ptr<float> intensity_data) : shape_id(shape_id) {
intensity[0] = intensity_data[0];
intensity[1] = intensity_data[1];
intensity[2] = intensity_data[2];
}
Light(int shape_id,
const Vector3f &intensity) :
shape_id(shape_id), intensity(intensity) {}
int shape_id;
Vector3f intensity;
};
struct DLight {
DLight(ptr<float> intensity_data) : intensity(intensity_data.get()) {
}
float *intensity;
};
struct DLightInst {
int light_id = -1;
Vector3 intensity = Vector3{0, 0, 0};
DEVICE inline bool operator<(const DLightInst &other) const {
return light_id < other.light_id;
}
DEVICE inline bool operator==(const DLightInst &other) const {
return light_id == other.light_id;
}
DEVICE inline DLightInst operator+(const DLightInst &other) const {
return DLightInst{light_id, intensity + other.intensity};
}
};
template <typename T>
struct TLightSample {
T light_sel;
T tri_sel;
TVector2<T> uv;
};
using LightSample = TLightSample<Real>;
void accumulate_light(const BufferView<DLightInst> &d_light_insts,
BufferView<DLight> d_lights,
bool use_gpu);