blob: 9ea8d29f3fa1be9a796f43fc4cfe6c8eed81077c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package dev.figboot.cuberender.state;
import dev.figboot.cuberender.math.Vector4f;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Getter
public enum BlendMode {
DISABLE((inOutColor, prev) -> inOutColor.w = 1),
BINARY((inOutColor, prev) -> {
if (inOutColor.w < 0.5) {
inOutColor.copyFrom(prev);
} else {
inOutColor.w = 1;
}
}),
BLEND_OVER((inOutColor, prev) -> {
float pAlphaFactor = prev.w * (1 - inOutColor.w);
float aOut = inOutColor.w + pAlphaFactor;
inOutColor.x = (inOutColor.x * inOutColor.w + prev.x * pAlphaFactor) / aOut;
inOutColor.y = (inOutColor.y * inOutColor.w + prev.y * pAlphaFactor) / aOut;
inOutColor.z = (inOutColor.z * inOutColor.w + prev.z * pAlphaFactor) / aOut;
inOutColor.w = aOut;
});
private final BlendFunction function;
public interface BlendFunction {
void blend(Vector4f inOutColor, Vector4f prev);
}
}
|