import { ExtensionType } from '../extensions/Extensions.mjs'; import { BlendModeFilter } from '../filters/blend-modes/BlendModeFilter.mjs'; "use strict"; class LinearLightBlend extends BlendModeFilter { constructor() { super({ gl: { functions: ` float linearBurn(float base, float blend) { return max(0.0, base + blend - 1.0); } float linearDodge(float base, float blend) { return min(1.0, base + blend); } float linearLight(float base, float blend) { return (blend <= 0.5) ? linearBurn(base,2.0*blend) : linearBurn(base,2.0*(blend-0.5)); } vec3 blendLinearLight(vec3 base, vec3 blend, float opacity) { vec3 blended = vec3( linearLight(base.r, blend.r), linearLight(base.g, blend.g), linearLight(base.b, blend.b) ); return (blended * opacity + base * (1.0 - opacity)); } `, main: ` finalColor = vec4(blendLinearLight(back.rgb, front.rgb,front.a), blendedAlpha) * uBlend; ` }, gpu: { functions: ` fn linearBurn(base: f32, blend: f32) -> f32 { return max(0.0, base + blend - 1.0); } fn linearDodge(base: f32, blend: f32) -> f32 { return min(1.0, base + blend); } fn linearLight(base: f32, blend: f32) -> f32 { return select(linearBurn(base,2.0*(blend-0.5)), linearBurn(base,2.0*blend), blend <= 0.5); } fn blendLinearLightOpacity(base:vec3, blend:vec3, opacity:f32) -> vec3 { let blended = vec3( linearLight(base.r, blend.r), linearLight(base.g, blend.g), linearLight(base.b, blend.b) ); return (blended * opacity + base * (1.0 - opacity)); } `, main: ` out = vec4(blendLinearLightOpacity(back.rgb, front.rgb, front.a), blendedAlpha) * blendUniforms.uBlend; ` } }); } } /** @ignore */ LinearLightBlend.extension = { name: "linear-light", type: ExtensionType.BlendMode }; export { LinearLightBlend }; //# sourceMappingURL=LinearLightBlend.mjs.map