-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReflective.cpp
More file actions
34 lines (24 loc) · 954 Bytes
/
Reflective.cpp
File metadata and controls
34 lines (24 loc) · 954 Bytes
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
#include "Reflective.h"
const double PI = 3.14;
const double epsilon = 0.001;
const double inf = std::numeric_limits<double>::infinity();
Reflective::Reflective() {}
double Reflective::brdf(const Vector3d& wo, const Vector3d& wi, const Vector3d& n) {
return ((2*n.dot(wo)*n-wo).dot(wi)>0.999) ? 1.0 : 0.0;
}
double Reflective::pdf(const Vector3d& wo, const Vector3d& wi, const Vector3d& n) {
return ((2*n.dot(wo)*n-wo).dot(wi)>0.999) ? 1.0 : inf;
}
Color4dRGB Reflective::explicit_eval(const Vector3d& wo, const Vector3d& wi, const Vector3d& n) {
return Color4dRGB(1.0);
}
Vector3d Reflective::importance_sampling(const Vector3d& wo, const Vector3d& n) {
return Vector3d::Identity();
}
void Reflective::eval(Ray& r, const Vector3d& p, const Vector3d& n) {
r.origin = p+n*0.01;
r.color = r.color;
Vector3d o = (-2*r.dir.dot(n)*n+r.dir);
r.dir = o;
}
Reflective::~Reflective() {}