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

49 lines (43 loc) 1.49 kB
'use strict'; var Extensions = require('../extensions/Extensions.js'); var BlendModeFilter = require('../filters/blend-modes/BlendModeFilter.js'); var GLhls = require('../filters/blend-modes/hls/GLhls.js'); var GPUhls = require('../filters/blend-modes/hls/GPUhls.js'); "use strict"; class ColorBlend extends BlendModeFilter.BlendModeFilter { constructor() { super({ gl: { functions: ` ${GLhls.hslgl} vec3 blendColor(vec3 base, vec3 blend, float opacity) { return (setLuminosity(blend, getLuminosity(base)) * opacity + base * (1.0 - opacity)); } `, main: ` finalColor = vec4(blendColor(back.rgb, front.rgb,front.a), blendedAlpha) * uBlend; ` }, gpu: { functions: ` ${GPUhls.hslgpu} fn blendColorOpacity(base:vec3<f32>, blend:vec3<f32>, opacity:f32) -> vec3<f32> { return (setLuminosity(blend, getLuminosity(base)) * opacity + base * (1.0 - opacity)); } `, main: ` out = vec4<f32>(blendColorOpacity(back.rgb, front.rgb, front.a), blendedAlpha) * blendUniforms.uBlend; ` } }); } } /** @ignore */ ColorBlend.extension = { name: "color", type: Extensions.ExtensionType.BlendMode }; exports.ColorBlend = ColorBlend; //# sourceMappingURL=ColorBlend.js.map