-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestMat.java
35 lines (28 loc) · 846 Bytes
/
TestMat.java
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
public class TestMat implements Material {
private Vec3 albedo;
private Ray latestScattered = new Ray();
public TestMat() {
}
public Vec3 getAttenuation() {
return albedo;
}
public Ray getScattered() {
return latestScattered;
}
@Override
public boolean scatter(final Ray rIn, final HitRecord rec, Vec3 attenuation, Ray scattered) {
Vec3 scatterDirection = rec.normal.plus(Vec3.randomUnitVector());
// Catch degenerate scatter direction
if (scatterDirection.nearZero()) {
scatterDirection = rec.normal;
}
scattered = new Ray(rec.p, scatterDirection);
albedo = rec.normal;
latestScattered = scattered;
return true;
}
@Override
public Material createCopy() {
return new TestMat();
}
}