UNPKG

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">

62 lines (56 loc) 2.06 kB
import { ExtensionType } from '../extensions/Extensions.mjs'; import { BlendModeFilter } from '../filters/blend-modes/BlendModeFilter.mjs'; "use strict"; class HardLightBlend extends BlendModeFilter { constructor() { super({ gl: { functions: ` float hardLight(float base, float blend) { return (blend < 0.5) ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend); } vec3 blendHardLight(vec3 base, vec3 blend, float opacity) { vec3 blended = vec3( hardLight(base.r, blend.r), hardLight(base.g, blend.g), hardLight(base.b, blend.b) ); return (blended * opacity + base * (1.0 - opacity)); } `, main: ` finalColor = vec4(blendHardLight(back.rgb, front.rgb,front.a), blendedAlpha) * uBlend; ` }, gpu: { functions: ` fn hardLight(base: f32, blend: f32) -> f32 { return select(1.0 - 2.0 * (1.0 - base) * (1.0 - blend), 2.0 * base * blend, blend < 0.5); } fn blendHardLight(base: vec3<f32>, blend: vec3<f32>, opacity: f32) -> vec3<f32> { let blended = vec3<f32>( hardLight(base.r, blend.r), hardLight(base.g, blend.g), hardLight(base.b, blend.b) ); return (blended * opacity + base * (1.0 - opacity)); } `, main: ` out = vec4<f32>(blendHardLight(back.rgb, front.rgb, front.a), blendedAlpha) * blendUniforms.uBlend; ` } }); } } /** @ignore */ HardLightBlend.extension = { name: "hard-light", type: ExtensionType.BlendMode }; export { HardLightBlend }; //# sourceMappingURL=HardLightBlend.mjs.map