-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMaterialLamp.c
36 lines (25 loc) · 1.07 KB
/
MaterialLamp.c
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
#include "MaterialLamp.h"
#include "randf.h"
#include <math.h>
const MaterialVTable materialLampVTable = (MaterialVTable) {
&materialLampSampleBRDF,
&materialLampBRDF,
&materialLampIrradience
};
MaterialLamp makeMaterialLamp(const Color irradience) {
return (MaterialLamp) {makeMaterial(&materialLampVTable), irradience};
}
defineAllocator(MaterialLamp)
Photon materialLampSampleBRDF(const Material *material, const Intersection intersection, const Photon incoming) {
// Perfectly black surface. The direction of the reflected photon doesn't matter.
return makePhoton(makeRay(intersection.position, intersection.normal), makeColorBlack());
}
Color materialLampBRDF(const Material *material, const Intersection intersection, const Vector incoming, const Vector outgoing) {
// Perfectly black surface. All light comes from radience, not reflectance.
return makeColorBlack();
}
Color materialLampIrradience(const Material *superObject) {
MaterialLamp *material = (MaterialLamp *) superObject;
// Uniformly radiating, perfectly diffuse surface.
return material->irradience;
}