improve color averaging

main
jbb01 6 months ago
parent 67bfafc5b8
commit a31488bc78

@ -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())
);
}

Loading…
Cancel
Save