@pixi/filter-advanced-bloom
Advanced tools
Comparing version 2.7.0 to 3.0.0
/*! | ||
* @pixi/filter-advanced-bloom - v2.7.0 | ||
* Compiled Sun, 13 Jan 2019 22:51:52 UTC | ||
* Compiled Fri, 10 May 2019 22:56:42 UTC | ||
* | ||
@@ -8,3 +8,245 @@ * @pixi/filter-advanced-bloom is licensed under the MIT License. | ||
*/ | ||
import{Filter as t,settings as r}from"pixi.js";import{KawaseBlurFilter as e}from"@pixi/filter-kawase-blur";var o="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform float threshold;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n // A simple & fast algorithm for getting brightness.\n // It's inaccuracy , but good enought for this feature.\n float _max = max(max(color.r, color.g), color.b);\n float _min = min(min(color.r, color.g), color.b);\n float brightness = (_max + _min) * 0.5;\n\n if(brightness > threshold) {\n gl_FragColor = color;\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n",n=function(t){function r(r){void 0===r&&(r=.5),t.call(this,o,i),this.threshold=r}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={threshold:{configurable:!0}};return e.threshold.get=function(){return this.uniforms.threshold},e.threshold.set=function(t){this.uniforms.threshold=t},Object.defineProperties(r.prototype,e),r}(t),l="uniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D bloomTexture;\nuniform float bloomScale;\nuniform float brightness;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n color.rgb *= brightness;\n vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= bloomScale;\n gl_FragColor = color + bloomColor;\n}\n",s=function(t){function i(i){t.call(this,o,l),"number"==typeof i&&(i={threshold:i}),i=Object.assign({threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:r.RESOLUTION},i),this.bloomScale=i.bloomScale,this.brightness=i.brightness;var s=i.kernels,u=i.blur,a=i.quality,c=i.pixelSize,h=i.resolution;this._extractFilter=new n(i.threshold),this._extractFilter.resolution=h,this._blurFilter=s?new e(s):new e(u,a),this.pixelSize=c,this.resolution=h}t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i;var s={resolution:{configurable:!0},threshold:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return i.prototype.apply=function(t,r,e,o,i){var n=t.getRenderTarget(!0);this._extractFilter.apply(t,r,n,!0,i);var l=t.getRenderTarget(!0);this._blurFilter.apply(t,n,l,!0,i),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=l,t.applyFilter(this,r,e,o),t.returnRenderTarget(l),t.returnRenderTarget(n)},s.resolution.get=function(){return this._resolution},s.resolution.set=function(t){this._resolution=t,this._extractFilter&&(this._extractFilter.resolution=t),this._blurFilter&&(this._blurFilter.resolution=t)},s.threshold.get=function(){return this._extractFilter.threshold},s.threshold.set=function(t){this._extractFilter.threshold=t},s.kernels.get=function(){return this._blurFilter.kernels},s.kernels.set=function(t){this._blurFilter.kernels=t},s.blur.get=function(){return this._blurFilter.blur},s.blur.set=function(t){this._blurFilter.blur=t},s.quality.get=function(){return this._blurFilter.quality},s.quality.set=function(t){this._blurFilter.quality=t},s.pixelSize.get=function(){return this._blurFilter.pixelSize},s.pixelSize.set=function(t){this._blurFilter.pixelSize=t},Object.defineProperties(i.prototype,s),i}(t);export{s as AdvancedBloomFilter}; | ||
import { Filter } from '@pixi/core'; | ||
import { KawaseBlurFilter } from '@pixi/filter-kawase-blur'; | ||
import { settings } from '@pixi/settings'; | ||
var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}"; | ||
var fragment = "\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform float threshold;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n // A simple & fast algorithm for getting brightness.\n // It's inaccuracy , but good enought for this feature.\n float _max = max(max(color.r, color.g), color.b);\n float _min = min(min(color.r, color.g), color.b);\n float brightness = (_max + _min) * 0.5;\n\n if(brightness > threshold) {\n gl_FragColor = color;\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n"; | ||
/** | ||
* Internal filter for AdvancedBloomFilter to get brightness. | ||
* @class | ||
* @private | ||
* @param {number} [threshold=0.5] Defines how bright a color needs to be extracted. | ||
*/ | ||
var ExtractBrightnessFilter = /*@__PURE__*/(function (Filter) { | ||
function ExtractBrightnessFilter(threshold) { | ||
if ( threshold === void 0 ) threshold = 0.5; | ||
Filter.call(this, vertex, fragment); | ||
this.threshold = threshold; | ||
} | ||
if ( Filter ) ExtractBrightnessFilter.__proto__ = Filter; | ||
ExtractBrightnessFilter.prototype = Object.create( Filter && Filter.prototype ); | ||
ExtractBrightnessFilter.prototype.constructor = ExtractBrightnessFilter; | ||
var prototypeAccessors = { threshold: { configurable: true } }; | ||
/** | ||
* Defines how bright a color needs to be extracted. | ||
* | ||
* @member {number} | ||
* @default 0.5 | ||
*/ | ||
prototypeAccessors.threshold.get = function () { | ||
return this.uniforms.threshold; | ||
}; | ||
prototypeAccessors.threshold.set = function (value) { | ||
this.uniforms.threshold = value; | ||
}; | ||
Object.defineProperties( ExtractBrightnessFilter.prototype, prototypeAccessors ); | ||
return ExtractBrightnessFilter; | ||
}(Filter)); | ||
var fragment$1 = "uniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D bloomTexture;\nuniform float bloomScale;\nuniform float brightness;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n color.rgb *= brightness;\n vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= bloomScale;\n gl_FragColor = color + bloomColor;\n}\n"; | ||
/** | ||
* The AdvancedBloomFilter applies a Bloom Effect to an object. Unlike the normal BloomFilter | ||
* this had some advanced controls for adjusting the look of the bloom. Note: this filter | ||
* is slower than normal BloomFilter.<br> | ||
* ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/advanced-bloom.png) | ||
* | ||
* @class | ||
* @extends PIXI.Filter | ||
* @memberof PIXI.filters | ||
* @see {@link https://www.npmjs.com/package/@pixi/filter-advanced-bloom|@pixi/filter-advanced-bloom} | ||
* @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters} | ||
* | ||
* @param {object|number} [options] - The optional parameters of advanced bloom filter. | ||
* When options is a number , it will be `options.threshold`. | ||
* @param {number} [options.threshold=0.5] - Defines how bright a color needs to be to affect bloom. | ||
* @param {number} [options.bloomScale=1.0] - To adjust the strength of the bloom. Higher values is more intense brightness. | ||
* @param {number} [options.brightness=1.0] - The brightness, lower value is more subtle brightness, higher value is blown-out. | ||
* @param {number} [options.blur=8] - Sets the strength of the Blur properties simultaneously | ||
* @param {number} [options.quality=4] - The quality of the Blur filter. | ||
* @param {number[]} [options.kernels=null] - The kernels of the Blur filter. | ||
* @param {number|number[]|PIXI.Point} [options.pixelSize=1] - the pixelSize of the Blur filter. | ||
* @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution of the Blur filter. | ||
*/ | ||
var AdvancedBloomFilter = /*@__PURE__*/(function (Filter) { | ||
function AdvancedBloomFilter(options) { | ||
Filter.call(this, vertex, fragment$1); | ||
if (typeof options === 'number') { | ||
options = { threshold: options }; | ||
} | ||
options = Object.assign({ | ||
threshold: 0.5, | ||
bloomScale: 1.0, | ||
brightness: 1.0, | ||
kernels: null, | ||
blur: 8, | ||
quality: 4, | ||
pixelSize: 1, | ||
resolution: settings.RESOLUTION, | ||
}, options); | ||
/** | ||
* To adjust the strength of the bloom. Higher values is more intense brightness. | ||
* | ||
* @member {number} | ||
* @default 1.0 | ||
*/ | ||
this.bloomScale = options.bloomScale; | ||
/** | ||
* The brightness, lower value is more subtle brightness, higher value is blown-out. | ||
* | ||
* @member {number} | ||
* @default 1.0 | ||
*/ | ||
this.brightness = options.brightness; | ||
var kernels = options.kernels; | ||
var blur = options.blur; | ||
var quality = options.quality; | ||
var pixelSize = options.pixelSize; | ||
var resolution = options.resolution; | ||
this._extractFilter = new ExtractBrightnessFilter(options.threshold); | ||
this._extractFilter.resolution = resolution; | ||
this._blurFilter = kernels ? | ||
new KawaseBlurFilter(kernels) : | ||
new KawaseBlurFilter(blur, quality); | ||
this.pixelSize = pixelSize; | ||
this.resolution = resolution; | ||
} | ||
if ( Filter ) AdvancedBloomFilter.__proto__ = Filter; | ||
AdvancedBloomFilter.prototype = Object.create( Filter && Filter.prototype ); | ||
AdvancedBloomFilter.prototype.constructor = AdvancedBloomFilter; | ||
var prototypeAccessors = { resolution: { configurable: true },threshold: { configurable: true },kernels: { configurable: true },blur: { configurable: true },quality: { configurable: true },pixelSize: { configurable: true } }; | ||
/** | ||
* Override existing apply method in PIXI.Filter | ||
* @private | ||
*/ | ||
AdvancedBloomFilter.prototype.apply = function apply (filterManager, input, output, clear, currentState) { | ||
var brightTarget = filterManager.getFilterTexture(); | ||
this._extractFilter.apply(filterManager, input, brightTarget, true, currentState); | ||
var bloomTarget = filterManager.getFilterTexture(); | ||
this._blurFilter.apply(filterManager, brightTarget, bloomTarget, true, currentState); | ||
this.uniforms.bloomScale = this.bloomScale; | ||
this.uniforms.brightness = this.brightness; | ||
this.uniforms.bloomTexture = bloomTarget; | ||
filterManager.applyFilter(this, input, output, clear); | ||
filterManager.returnFilterTexture(bloomTarget); | ||
filterManager.returnFilterTexture(brightTarget); | ||
}; | ||
/** | ||
* The resolution of the filter. | ||
* | ||
* @member {number} | ||
*/ | ||
prototypeAccessors.resolution.get = function () { | ||
return this._resolution; | ||
}; | ||
prototypeAccessors.resolution.set = function (value) { | ||
this._resolution = value; | ||
if (this._extractFilter) { | ||
this._extractFilter.resolution = value; | ||
} | ||
if (this._blurFilter) { | ||
this._blurFilter.resolution = value; | ||
} | ||
}; | ||
/** | ||
* Defines how bright a color needs to be to affect bloom. | ||
* | ||
* @member {number} | ||
* @default 0.5 | ||
*/ | ||
prototypeAccessors.threshold.get = function () { | ||
return this._extractFilter.threshold; | ||
}; | ||
prototypeAccessors.threshold.set = function (value) { | ||
this._extractFilter.threshold = value; | ||
}; | ||
/** | ||
* Sets the kernels of the Blur Filter | ||
* | ||
* @member {number} | ||
* @default 4 | ||
*/ | ||
prototypeAccessors.kernels.get = function () { | ||
return this._blurFilter.kernels; | ||
}; | ||
prototypeAccessors.kernels.set = function (value) { | ||
this._blurFilter.kernels = value; | ||
}; | ||
/** | ||
* Sets the strength of the Blur properties simultaneously | ||
* | ||
* @member {number} | ||
* @default 2 | ||
*/ | ||
prototypeAccessors.blur.get = function () { | ||
return this._blurFilter.blur; | ||
}; | ||
prototypeAccessors.blur.set = function (value) { | ||
this._blurFilter.blur = value; | ||
}; | ||
/** | ||
* Sets the quality of the Blur Filter | ||
* | ||
* @member {number} | ||
* @default 4 | ||
*/ | ||
prototypeAccessors.quality.get = function () { | ||
return this._blurFilter.quality; | ||
}; | ||
prototypeAccessors.quality.set = function (value) { | ||
this._blurFilter.quality = value; | ||
}; | ||
/** | ||
* Sets the pixelSize of the Kawase Blur filter | ||
* | ||
* @member {number|number[]|PIXI.Point} | ||
* @default 1 | ||
*/ | ||
prototypeAccessors.pixelSize.get = function () { | ||
return this._blurFilter.pixelSize; | ||
}; | ||
prototypeAccessors.pixelSize.set = function (value) { | ||
this._blurFilter.pixelSize = value; | ||
}; | ||
Object.defineProperties( AdvancedBloomFilter.prototype, prototypeAccessors ); | ||
return AdvancedBloomFilter; | ||
}(Filter)); | ||
export { AdvancedBloomFilter }; | ||
//# sourceMappingURL=filter-advanced-bloom.esm.js.map |
{ | ||
"name": "@pixi/filter-advanced-bloom", | ||
"version": "2.7.0", | ||
"main": "lib/filter-advanced-bloom.js", | ||
"description": "PixiJS v4 filter to render Bloom Filter (with highlight) effect", | ||
"version": "3.0.0", | ||
"main": "lib/filter-advanced-bloom.cjs.js", | ||
"bundle": "dist/filter-advanced-bloom.js", | ||
"description": "PixiJS filter to render Bloom Filter (with highlight) effect", | ||
"author": "finscn", | ||
@@ -24,2 +25,3 @@ "contributors": [ | ||
"lib", | ||
"dist", | ||
"types.d.ts" | ||
@@ -30,12 +32,11 @@ ], | ||
}, | ||
"peerDependencies": { | ||
"pixi.js": ">=4.5.0" | ||
}, | ||
"dependencies": { | ||
"@pixi/filter-kawase-blur": "^2.7.0" | ||
"@pixi/core": "^5.0.0-X", | ||
"@pixi/filter-kawase-blur": "^3.0.0", | ||
"@pixi/settings": "^5.0.0-X" | ||
}, | ||
"devDependencies": { | ||
"@tools/fragments": "^2.0.0" | ||
"@tools/fragments": "^3.0.0" | ||
}, | ||
"gitHead": "a1329fadd2910c48842c92f254be77d971a823ca" | ||
"gitHead": "0902eca3fe476dd7dacc9330f504d8e2ade6c9bd" | ||
} |
# AdvancedBloomFilter | ||
PixiJS v4 filter to render Bloom Filter (with highlight) effect. | ||
PixiJS filter to render Bloom Filter (with highlight) effect. | ||
@@ -5,0 +5,0 @@ ## Installation |
/// <reference types="pixi.js" /> | ||
declare namespace PIXI.filters { | ||
class AdvancedBloomFilter extends PIXI.Filter<{}> { | ||
declare module "@pixi/filter-advanced-bloom" { | ||
export class AdvancedBloomFilter extends PIXI.Filter { | ||
constructor(options?: AdvancedBloomOptions); | ||
@@ -15,3 +15,3 @@ constructor(threshold?: number); | ||
} | ||
interface AdvancedBloomOptions { | ||
export interface AdvancedBloomOptions { | ||
threshold?: number; | ||
@@ -26,6 +26,2 @@ bloomScale?: number; | ||
} | ||
} | ||
declare module "@pixi/filter-advanced-bloom" { | ||
export = PIXI.filters; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
55359
10
478
0
3
1
+ Added@pixi/core@^5.0.0-X
+ Added@pixi/settings@^5.0.0-X
+ Added@pixi/constants@5.3.12(transitive)
+ Added@pixi/core@5.3.12(transitive)
+ Added@pixi/filter-kawase-blur@3.2.0(transitive)
+ Added@pixi/math@5.3.12(transitive)
+ Added@pixi/runner@5.3.12(transitive)
+ Added@pixi/settings@5.3.12(transitive)
+ Added@pixi/ticker@5.3.12(transitive)
+ Added@pixi/utils@5.3.12(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedeventemitter3@3.1.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.6(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedmath-intrinsics@1.0.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedurl@0.11.4(transitive)
- Removed@pixi/colord@2.9.6(transitive)
- Removed@pixi/filter-kawase-blur@2.7.0(transitive)
- Removed@types/css-font-loading-module@0.0.12(transitive)
- Removed@types/earcut@2.1.4(transitive)
- Removed@webgpu/types@0.1.51(transitive)
- Removed@xmldom/xmldom@0.8.10(transitive)
- Removedeventemitter3@5.0.1(transitive)
- Removedparse-svg-path@0.1.2(transitive)
- Removedpixi.js@8.6.5(transitive)