add shading according to normal vector
parent
590054a046
commit
14fd1d73fc
@ -0,0 +1,16 @@
|
||||
package eu.jonahbauer.raytracing.shape;
|
||||
|
||||
import eu.jonahbauer.raytracing.math.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record HitResult(double t, @NotNull Vec3 normal) implements Comparable<HitResult> {
|
||||
public HitResult {
|
||||
if (t < 0 || !Double.isFinite(t)) throw new IllegalArgumentException("t must be non-negative");
|
||||
normal = normal.unit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull HitResult o) {
|
||||
return Double.compare(t, o.t);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue