diff --git a/src/main/java/eu/jonahbauer/raytracing/render/texture/Color.java b/src/main/java/eu/jonahbauer/raytracing/render/texture/Color.java index 3a6ee98..5370224 100644 --- a/src/main/java/eu/jonahbauer/raytracing/render/texture/Color.java +++ b/src/main/java/eu/jonahbauer/raytracing/render/texture/Color.java @@ -44,10 +44,11 @@ public record Color(double r, double g, double b) implements Texture { } public static @NotNull Color average(@NotNull Color current, @NotNull Color next, int index) { + var factor = 1d / index; return new Color( - current.r() + (next.r() - current.r()) / index, - current.g() + (next.g() - current.g()) / index, - current.b() + (next.b() - current.b()) / index + Math.fma(factor, next.r() - current.r(), current.r()), + Math.fma(factor, next.g() - current.g(), current.g()), + Math.fma(factor, next.b() - current.b(), current.b()) ); }