|
|
@ -3,6 +3,7 @@ package eu.jonahbauer.raytracing.render.material;
|
|
|
|
import eu.jonahbauer.raytracing.math.Ray;
|
|
|
|
import eu.jonahbauer.raytracing.math.Ray;
|
|
|
|
import eu.jonahbauer.raytracing.math.Vec3;
|
|
|
|
import eu.jonahbauer.raytracing.math.Vec3;
|
|
|
|
import eu.jonahbauer.raytracing.render.texture.Color;
|
|
|
|
import eu.jonahbauer.raytracing.render.texture.Color;
|
|
|
|
|
|
|
|
import eu.jonahbauer.raytracing.render.texture.Texture;
|
|
|
|
import eu.jonahbauer.raytracing.scene.HitResult;
|
|
|
|
import eu.jonahbauer.raytracing.scene.HitResult;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
|
|
|
@ -14,4 +15,9 @@ public record IsotropicMaterial(@NotNull Color albedo) implements Material {
|
|
|
|
public @NotNull Optional<ScatterResult> scatter(@NotNull Ray ray, @NotNull HitResult hit, @NotNull RandomGenerator random) {
|
|
|
|
public @NotNull Optional<ScatterResult> scatter(@NotNull Ray ray, @NotNull HitResult hit, @NotNull RandomGenerator random) {
|
|
|
|
return Optional.of(new ScatterResult(new Ray(hit.position(), Vec3.random(random, true)), albedo()));
|
|
|
|
return Optional.of(new ScatterResult(new Ray(hit.position(), Vec3.random(random, true)), albedo()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public @NotNull Texture texture() {
|
|
|
|
|
|
|
|
return albedo();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|