improve color averaging
This commit is contained in:
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) {
|
public static @NotNull Color average(@NotNull Color current, @NotNull Color next, int index) {
|
||||||
|
var factor = 1d / index;
|
||||||
return new Color(
|
return new Color(
|
||||||
current.r() + (next.r() - current.r()) / index,
|
Math.fma(factor, next.r() - current.r(), current.r()),
|
||||||
current.g() + (next.g() - current.g()) / index,
|
Math.fma(factor, next.g() - current.g(), current.g()),
|
||||||
current.b() + (next.b() - current.b()) / index
|
Math.fma(factor, next.b() - current.b(), current.b())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user