@babylonjs/smart-filters-blocks 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js +11 -6
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js.map +1 -1
- package/package.json +2 -2
- package/src/blocks/babylon/demo/effects/pixelateBlock.block.glsl +6 -5
- package/src/blocks/babylon/demo/effects/pixelateBlock.block.ts +11 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixelateBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/pixelateBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,aAAa,EAEb,mBAAmB,EACnB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,aAAa,EACF,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"pixelateBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/pixelateBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,aAAa,EAEb,mBAAmB,EACnB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,aAAa,EACF,MAAM,0BAA0B,CAAC;AAwFrD;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC1C;;OAEG;IACH,OAAuB,SAAS,SAAmB;IAEnD;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D;;OAEG;IACH,SAAgB,KAAK,kFAAoE;IAEzF;;;OAGG;IACH,SAAgB,SAAS,sIAIvB;IAEF;;;OAGG;IACH,SAAgB,QAAQ,wIAItB;IAEF;;OAEG;IACH,OAAuB,UAAU,gBAAiB;IAElD;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,aAAa;CAO3C"}
|
|
@@ -12,11 +12,11 @@ const shaderProgram = {
|
|
|
12
12
|
uniform: `
|
|
13
13
|
uniform sampler2D _input_; // main
|
|
14
14
|
uniform float _intensity_;
|
|
15
|
-
uniform bool _disabled_
|
|
15
|
+
uniform bool _disabled_;
|
|
16
|
+
uniform vec2 _aspect_;`,
|
|
16
17
|
const: ` const float _videoPixelatePower_ = 6.0;
|
|
17
18
|
const float _videoPixelateMin_ = 10.0;
|
|
18
|
-
const float _videoPixelateMax_ = 1920.0
|
|
19
|
-
const float _aspect_ = 1.72;`,
|
|
19
|
+
const float _videoPixelateMax_ = 1920.0;`,
|
|
20
20
|
mainInputTexture: "_input_",
|
|
21
21
|
mainFunctionName: "_pixelate_",
|
|
22
22
|
functions: [
|
|
@@ -26,8 +26,9 @@ const shaderProgram = {
|
|
|
26
26
|
vec4 _pixelate_(vec2 vUV) {
|
|
27
27
|
if (!_disabled_) {
|
|
28
28
|
float pixelateStrength = mix(_videoPixelateMin_, _videoPixelateMax_, pow(1. - _intensity_, _videoPixelatePower_));
|
|
29
|
-
vec2 _pixelate_ = vec2(pixelateStrength * _aspect_, pixelateStrength);
|
|
30
|
-
|
|
29
|
+
vec2 _pixelate_ = vec2(pixelateStrength * _aspect_.x, pixelateStrength);
|
|
30
|
+
vec2 pixelSize = vec2(1. / _pixelate_);
|
|
31
|
+
vUV = pixelSize * (floor(_pixelate_ * vUV) + 0.5);
|
|
31
32
|
}
|
|
32
33
|
return texture2D(_input_, vUV);
|
|
33
34
|
}
|
|
@@ -45,6 +46,7 @@ const uniforms = {
|
|
|
45
46
|
input: "input",
|
|
46
47
|
intensity: "intensity",
|
|
47
48
|
disabled: "disabled",
|
|
49
|
+
aspect: "aspect",
|
|
48
50
|
};
|
|
49
51
|
/**
|
|
50
52
|
* The shader binding for the PixelateBlock, used by the runtime
|
|
@@ -65,11 +67,14 @@ class PixelateBlockShaderBinding extends ShaderBinding {
|
|
|
65
67
|
/**
|
|
66
68
|
* Binds all the required data to the shader when rendering.
|
|
67
69
|
* @param effect - defines the effect to bind the data to
|
|
70
|
+
* @param width - defines the width of the output
|
|
71
|
+
* @param height - defines the height of the output
|
|
68
72
|
*/
|
|
69
|
-
bind(effect) {
|
|
73
|
+
bind(effect, width, height) {
|
|
70
74
|
effect.setTexture(this.getRemappedName(uniforms.input), this._input.value);
|
|
71
75
|
effect.setFloat(this.getRemappedName(uniforms.intensity), this._intensity.value);
|
|
72
76
|
effect.setBool(this.getRemappedName(uniforms.disabled), this._disabled.value);
|
|
77
|
+
effect.setFloat2(this.getRemappedName(uniforms.aspect), width / height, height / width);
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixelateBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/pixelateBlock.block.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+DAA+D;AAC/D,+DAA+D;AAC/D,+DAA+D;AAS/D,OAAO,EACH,aAAa,EAEb,mBAAmB,EAEnB,WAAW,EAEX,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAErD;;GAEG;AACH,MAAM,aAAa,GAAkB;IACjC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"pixelateBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/pixelateBlock.block.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+DAA+D;AAC/D,+DAA+D;AAC/D,+DAA+D;AAS/D,OAAO,EACH,aAAa,EAEb,mBAAmB,EAEnB,WAAW,EAEX,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAErD;;GAEG;AACH,MAAM,aAAa,GAAkB;IACjC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;;;mCAIkB;QAC3B,KAAK,EAAE;;qDAEsC;QAC7C,gBAAgB,EAAE,SAAS;QAC3B,gBAAg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IAyC1C;;;;OAIG;IACH,YAAY,WAAwB,EAAE,IAAY;QAC9C,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QApCpC;;WAEG;QACa,UAAK,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEzF;;;WAGG;QACa,cAAS,GAAG,IAAI,CAAC,sBAAsB,CACnD,WAAW,EACX,mBAAmB,CAAC,KAAK,EACzB,eAAe,CAAC,GAAG,CAAC,CACvB,CAAC;QAEF;;;WAGG;QACa,aAAQ,GAAG,IAAI,CAAC,sBAAsB,CAClD,UAAU,EACV,mBAAmB,CAAC,OAAO,EAC3B,eAAe,CAAC,KAAK,CAAC,CACzB,CAAC;IAcF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEjE,OAAO,IAAI,0BAA0B,CAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;;AA3DD;;GAEG;AACoB,uBAAS,GAAG,eAAe,AAAlB,CAAmB;AAEnD;;GAEG;AACoB,uBAAS,GAAG,sBAAsB,AAAzB,CAA0B;AA2B1D;;GAEG;AACoB,wBAAU,GAAG,aAAa,AAAhB,CAAiB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/smart-filters-blocks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Babylon.js Smart Filter Block Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"video",
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"@babylonjs/core": "^8.0.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@babylonjs/smart-filters": "1.0.
|
|
50
|
+
"@babylonjs/smart-filters": "1.0.12"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -11,18 +11,19 @@ uniform sampler2D input; // main
|
|
|
11
11
|
uniform float intensity;
|
|
12
12
|
// { "default": false }
|
|
13
13
|
uniform bool disabled;
|
|
14
|
+
// { "autoBind": "outputAspectRatio" }
|
|
15
|
+
uniform vec2 aspect;
|
|
14
16
|
|
|
15
17
|
const float videoPixelatePower = 6.0;
|
|
16
18
|
const float videoPixelateMin = 10.0;
|
|
17
19
|
const float videoPixelateMax = 1920.0;
|
|
18
20
|
|
|
19
|
-
const float aspect = 1.72;
|
|
20
|
-
|
|
21
21
|
vec4 pixelate(vec2 vUV) { // main
|
|
22
22
|
if (!disabled) {
|
|
23
23
|
float pixelateStrength = mix(videoPixelateMin, videoPixelateMax, pow(1. - intensity, videoPixelatePower));
|
|
24
|
-
vec2 pixelate = vec2(pixelateStrength * aspect, pixelateStrength);
|
|
25
|
-
|
|
24
|
+
vec2 pixelate = vec2(pixelateStrength * aspect.x, pixelateStrength);
|
|
25
|
+
vec2 pixelSize = vec2(1. / pixelate);
|
|
26
|
+
vUV = pixelSize * (floor(pixelate * vUV) + 0.5);
|
|
26
27
|
}
|
|
27
28
|
return texture2D(input, vUV);
|
|
28
|
-
}
|
|
29
|
+
}
|
|
@@ -28,11 +28,11 @@ const shaderProgram: ShaderProgram = {
|
|
|
28
28
|
uniform: `
|
|
29
29
|
uniform sampler2D _input_; // main
|
|
30
30
|
uniform float _intensity_;
|
|
31
|
-
uniform bool _disabled_
|
|
31
|
+
uniform bool _disabled_;
|
|
32
|
+
uniform vec2 _aspect_;`,
|
|
32
33
|
const: ` const float _videoPixelatePower_ = 6.0;
|
|
33
34
|
const float _videoPixelateMin_ = 10.0;
|
|
34
|
-
const float _videoPixelateMax_ = 1920.0
|
|
35
|
-
const float _aspect_ = 1.72;`,
|
|
35
|
+
const float _videoPixelateMax_ = 1920.0;`,
|
|
36
36
|
mainInputTexture: "_input_",
|
|
37
37
|
mainFunctionName: "_pixelate_",
|
|
38
38
|
functions: [
|
|
@@ -42,8 +42,9 @@ const shaderProgram: ShaderProgram = {
|
|
|
42
42
|
vec4 _pixelate_(vec2 vUV) {
|
|
43
43
|
if (!_disabled_) {
|
|
44
44
|
float pixelateStrength = mix(_videoPixelateMin_, _videoPixelateMax_, pow(1. - _intensity_, _videoPixelatePower_));
|
|
45
|
-
vec2 _pixelate_ = vec2(pixelateStrength * _aspect_, pixelateStrength);
|
|
46
|
-
|
|
45
|
+
vec2 _pixelate_ = vec2(pixelateStrength * _aspect_.x, pixelateStrength);
|
|
46
|
+
vec2 pixelSize = vec2(1. / _pixelate_);
|
|
47
|
+
vUV = pixelSize * (floor(_pixelate_ * vUV) + 0.5);
|
|
47
48
|
}
|
|
48
49
|
return texture2D(_input_, vUV);
|
|
49
50
|
}
|
|
@@ -62,6 +63,7 @@ const uniforms = {
|
|
|
62
63
|
input: "input",
|
|
63
64
|
intensity: "intensity",
|
|
64
65
|
disabled: "disabled",
|
|
66
|
+
aspect: "aspect",
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
/**
|
|
@@ -92,11 +94,14 @@ class PixelateBlockShaderBinding extends ShaderBinding {
|
|
|
92
94
|
/**
|
|
93
95
|
* Binds all the required data to the shader when rendering.
|
|
94
96
|
* @param effect - defines the effect to bind the data to
|
|
97
|
+
* @param width - defines the width of the output
|
|
98
|
+
* @param height - defines the height of the output
|
|
95
99
|
*/
|
|
96
|
-
public override bind(effect: Effect): void {
|
|
100
|
+
public override bind(effect: Effect, width: number, height: number): void {
|
|
97
101
|
effect.setTexture(this.getRemappedName(uniforms.input), this._input.value);
|
|
98
102
|
effect.setFloat(this.getRemappedName(uniforms.intensity), this._intensity.value);
|
|
99
103
|
effect.setBool(this.getRemappedName(uniforms.disabled), this._disabled.value);
|
|
104
|
+
effect.setFloat2(this.getRemappedName(uniforms.aspect), width / height, height / width);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
|