pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
60 lines (54 loc) • 1.94 kB
JavaScript
import { ExtensionType } from '../extensions/Extensions.mjs';
import { BlendModeFilter } from '../filters/blend-modes/BlendModeFilter.mjs';
"use strict";
class LinearDodgeBlend extends BlendModeFilter {
constructor() {
super({
gl: {
functions: `
float linearDodge(float base, float blend) {
return min(1.0, base + blend);
}
vec3 blendLinearDodge(vec3 base, vec3 blend, float opacity) {
vec3 blended = vec3(
linearDodge(base.r, blend.r),
linearDodge(base.g, blend.g),
linearDodge(base.b, blend.b)
);
return (blended * opacity + base * (1.0 - opacity));
}
`,
main: `
finalColor = vec4(blendLinearDodge(back.rgb, front.rgb,front.a), blendedAlpha) * uBlend;
`
},
gpu: {
functions: `
fn linearDodge(base: f32, blend: f32) -> f32
{
return min(1, base + blend);
}
fn blendLinearDodge(base:vec3<f32>, blend:vec3<f32>, opacity:f32) -> vec3<f32>
{
let blended = vec3<f32>(
linearDodge(base.r, blend.r),
linearDodge(base.g, blend.g),
linearDodge(base.b, blend.b)
);
return (blended * opacity + base * (1.0 - opacity));
}
`,
main: `
out = vec4<f32>(blendLinearDodge(back.rgb, front.rgb, front.a), blendedAlpha) * blendUniforms.uBlend;
`
}
});
}
}
/** @ignore */
LinearDodgeBlend.extension = {
name: "linear-dodge",
type: ExtensionType.BlendMode
};
export { LinearDodgeBlend };
//# sourceMappingURL=LinearDodgeBlend.mjs.map