@onerjs/smart-filters-blocks 8.31.5 → 8.31.7
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/compositionBlock.d.ts +7 -3
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js +29 -31
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.js +16 -8
- package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +1 -1
- package/package.json +2 -2
- package/src/blocks/babylon/demo/effects/compositionBlock.fragment.glsl +39 -37
- package/src/blocks/babylon/demo/effects/compositionBlock.fragment.ts +29 -31
- package/src/blocks/babylon/demo/effects/compositionBlock.ts +19 -9
|
@@ -23,7 +23,6 @@ export declare class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
23
23
|
private readonly _foregroundWidth;
|
|
24
24
|
private readonly _foregroundHeight;
|
|
25
25
|
private readonly _foregroundAlphaScale;
|
|
26
|
-
private readonly _alphaMode;
|
|
27
26
|
/**
|
|
28
27
|
* Creates a new shader binding instance for the Composition block.
|
|
29
28
|
* @param parentBlock - The parent block
|
|
@@ -34,9 +33,8 @@ export declare class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
34
33
|
* @param foregroundWidth - the width of the foreground texture
|
|
35
34
|
* @param foregroundHeight - the height of the foreground texture
|
|
36
35
|
* @param foregroundAlphaScale - the alpha scale of the foreground texture
|
|
37
|
-
* @param alphaMode - the alpha mode to use
|
|
38
36
|
*/
|
|
39
|
-
constructor(parentBlock: IDisableableBlock, backgroundTexture: RuntimeData<ConnectionPointType.Texture>, foregroundTexture: RuntimeData<ConnectionPointType.Texture>, foregroundTop: RuntimeData<ConnectionPointType.Float>, foregroundLeft: RuntimeData<ConnectionPointType.Float>, foregroundWidth: RuntimeData<ConnectionPointType.Float>, foregroundHeight: RuntimeData<ConnectionPointType.Float>, foregroundAlphaScale: RuntimeData<ConnectionPointType.Float
|
|
37
|
+
constructor(parentBlock: IDisableableBlock, backgroundTexture: RuntimeData<ConnectionPointType.Texture>, foregroundTexture: RuntimeData<ConnectionPointType.Texture>, foregroundTop: RuntimeData<ConnectionPointType.Float>, foregroundLeft: RuntimeData<ConnectionPointType.Float>, foregroundWidth: RuntimeData<ConnectionPointType.Float>, foregroundHeight: RuntimeData<ConnectionPointType.Float>, foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>);
|
|
40
38
|
/**
|
|
41
39
|
* Binds all the required data to the shader when rendering.
|
|
42
40
|
* @param effect - defines the effect to bind the data to
|
|
@@ -101,6 +99,12 @@ export declare class CompositionBlock extends DisableableShaderBlock {
|
|
|
101
99
|
* The shader program (vertex and fragment code) to use to render the block
|
|
102
100
|
*/
|
|
103
101
|
static ShaderCode: import("@onerjs/smart-filters").ShaderProgram;
|
|
102
|
+
/**
|
|
103
|
+
* Gets the shader program to use to render the block.
|
|
104
|
+
* This adds the per-instance const values to the shader program.
|
|
105
|
+
* @returns The shader program to use to render the block
|
|
106
|
+
*/
|
|
107
|
+
getShaderProgram(): import("@onerjs/smart-filters").ShaderProgram;
|
|
104
108
|
/**
|
|
105
109
|
* Instantiates a new Block.
|
|
106
110
|
* @param smartFilter - The smart filter this block belongs to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compositionBlock.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,yCAAiC;AACvD,OAAO,EACH,wBAAwB,EACxB,KAAK,WAAW,EAChB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,sBAAsB,EACtB,KAAK,WAAW,
|
|
1
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AmB,CAAC,KAAK,CAAC,EACvD,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,EACxD,oBAAoB,EAAE,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC;IAYhE;;;;;OAKG;IACa,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAoB5E;AAED;;;;;;;;;;GAUG;AACH,qBAAa,gBAAiB,SAAQ,sBAAsB;IACxD;;OAEG;IACH,OAAuB,SAAS,SAAwB;IAExD;;OAEG;IACH,OAAuB,SAAS,SAA+B;IAE/D;;OAEG;IACH,SAAgB,UAAU,+EAAyE;IAEnG;;OAEG;IACH,SAAgB,UAAU,mIAAwG;IAElI;;OAEG;IACH,SAAgB,aAAa,iIAAiG;IAE9H;;OAEG;IACH,SAAgB,cAAc,iIAAkG;IAEhI;;OAEG;IACH,SAAgB,eAAe,iIAAmG;IAElI;;OAEG;IACH,SAAgB,gBAAgB,iIAAoG;IAEpI;;OAEG;IACH,SAAgB,oBAAoB,iIAA+G;IAEnJ;;OAEG;IAWI,SAAS,EAAE,MAAM,CAAiB;IAEzC;;OAEG;IACH,OAAuB,UAAU,gDAAiB;IAElD;;;;OAIG;IACa,gBAAgB;IAWhC;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,wBAAwB;CAWtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compositionBlock.fragment.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.fragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAAsB;AAEnD;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"compositionBlock.fragment.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.fragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAAsB;AAEnD;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAkDzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,QAAQ;;;;;;CAMb,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;AAExC,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,QAAQ,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -9,7 +9,6 @@ const BlockShaderProgram = {
|
|
|
9
9
|
uniform sampler2D _foreground_;
|
|
10
10
|
uniform vec2 _scaleUV_;
|
|
11
11
|
uniform vec2 _translateUV_;
|
|
12
|
-
uniform float _alphaMode_;
|
|
13
12
|
uniform float _foregroundAlphaScale_;`,
|
|
14
13
|
mainInputTexture: "_background_",
|
|
15
14
|
mainFunctionName: "_composition_",
|
|
@@ -17,35 +16,35 @@ const BlockShaderProgram = {
|
|
|
17
16
|
{
|
|
18
17
|
name: "_composition_",
|
|
19
18
|
code: `
|
|
20
|
-
vec4 _composition_(vec2 vUV) {
|
|
21
|
-
vec4 _background_ = texture2D(_background_, vUV);
|
|
22
|
-
|
|
23
|
-
vec2 transformedUV = vUV * (1.0 / _scaleUV_) + _translateUV_;
|
|
24
|
-
if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
|
|
25
|
-
return _background_;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
vec4 _foreground_ = texture2D(_foreground_, transformedUV);
|
|
29
|
-
_foreground_.a *= _foregroundAlphaScale_;
|
|
30
|
-
|
|
31
|
-
// SRC is _foreground_, DEST is _background_
|
|
32
|
-
if (_alphaMode_ == 0.) {
|
|
33
|
-
return _foreground_;
|
|
34
|
-
}
|
|
35
|
-
else if (_alphaMode_ == 1.) {
|
|
36
|
-
return _foreground_.a * _foreground_ + _background_;
|
|
37
|
-
}
|
|
38
|
-
else if (_alphaMode_ == 2.) {
|
|
39
|
-
return mix(_background_, _foreground_, _foreground_.a);
|
|
40
|
-
}
|
|
41
|
-
else if (_alphaMode_ == 3.) {
|
|
42
|
-
return _background_ - _foreground_ * _background_;
|
|
43
|
-
}
|
|
44
|
-
else if (_alphaMode_ == 4.) {
|
|
45
|
-
return _foreground_ * _background_;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return _background_;
|
|
19
|
+
vec4 _composition_(vec2 vUV) {
|
|
20
|
+
vec4 _background_ = texture2D(_background_, vUV);
|
|
21
|
+
|
|
22
|
+
vec2 transformedUV = vUV * (1.0 / _scaleUV_) + _translateUV_;
|
|
23
|
+
if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
|
|
24
|
+
return _background_;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec4 _foreground_ = texture2D(_foreground_, transformedUV);
|
|
28
|
+
_foreground_.a *= _foregroundAlphaScale_;
|
|
29
|
+
|
|
30
|
+
// SRC is _foreground_, DEST is _background_
|
|
31
|
+
if (_alphaMode_ == 0.) {
|
|
32
|
+
return _foreground_;
|
|
33
|
+
}
|
|
34
|
+
else if (_alphaMode_ == 1.) {
|
|
35
|
+
return _foreground_.a * _foreground_ + _background_;
|
|
36
|
+
}
|
|
37
|
+
else if (_alphaMode_ == 2.) {
|
|
38
|
+
return mix(_background_, _foreground_, _foreground_.a);
|
|
39
|
+
}
|
|
40
|
+
else if (_alphaMode_ == 3.) {
|
|
41
|
+
return _background_ - _foreground_ * _background_;
|
|
42
|
+
}
|
|
43
|
+
else if (_alphaMode_ == 4.) {
|
|
44
|
+
return _foreground_ * _background_;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return _background_;
|
|
49
48
|
}
|
|
50
49
|
`,
|
|
51
50
|
params: "vec2 vUV",
|
|
@@ -62,7 +61,6 @@ const Uniforms = {
|
|
|
62
61
|
foreground: "foreground",
|
|
63
62
|
scaleUV: "scaleUV",
|
|
64
63
|
translateUV: "translateUV",
|
|
65
|
-
alphaMode: "alphaMode",
|
|
66
64
|
foregroundAlphaScale: "foregroundAlphaScale",
|
|
67
65
|
};
|
|
68
66
|
export { BlockShaderProgram, Uniforms };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compositionBlock.fragment.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.fragment.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACtC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"compositionBlock.fragment.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.fragment.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACtC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;;;;kDAKiC;QAC1C,gBAAgB,EAAE,cAAc;QAChC,gBAAgB,EAAE,eAAe;QACjC,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+BD;gBACL,MAAM,EAAE,UAAU;aACrB;SACJ;KACJ;CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG;IACb,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,oBAAoB,EAAE,sBAAsB;CAC/C,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;AACxC,0CAA0C;AAC1C,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,QAAQ,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import { __decorate } from "@onerjs/core/tslib.es6.js";
|
|
3
|
-
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, PropertyTypeForEdition, editableInPropertyPage, } from "@onerjs/smart-filters";
|
|
3
|
+
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, PropertyTypeForEdition, editableInPropertyPage, CloneShaderProgram, } from "@onerjs/smart-filters";
|
|
4
4
|
import { compositionBlockType } from "../../../blockTypes.js";
|
|
5
5
|
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
6
6
|
import { uniforms, shaderProgram } from "./compositionBlock.fragment.js";
|
|
@@ -30,9 +30,8 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
30
30
|
* @param foregroundWidth - the width of the foreground texture
|
|
31
31
|
* @param foregroundHeight - the height of the foreground texture
|
|
32
32
|
* @param foregroundAlphaScale - the alpha scale of the foreground texture
|
|
33
|
-
* @param alphaMode - the alpha mode to use
|
|
34
33
|
*/
|
|
35
|
-
constructor(parentBlock, backgroundTexture, foregroundTexture, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale
|
|
34
|
+
constructor(parentBlock, backgroundTexture, foregroundTexture, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale) {
|
|
36
35
|
super(parentBlock);
|
|
37
36
|
this._backgroundTexture = backgroundTexture;
|
|
38
37
|
this._foregroundTexture = foregroundTexture;
|
|
@@ -41,7 +40,6 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
41
40
|
this._foregroundWidth = foregroundWidth;
|
|
42
41
|
this._foregroundHeight = foregroundHeight;
|
|
43
42
|
this._foregroundAlphaScale = foregroundAlphaScale;
|
|
44
|
-
this._alphaMode = alphaMode;
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
47
45
|
* Binds all the required data to the shader when rendering.
|
|
@@ -58,8 +56,6 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
58
56
|
const foregroundWidth = this._foregroundWidth.value;
|
|
59
57
|
const foregroundHeight = this._foregroundHeight.value;
|
|
60
58
|
const foregroundAlphaScale = this._foregroundAlphaScale.value;
|
|
61
|
-
const alphaMode = this._alphaMode;
|
|
62
|
-
effect.setFloat(this.getRemappedName(uniforms.alphaMode), alphaMode);
|
|
63
59
|
effect.setTexture(this.getRemappedName(uniforms.background), background);
|
|
64
60
|
effect.setTexture(this.getRemappedName(uniforms.foreground), foreground);
|
|
65
61
|
// NOTE: textures may always be undefined if connected to another shader block when the graph is optimized
|
|
@@ -80,6 +76,19 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
80
76
|
* - ALPHA_MULTIPLY: alpha blending is SRC * DEST
|
|
81
77
|
*/
|
|
82
78
|
export class CompositionBlock extends DisableableShaderBlock {
|
|
79
|
+
/**
|
|
80
|
+
* Gets the shader program to use to render the block.
|
|
81
|
+
* This adds the per-instance const values to the shader program.
|
|
82
|
+
* @returns The shader program to use to render the block
|
|
83
|
+
*/
|
|
84
|
+
getShaderProgram() {
|
|
85
|
+
const staticShaderProgram = super.getShaderProgram();
|
|
86
|
+
// Since we are making changes only for this instance of the block, and
|
|
87
|
+
// the disableableShaderProgram is static, we make a copy and modify that.
|
|
88
|
+
const shaderProgramForThisInstance = CloneShaderProgram(staticShaderProgram);
|
|
89
|
+
shaderProgramForThisInstance.fragment.constPerInstance = `const float _alphaMode_ = ${this.alphaMode.toFixed(1)};`;
|
|
90
|
+
return shaderProgramForThisInstance;
|
|
91
|
+
}
|
|
83
92
|
/**
|
|
84
93
|
* Instantiates a new Block.
|
|
85
94
|
* @param smartFilter - The smart filter this block belongs to
|
|
@@ -132,8 +141,7 @@ export class CompositionBlock extends DisableableShaderBlock {
|
|
|
132
141
|
const foregroundHeight = this.foregroundHeight.runtimeData;
|
|
133
142
|
const foregroundTop = this.foregroundTop.runtimeData;
|
|
134
143
|
const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
|
|
135
|
-
|
|
136
|
-
return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale, alphaMode);
|
|
144
|
+
return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale);
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compositionBlock.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.ts"],"names":[],"mappings":"AAAA,yDAAyD;;AAGzD,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EAEnB,sBAAsB,EAEtB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"compositionBlock.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.ts"],"names":[],"mappings":"AAAA,yDAAyD;;AAGzD,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EAEnB,sBAAsB,EAEtB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GACrB,8BAAsB;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEzE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,uDAAuD;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,gDAAgD;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC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CAAC;QACrD,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC;QAEnE,OAAO,IAAI,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IAC9J,CAAC;;AAxGD;;GAEG;AACoB,0BAAS,GAAG,oBAAoB,AAAvB,CAAwB;AAExD;;GAEG;AACoB,0BAAS,GAAG,2BAA2B,AAA9B,CAA+B;AAoD/D;;GAEG;AACoB,2BAAU,GAAG,aAAa,AAAhB,CAAiB;AAL3C;IAVN,sBAAsB,CAAC,YAAY,EAAE,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE;QAC7E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE;YAC1C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;YAClC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE;YAC1C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;YAC5C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;SAC/C;KACJ,CAAC;mDACuC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onerjs/smart-filters-blocks",
|
|
3
|
-
"version": "8.31.
|
|
3
|
+
"version": "8.31.7",
|
|
4
4
|
"description": "Babylon.js Smart Filter Block Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"video",
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"@onerjs/core": "^7.47.3 || ^8.0.1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@onerjs/smart-filters": "^8.31.
|
|
52
|
+
"@onerjs/smart-filters": "^8.31.7"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
uniform sampler2D background; // main
|
|
2
|
-
uniform sampler2D foreground;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
uniform
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
uniform sampler2D background; // main
|
|
2
|
+
uniform sampler2D foreground;
|
|
3
|
+
|
|
4
|
+
// { "property": true }
|
|
5
|
+
const float alphaMode = 1;
|
|
6
|
+
|
|
7
|
+
uniform vec2 scaleUV;
|
|
8
|
+
uniform vec2 translateUV;
|
|
9
|
+
uniform float foregroundAlphaScale;
|
|
10
|
+
|
|
11
|
+
vec4 composition(vec2 vUV) { // main
|
|
12
|
+
vec4 background = texture2D(background, vUV);
|
|
13
|
+
|
|
14
|
+
vec2 transformedUV = vUV * (1.0 / scaleUV) + translateUV;
|
|
15
|
+
if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
|
|
16
|
+
return background;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
vec4 foreground = texture2D(foreground, transformedUV);
|
|
20
|
+
foreground.a *= foregroundAlphaScale;
|
|
21
|
+
|
|
22
|
+
// SRC is foreground, DEST is background
|
|
23
|
+
if (alphaMode == 0.) {
|
|
24
|
+
return foreground;
|
|
25
|
+
}
|
|
26
|
+
else if (alphaMode == 1.) {
|
|
27
|
+
return foreground.a * foreground + background;
|
|
28
|
+
}
|
|
29
|
+
else if (alphaMode == 2.) {
|
|
30
|
+
return mix(background, foreground, foreground.a);
|
|
31
|
+
}
|
|
32
|
+
else if (alphaMode == 3.) {
|
|
33
|
+
return background - foreground * background;
|
|
34
|
+
}
|
|
35
|
+
else if (alphaMode == 4.) {
|
|
36
|
+
return foreground * background;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return background;
|
|
38
40
|
}
|
|
@@ -11,7 +11,6 @@ const BlockShaderProgram: ShaderProgram = {
|
|
|
11
11
|
uniform sampler2D _foreground_;
|
|
12
12
|
uniform vec2 _scaleUV_;
|
|
13
13
|
uniform vec2 _translateUV_;
|
|
14
|
-
uniform float _alphaMode_;
|
|
15
14
|
uniform float _foregroundAlphaScale_;`,
|
|
16
15
|
mainInputTexture: "_background_",
|
|
17
16
|
mainFunctionName: "_composition_",
|
|
@@ -19,35 +18,35 @@ const BlockShaderProgram: ShaderProgram = {
|
|
|
19
18
|
{
|
|
20
19
|
name: "_composition_",
|
|
21
20
|
code: `
|
|
22
|
-
vec4 _composition_(vec2 vUV) {
|
|
23
|
-
vec4 _background_ = texture2D(_background_, vUV);
|
|
24
|
-
|
|
25
|
-
vec2 transformedUV = vUV * (1.0 / _scaleUV_) + _translateUV_;
|
|
26
|
-
if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
|
|
27
|
-
return _background_;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
vec4 _foreground_ = texture2D(_foreground_, transformedUV);
|
|
31
|
-
_foreground_.a *= _foregroundAlphaScale_;
|
|
32
|
-
|
|
33
|
-
// SRC is _foreground_, DEST is _background_
|
|
34
|
-
if (_alphaMode_ == 0.) {
|
|
35
|
-
return _foreground_;
|
|
36
|
-
}
|
|
37
|
-
else if (_alphaMode_ == 1.) {
|
|
38
|
-
return _foreground_.a * _foreground_ + _background_;
|
|
39
|
-
}
|
|
40
|
-
else if (_alphaMode_ == 2.) {
|
|
41
|
-
return mix(_background_, _foreground_, _foreground_.a);
|
|
42
|
-
}
|
|
43
|
-
else if (_alphaMode_ == 3.) {
|
|
44
|
-
return _background_ - _foreground_ * _background_;
|
|
45
|
-
}
|
|
46
|
-
else if (_alphaMode_ == 4.) {
|
|
47
|
-
return _foreground_ * _background_;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return _background_;
|
|
21
|
+
vec4 _composition_(vec2 vUV) {
|
|
22
|
+
vec4 _background_ = texture2D(_background_, vUV);
|
|
23
|
+
|
|
24
|
+
vec2 transformedUV = vUV * (1.0 / _scaleUV_) + _translateUV_;
|
|
25
|
+
if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
|
|
26
|
+
return _background_;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
vec4 _foreground_ = texture2D(_foreground_, transformedUV);
|
|
30
|
+
_foreground_.a *= _foregroundAlphaScale_;
|
|
31
|
+
|
|
32
|
+
// SRC is _foreground_, DEST is _background_
|
|
33
|
+
if (_alphaMode_ == 0.) {
|
|
34
|
+
return _foreground_;
|
|
35
|
+
}
|
|
36
|
+
else if (_alphaMode_ == 1.) {
|
|
37
|
+
return _foreground_.a * _foreground_ + _background_;
|
|
38
|
+
}
|
|
39
|
+
else if (_alphaMode_ == 2.) {
|
|
40
|
+
return mix(_background_, _foreground_, _foreground_.a);
|
|
41
|
+
}
|
|
42
|
+
else if (_alphaMode_ == 3.) {
|
|
43
|
+
return _background_ - _foreground_ * _background_;
|
|
44
|
+
}
|
|
45
|
+
else if (_alphaMode_ == 4.) {
|
|
46
|
+
return _foreground_ * _background_;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return _background_;
|
|
51
50
|
}
|
|
52
51
|
`,
|
|
53
52
|
params: "vec2 vUV",
|
|
@@ -65,7 +64,6 @@ const Uniforms = {
|
|
|
65
64
|
foreground: "foreground",
|
|
66
65
|
scaleUV: "scaleUV",
|
|
67
66
|
translateUV: "translateUV",
|
|
68
|
-
alphaMode: "alphaMode",
|
|
69
67
|
foregroundAlphaScale: "foregroundAlphaScale",
|
|
70
68
|
};
|
|
71
69
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
createStrongRef,
|
|
12
12
|
PropertyTypeForEdition,
|
|
13
13
|
editableInPropertyPage,
|
|
14
|
+
CloneShaderProgram,
|
|
14
15
|
} from "smart-filters";
|
|
15
16
|
import { compositionBlockType } from "../../../blockTypes.js";
|
|
16
17
|
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
@@ -40,7 +41,6 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
40
41
|
private readonly _foregroundWidth: RuntimeData<ConnectionPointType.Float>;
|
|
41
42
|
private readonly _foregroundHeight: RuntimeData<ConnectionPointType.Float>;
|
|
42
43
|
private readonly _foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>;
|
|
43
|
-
private readonly _alphaMode: number;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Creates a new shader binding instance for the Composition block.
|
|
@@ -52,7 +52,6 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
52
52
|
* @param foregroundWidth - the width of the foreground texture
|
|
53
53
|
* @param foregroundHeight - the height of the foreground texture
|
|
54
54
|
* @param foregroundAlphaScale - the alpha scale of the foreground texture
|
|
55
|
-
* @param alphaMode - the alpha mode to use
|
|
56
55
|
*/
|
|
57
56
|
constructor(
|
|
58
57
|
parentBlock: IDisableableBlock,
|
|
@@ -62,8 +61,7 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
62
61
|
foregroundLeft: RuntimeData<ConnectionPointType.Float>,
|
|
63
62
|
foregroundWidth: RuntimeData<ConnectionPointType.Float>,
|
|
64
63
|
foregroundHeight: RuntimeData<ConnectionPointType.Float>,
|
|
65
|
-
foregroundAlphaScale: RuntimeData<ConnectionPointType.Float
|
|
66
|
-
alphaMode: number
|
|
64
|
+
foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>
|
|
67
65
|
) {
|
|
68
66
|
super(parentBlock);
|
|
69
67
|
this._backgroundTexture = backgroundTexture;
|
|
@@ -73,7 +71,6 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
73
71
|
this._foregroundWidth = foregroundWidth;
|
|
74
72
|
this._foregroundHeight = foregroundHeight;
|
|
75
73
|
this._foregroundAlphaScale = foregroundAlphaScale;
|
|
76
|
-
this._alphaMode = alphaMode;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
/**
|
|
@@ -92,9 +89,7 @@ export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
|
92
89
|
const foregroundWidth = this._foregroundWidth.value;
|
|
93
90
|
const foregroundHeight = this._foregroundHeight.value;
|
|
94
91
|
const foregroundAlphaScale = this._foregroundAlphaScale.value;
|
|
95
|
-
const alphaMode = this._alphaMode;
|
|
96
92
|
|
|
97
|
-
effect.setFloat(this.getRemappedName(uniforms.alphaMode), alphaMode);
|
|
98
93
|
effect.setTexture(this.getRemappedName(uniforms.background), background);
|
|
99
94
|
effect.setTexture(this.getRemappedName(uniforms.foreground), foreground);
|
|
100
95
|
|
|
@@ -183,6 +178,22 @@ export class CompositionBlock extends DisableableShaderBlock {
|
|
|
183
178
|
*/
|
|
184
179
|
public static override ShaderCode = shaderProgram;
|
|
185
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Gets the shader program to use to render the block.
|
|
183
|
+
* This adds the per-instance const values to the shader program.
|
|
184
|
+
* @returns The shader program to use to render the block
|
|
185
|
+
*/
|
|
186
|
+
public override getShaderProgram() {
|
|
187
|
+
const staticShaderProgram = super.getShaderProgram();
|
|
188
|
+
|
|
189
|
+
// Since we are making changes only for this instance of the block, and
|
|
190
|
+
// the disableableShaderProgram is static, we make a copy and modify that.
|
|
191
|
+
const shaderProgramForThisInstance = CloneShaderProgram(staticShaderProgram);
|
|
192
|
+
shaderProgramForThisInstance.fragment.constPerInstance = `const float _alphaMode_ = ${this.alphaMode.toFixed(1)};`;
|
|
193
|
+
|
|
194
|
+
return shaderProgramForThisInstance;
|
|
195
|
+
}
|
|
196
|
+
|
|
186
197
|
/**
|
|
187
198
|
* Instantiates a new Block.
|
|
188
199
|
* @param smartFilter - The smart filter this block belongs to
|
|
@@ -204,8 +215,7 @@ export class CompositionBlock extends DisableableShaderBlock {
|
|
|
204
215
|
const foregroundHeight = this.foregroundHeight.runtimeData;
|
|
205
216
|
const foregroundTop = this.foregroundTop.runtimeData;
|
|
206
217
|
const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
|
|
207
|
-
const alphaMode = this.alphaMode;
|
|
208
218
|
|
|
209
|
-
return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale
|
|
219
|
+
return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale);
|
|
210
220
|
}
|
|
211
221
|
}
|