This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbsdf.h
76 lines (64 loc) · 1.74 KB
/
bsdf.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
// Copyright (c) 2016 Kai Luo. All rights reserved.
#ifndef ZLI_BSDF_H_
#define ZLI_BSDF_H_
#include <functional>
#include <memory>
#include <tuple>
#include "core_math.h"
namespace zLi {
struct BRDF {
enum class Type {
Specular,
Diffuse,
};
// @args: normal, wi
// @return (pdf, wo)
std::function<std::tuple<Float, Vector3f>(const Vector3f &, const Vector3f &)>
pdf;
// @args: normal, wi, wo
// @return brdf
std::function<Float(const Vector3f &, const Vector3f &, const Vector3f &)> f;
std::function<BRDF::Type()> type;
};
struct BTDF {
// @args: normal, wi
// @return (pdf, wo)
std::function<std::tuple<Float, Vector3f>(const Vector3f &, const Vector3f &)>
pdf;
// @args: normal, wi, wo
// @return btdf
std::function<Float(const Vector3f &, const Vector3f &, const Vector3f &)> f;
};
struct BSDF {
BSDF() = default;
BSDF(const BSDF &rhs) {
if (rhs.brdf) {
brdf = std::make_unique<BRDF>(*rhs.brdf);
}
if (rhs.btdf) {
btdf = std::make_unique<BTDF>(*rhs.btdf);
}
}
BSDF(BSDF &&) = default;
std::unique_ptr<BRDF> brdf;
std::unique_ptr<BTDF> btdf;
};
struct LambertianDiffuse {
static std::tuple<Float, Vector3f> pdf(const Vector3f &normal,
const Vector3f &wi);
static Float f(const Vector3f &normal, const Vector3f &wi,
const Vector3f &wo);
static BSDF ImplBSDF();
};
struct Specular {
static std::tuple<Float, Vector3f> pdf(const Vector3f &normal,
const Vector3f &wi);
static Float f(const Vector3f &normal, const Vector3f &wi,
const Vector3f &wo);
static BSDF ImplBSDF();
};
struct Refractive {
static BSDF ImplBSDF(Float);
};
} // namespace zLi
#endif