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