41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import { ExtensionType } from '../extensions/Extensions.mjs';
|
|
import { BlendModeFilter } from '../filters/blend-modes/BlendModeFilter.mjs';
|
|
|
|
"use strict";
|
|
class DifferenceBlend extends BlendModeFilter {
|
|
constructor() {
|
|
super({
|
|
gl: {
|
|
functions: `
|
|
vec3 blendDifference(vec3 base, vec3 blend, float opacity)
|
|
{
|
|
return (abs(blend - base) * opacity + base * (1.0 - opacity));
|
|
}
|
|
`,
|
|
main: `
|
|
finalColor = vec4(blendDifference(back.rgb, front.rgb,front.a), blendedAlpha) * uBlend;
|
|
`
|
|
},
|
|
gpu: {
|
|
functions: `
|
|
fn blendDifference(base:vec3<f32>, blend:vec3<f32>, opacity:f32) -> vec3<f32>
|
|
{
|
|
return (abs(blend - base) * opacity + base * (1.0 - opacity));
|
|
}
|
|
`,
|
|
main: `
|
|
out = vec4<f32>(blendDifference(back.rgb, front.rgb, front.a), blendedAlpha) * blendUniforms.uBlend;
|
|
`
|
|
}
|
|
});
|
|
}
|
|
}
|
|
/** @ignore */
|
|
DifferenceBlend.extension = {
|
|
name: "difference",
|
|
type: ExtensionType.BlendMode
|
|
};
|
|
|
|
export { DifferenceBlend };
|
|
//# sourceMappingURL=DifferenceBlend.mjs.map
|