package eu.jonahbauer.raytracing.render.material;

import eu.jonahbauer.raytracing.math.Ray;
import eu.jonahbauer.raytracing.render.Color;
import eu.jonahbauer.raytracing.scene.HitResult;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;
import java.util.Optional;

public interface Material {

    @NotNull Optional<ScatterResult> scatter(@NotNull Ray ray, @NotNull HitResult hit);

    default @NotNull Color emitted(@NotNull HitResult hit) {
        return Color.BLACK;
    }

    record ScatterResult(@NotNull Ray ray, @NotNull Color attenuation) {
        public ScatterResult {
            Objects.requireNonNull(ray, "ray");
            Objects.requireNonNull(attenuation, "attenuation");
        }
    }
}
