@onerjs/smart-filters-blocks 8.25.1 → 8.25.3
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/blackAndWhiteBlock.block.d.ts +34 -0
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js +100 -0
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts +53 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts +28 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js +15 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.js +93 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts +8 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js +28 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts +116 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts +24 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js +14 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts +20 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js +71 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.js +163 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts +6 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js +25 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts +39 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.js +137 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts +39 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js +114 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts +76 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts +32 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js +16 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js +162 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts +6 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js +27 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts +38 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.js +106 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts +46 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js +132 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/index.d.ts +15 -0
- package/dist/blocks/babylon/demo/effects/index.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/index.js +15 -0
- package/dist/blocks/babylon/demo/effects/index.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts +63 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js +158 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts +38 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.js +109 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts +44 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js +129 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts +39 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js +115 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts +77 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts +20 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js +60 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js +98 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts +7 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.js +51 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/transitions/index.d.ts +2 -0
- package/dist/blocks/babylon/demo/transitions/index.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/transitions/index.js +2 -0
- package/dist/blocks/babylon/demo/transitions/index.js.map +1 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts +42 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js +115 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/utilities/index.d.ts +2 -0
- package/dist/blocks/babylon/demo/utilities/index.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/utilities/index.js +2 -0
- package/dist/blocks/babylon/demo/utilities/index.js.map +1 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts +34 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js +96 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js.map +1 -0
- package/dist/blocks/blockNamespaces.d.ts +5 -0
- package/dist/blocks/blockNamespaces.d.ts.map +1 -0
- package/dist/blocks/blockNamespaces.js +7 -0
- package/dist/blocks/blockNamespaces.js.map +1 -0
- package/dist/blocks/blockTypes.d.ts +22 -0
- package/dist/blocks/blockTypes.d.ts.map +1 -0
- package/dist/blocks/blockTypes.js +24 -0
- package/dist/blocks/blockTypes.js.map +1 -0
- package/dist/blocks/index.d.ts +6 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +7 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/registration/IBlockRegistration.d.ts +38 -0
- package/dist/registration/IBlockRegistration.d.ts.map +1 -0
- package/dist/registration/IBlockRegistration.js +2 -0
- package/dist/registration/IBlockRegistration.js.map +1 -0
- package/dist/registration/blockSerializers.d.ts +13 -0
- package/dist/registration/blockSerializers.d.ts.map +1 -0
- package/dist/registration/blockSerializers.js +33 -0
- package/dist/registration/blockSerializers.js.map +1 -0
- package/dist/registration/builtInBlockRegistrations.d.ts +13 -0
- package/dist/registration/builtInBlockRegistrations.d.ts.map +1 -0
- package/dist/registration/builtInBlockRegistrations.js +273 -0
- package/dist/registration/builtInBlockRegistrations.js.map +1 -0
- package/dist/registration/index.d.ts +4 -0
- package/dist/registration/index.d.ts.map +1 -0
- package/dist/registration/index.js +5 -0
- package/dist/registration/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shader program for the block.
|
|
3
|
+
*/
|
|
4
|
+
const BlockShaderProgram = {
|
|
5
|
+
vertex: undefined,
|
|
6
|
+
fragment: {
|
|
7
|
+
uniform: `
|
|
8
|
+
uniform sampler2D _background_; // main
|
|
9
|
+
uniform sampler2D _foreground_;
|
|
10
|
+
uniform vec2 _scaleUV_;
|
|
11
|
+
uniform vec2 _translateUV_;
|
|
12
|
+
uniform float _alphaMode_;
|
|
13
|
+
uniform float _foregroundAlphaScale_;`,
|
|
14
|
+
mainInputTexture: "_background_",
|
|
15
|
+
mainFunctionName: "_composition_",
|
|
16
|
+
functions: [
|
|
17
|
+
{
|
|
18
|
+
name: "_composition_",
|
|
19
|
+
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_;
|
|
49
|
+
}
|
|
50
|
+
`,
|
|
51
|
+
params: "vec2 vUV",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
58
|
+
* that the names are always in sync.
|
|
59
|
+
*/
|
|
60
|
+
const Uniforms = {
|
|
61
|
+
background: "background",
|
|
62
|
+
foreground: "foreground",
|
|
63
|
+
scaleUV: "scaleUV",
|
|
64
|
+
translateUV: "translateUV",
|
|
65
|
+
alphaMode: "alphaMode",
|
|
66
|
+
foregroundAlphaScale: "foregroundAlphaScale",
|
|
67
|
+
};
|
|
68
|
+
export { BlockShaderProgram, Uniforms };
|
|
69
|
+
// Back compat for when camelCase was used
|
|
70
|
+
export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
|
|
71
|
+
//# sourceMappingURL=compositionBlock.fragment.js.map
|
|
@@ -0,0 +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;;;;;;kDAMiC;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,SAAS,EAAE,WAAW;IACtB,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"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { __decorate } from "@onerjs/core/tslib.es6.js";
|
|
3
|
+
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, PropertyTypeForEdition, editableInPropertyPage, } from "@onerjs/smart-filters";
|
|
4
|
+
import { compositionBlockType } from "../../../blockTypes.js";
|
|
5
|
+
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
6
|
+
import { uniforms, shaderProgram } from "./compositionBlock.fragment.js";
|
|
7
|
+
/** Defines that alpha blending is disabled */
|
|
8
|
+
export const ALPHA_DISABLE = 0;
|
|
9
|
+
/** Defines that alpha blending is SRC ALPHA * SRC + DEST */
|
|
10
|
+
export const ALPHA_ADD = 1;
|
|
11
|
+
/** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
|
|
12
|
+
export const ALPHA_COMBINE = 2;
|
|
13
|
+
/** Defines that alpha blending is DEST - SRC * DEST */
|
|
14
|
+
export const ALPHA_SUBTRACT = 3;
|
|
15
|
+
/** Defines that alpha blending is SRC * DEST */
|
|
16
|
+
export const ALPHA_MULTIPLY = 4;
|
|
17
|
+
/**
|
|
18
|
+
* The shader bindings for the Composition block.
|
|
19
|
+
* This demonstrates how multiple input connection point values can be packed into a single
|
|
20
|
+
* uniform.
|
|
21
|
+
*/
|
|
22
|
+
export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new shader binding instance for the Composition block.
|
|
25
|
+
* @param parentBlock - The parent block
|
|
26
|
+
* @param backgroundTexture - the background texture
|
|
27
|
+
* @param foregroundTexture - the foreground texture
|
|
28
|
+
* @param foregroundTop - the top position of the foreground texture
|
|
29
|
+
* @param foregroundLeft - the left position of the foreground texture
|
|
30
|
+
* @param foregroundWidth - the width of the foreground texture
|
|
31
|
+
* @param foregroundHeight - the height of the foreground texture
|
|
32
|
+
* @param foregroundAlphaScale - the alpha scale of the foreground texture
|
|
33
|
+
* @param alphaMode - the alpha mode to use
|
|
34
|
+
*/
|
|
35
|
+
constructor(parentBlock, backgroundTexture, foregroundTexture, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale, alphaMode) {
|
|
36
|
+
super(parentBlock);
|
|
37
|
+
this._backgroundTexture = backgroundTexture;
|
|
38
|
+
this._foregroundTexture = foregroundTexture;
|
|
39
|
+
this._foregroundTop = foregroundTop;
|
|
40
|
+
this._foregroundLeft = foregroundLeft;
|
|
41
|
+
this._foregroundWidth = foregroundWidth;
|
|
42
|
+
this._foregroundHeight = foregroundHeight;
|
|
43
|
+
this._foregroundAlphaScale = foregroundAlphaScale;
|
|
44
|
+
this._alphaMode = alphaMode;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Binds all the required data to the shader when rendering.
|
|
48
|
+
* @param effect - defines the effect to bind the data to
|
|
49
|
+
* @param width - defines the width of the output
|
|
50
|
+
* @param height - defines the height of the output
|
|
51
|
+
*/
|
|
52
|
+
bind(effect, width, height) {
|
|
53
|
+
super.bind(effect, width, height);
|
|
54
|
+
const background = this._backgroundTexture.value;
|
|
55
|
+
const foreground = this._foregroundTexture.value;
|
|
56
|
+
const foregroundTop = this._foregroundTop.value;
|
|
57
|
+
const foregroundLeft = this._foregroundLeft.value;
|
|
58
|
+
const foregroundWidth = this._foregroundWidth.value;
|
|
59
|
+
const foregroundHeight = this._foregroundHeight.value;
|
|
60
|
+
const foregroundAlphaScale = this._foregroundAlphaScale.value;
|
|
61
|
+
const alphaMode = this._alphaMode;
|
|
62
|
+
effect.setFloat(this.getRemappedName(uniforms.alphaMode), alphaMode);
|
|
63
|
+
effect.setTexture(this.getRemappedName(uniforms.background), background);
|
|
64
|
+
effect.setTexture(this.getRemappedName(uniforms.foreground), foreground);
|
|
65
|
+
// NOTE: textures may always be undefined if connected to another shader block when the graph is optimized
|
|
66
|
+
effect.setFloat2(this.getRemappedName(uniforms.scaleUV), foregroundWidth, foregroundHeight);
|
|
67
|
+
effect.setFloat2(this.getRemappedName(uniforms.translateUV), -1 * foregroundLeft, foregroundTop);
|
|
68
|
+
effect.setFloat(this.getRemappedName(uniforms.foregroundAlphaScale), foregroundAlphaScale);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A simple compositing Block letting the filter "blend" 2 different layers.
|
|
73
|
+
* It demonstrates how a block can use properties for values which will not change at runtime (alphaMode)
|
|
74
|
+
*
|
|
75
|
+
* The alpha mode of the block can be set to one of the following:
|
|
76
|
+
* - ALPHA_DISABLE: alpha blending is disabled
|
|
77
|
+
* - ALPHA_ADD: alpha blending is SRC ALPHA * SRC + DEST
|
|
78
|
+
* - ALPHA_COMBINE: alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST
|
|
79
|
+
* - ALPHA_SUBTRACT: alpha blending is DEST - SRC * DEST
|
|
80
|
+
* - ALPHA_MULTIPLY: alpha blending is SRC * DEST
|
|
81
|
+
*/
|
|
82
|
+
export class CompositionBlock extends DisableableShaderBlock {
|
|
83
|
+
/**
|
|
84
|
+
* Instantiates a new Block.
|
|
85
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
86
|
+
* @param name - The friendly name of the block
|
|
87
|
+
*/
|
|
88
|
+
constructor(smartFilter, name) {
|
|
89
|
+
super(smartFilter, name, true);
|
|
90
|
+
/**
|
|
91
|
+
* The background texture to composite on to.
|
|
92
|
+
*/
|
|
93
|
+
this.background = this._registerInput(uniforms.background, ConnectionPointType.Texture);
|
|
94
|
+
/**
|
|
95
|
+
* The foreground texture to composite in.
|
|
96
|
+
*/
|
|
97
|
+
this.foreground = this._registerOptionalInput(uniforms.foreground, ConnectionPointType.Texture, createStrongRef(null));
|
|
98
|
+
/**
|
|
99
|
+
* Defines where the top of the texture to composite in should be displayed. (between 0 and 1).
|
|
100
|
+
*/
|
|
101
|
+
this.foregroundTop = this._registerOptionalInput("foregroundTop", ConnectionPointType.Float, createStrongRef(0.0));
|
|
102
|
+
/**
|
|
103
|
+
* Defines where the left of the texture to composite in should be displayed. (between 0 and 1).
|
|
104
|
+
*/
|
|
105
|
+
this.foregroundLeft = this._registerOptionalInput("foregroundLeft", ConnectionPointType.Float, createStrongRef(0.0));
|
|
106
|
+
/**
|
|
107
|
+
* Defines the width of the texture in the composition.
|
|
108
|
+
*/
|
|
109
|
+
this.foregroundWidth = this._registerOptionalInput("foregroundWidth", ConnectionPointType.Float, createStrongRef(1.0));
|
|
110
|
+
/**
|
|
111
|
+
* Defines the height of the texture in the composition.
|
|
112
|
+
*/
|
|
113
|
+
this.foregroundHeight = this._registerOptionalInput("foregroundHeight", ConnectionPointType.Float, createStrongRef(1.0));
|
|
114
|
+
/**
|
|
115
|
+
* Defines a multiplier applied to the foreground's alpha channel.
|
|
116
|
+
*/
|
|
117
|
+
this.foregroundAlphaScale = this._registerOptionalInput(uniforms.foregroundAlphaScale, ConnectionPointType.Float, createStrongRef(1.0));
|
|
118
|
+
/**
|
|
119
|
+
* Defines blend mode of the composition.
|
|
120
|
+
*/
|
|
121
|
+
this.alphaMode = ALPHA_COMBINE;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
125
|
+
* @returns The class instance that binds the data to the effect
|
|
126
|
+
*/
|
|
127
|
+
getShaderBinding() {
|
|
128
|
+
const background = this._confirmRuntimeDataSupplied(this.background);
|
|
129
|
+
const foreground = this._confirmRuntimeDataSupplied(this.foreground);
|
|
130
|
+
const foregroundWidth = this.foregroundWidth.runtimeData;
|
|
131
|
+
const foregroundLeft = this.foregroundLeft.runtimeData;
|
|
132
|
+
const foregroundHeight = this.foregroundHeight.runtimeData;
|
|
133
|
+
const foregroundTop = this.foregroundTop.runtimeData;
|
|
134
|
+
const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
|
|
135
|
+
const alphaMode = this.alphaMode;
|
|
136
|
+
return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale, alphaMode);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The class name of the block.
|
|
141
|
+
*/
|
|
142
|
+
CompositionBlock.ClassName = compositionBlockType;
|
|
143
|
+
/**
|
|
144
|
+
* The namespace of the block.
|
|
145
|
+
*/
|
|
146
|
+
CompositionBlock.Namespace = babylonDemoEffectsNamespace;
|
|
147
|
+
/**
|
|
148
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
149
|
+
*/
|
|
150
|
+
CompositionBlock.ShaderCode = shaderProgram;
|
|
151
|
+
__decorate([
|
|
152
|
+
editableInPropertyPage("Alpha Mode", PropertyTypeForEdition.List, "PROPERTIES", {
|
|
153
|
+
notifiers: { rebuild: true },
|
|
154
|
+
options: [
|
|
155
|
+
{ label: "Disable", value: ALPHA_DISABLE },
|
|
156
|
+
{ label: "Add", value: ALPHA_ADD },
|
|
157
|
+
{ label: "Combine", value: ALPHA_COMBINE },
|
|
158
|
+
{ label: "Subtract", value: ALPHA_SUBTRACT },
|
|
159
|
+
{ label: "Multiply", value: ALPHA_MULTIPLY },
|
|
160
|
+
],
|
|
161
|
+
})
|
|
162
|
+
], CompositionBlock.prototype, "alphaMode", void 0);
|
|
163
|
+
//# sourceMappingURL=compositionBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionBlock.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.ts"],"names":[],"mappings":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AAE,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionBlock.serializer.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.serializer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAa,8BAAsB;AAEnE;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,kBAmBxC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { compositionBlockType } from "../../../blockTypes.js";
|
|
2
|
+
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* The V1 serializer for a Composition Block
|
|
5
|
+
*/
|
|
6
|
+
export const CompositionBlockSerializer = {
|
|
7
|
+
blockType: compositionBlockType,
|
|
8
|
+
serialize: (block) => {
|
|
9
|
+
if (block.getClassName() !== compositionBlockType) {
|
|
10
|
+
throw new Error("Was asked to serialize an unrecognized block type");
|
|
11
|
+
}
|
|
12
|
+
const compositionBlock = block;
|
|
13
|
+
return {
|
|
14
|
+
name: block.name,
|
|
15
|
+
uniqueId: block.uniqueId,
|
|
16
|
+
blockType: compositionBlockType,
|
|
17
|
+
namespace: babylonDemoEffectsNamespace,
|
|
18
|
+
comments: block.comments,
|
|
19
|
+
data: {
|
|
20
|
+
alphaMode: compositionBlock.alphaMode,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=compositionBlock.serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositionBlock.serializer.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.serializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAG1E;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAuB;IAC1D,SAAS,EAAE,oBAAoB;IAC/B,SAAS,EAAE,CAAC,KAAgB,EAAE,EAAE;QAC5B,IAAI,KAAK,CAAC,YAAY,EAAE,KAAK,oBAAoB,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,gBAAgB,GAAG,KAAoC,CAAC;QAC9D,OAAO;YACH,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,oBAAoB;YAC/B,SAAS,EAAE,2BAA2B;YACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE;gBACF,SAAS,EAAE,gBAAgB,CAAC,SAAS;aACxC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DisableableShaderBinding, ConnectionPointType, type SmartFilter, DisableableShaderBlock, type ShaderProgram } from "@onerjs/smart-filters";
|
|
2
|
+
/**
|
|
3
|
+
* The implementation of the ContrastBlock
|
|
4
|
+
*/
|
|
5
|
+
export declare class ContrastBlock extends DisableableShaderBlock {
|
|
6
|
+
/**
|
|
7
|
+
* The class name of the block.
|
|
8
|
+
*/
|
|
9
|
+
static ClassName: string;
|
|
10
|
+
/**
|
|
11
|
+
* The namespace of the block.
|
|
12
|
+
*/
|
|
13
|
+
static Namespace: string;
|
|
14
|
+
/**
|
|
15
|
+
* The input connection point.
|
|
16
|
+
*/
|
|
17
|
+
readonly input: import("@onerjs/smart-filters").ConnectionPoint<ConnectionPointType.Texture>;
|
|
18
|
+
/**
|
|
19
|
+
/**
|
|
20
|
+
* The intensity connection point.
|
|
21
|
+
*/
|
|
22
|
+
readonly intensity: import("dev/smartFilters/dist/connection/connectionPointWithDefault").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
23
|
+
/**
|
|
24
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
25
|
+
*/
|
|
26
|
+
static ShaderCode: ShaderProgram;
|
|
27
|
+
/**
|
|
28
|
+
* Instantiates a new ContrastBlock.
|
|
29
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
30
|
+
* @param name - The friendly name of the block
|
|
31
|
+
*/
|
|
32
|
+
constructor(smartFilter: SmartFilter, name: string);
|
|
33
|
+
/**
|
|
34
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
35
|
+
* @returns The class instance that binds the data to the effect
|
|
36
|
+
*/
|
|
37
|
+
getShaderBinding(): DisableableShaderBinding;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=contrastBlock.block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrastBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/contrastBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EACnB,KAAK,WAAW,EAChB,sBAAsB,EACtB,KAAK,aAAa,EAGG,8BAAsB;AAsG/C;;GAEG;AACH,qBAAa,aAAc,SAAQ,sBAAsB;IACrD;;OAEG;IACH,OAAuB,SAAS,SAAmB;IAEnD;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D;;OAEG;IACH,SAAgB,KAAK,+EAAoE;IAEzF;;;OAGG;IACH,SAAgB,SAAS,8HAIvB;IAEF;;OAEG;IACH,OAAuB,UAAU,gBAAsB;IAEvD;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,wBAAwB;CAMtD"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
// ************************************************************
|
|
3
|
+
// Note: this file is auto-generated, do not modify it directly
|
|
4
|
+
// ************************************************************
|
|
5
|
+
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, BlockDisableStrategy } from "@onerjs/smart-filters";
|
|
6
|
+
/**
|
|
7
|
+
* The shader program for the block.
|
|
8
|
+
*/
|
|
9
|
+
const BlockShaderProgram = {
|
|
10
|
+
vertex: undefined,
|
|
11
|
+
fragment: {
|
|
12
|
+
uniform: `
|
|
13
|
+
uniform sampler2D _input_; // main
|
|
14
|
+
uniform float _intensity_;`,
|
|
15
|
+
mainInputTexture: "_input_",
|
|
16
|
+
mainFunctionName: "_contrast_",
|
|
17
|
+
functions: [
|
|
18
|
+
{
|
|
19
|
+
name: "_contrast_",
|
|
20
|
+
code: `
|
|
21
|
+
vec4 _contrast_(vec2 vUV) {
|
|
22
|
+
vec4 color = texture2D(_input_, vUV);
|
|
23
|
+
|
|
24
|
+
float contrastLMin = mix(-2., 0., _intensity_ * 2.0);
|
|
25
|
+
float contrastLMax = mix(3., 1., _intensity_ * 2.0);
|
|
26
|
+
|
|
27
|
+
vec3 contrastMin = _remap_(color.rgb, contrastLMin, contrastLMax, 0., 1.);
|
|
28
|
+
|
|
29
|
+
float intensityMapped = _remap_(_intensity_, 0.5, 1., 0., 1.0);
|
|
30
|
+
float contrastHMin = mix(0., 0.45, intensityMapped);
|
|
31
|
+
float contrastHMax = mix(1., 0.5, intensityMapped);
|
|
32
|
+
|
|
33
|
+
vec3 contrastMax = _remap_(color.rgb, contrastHMin, contrastHMax, 0., 1.);
|
|
34
|
+
|
|
35
|
+
return vec4(mix(contrastMin, contrastMax, step(_intensity_, 0.5)), color.a);
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
params: "vec2 vUV",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "_remap_",
|
|
42
|
+
code: `
|
|
43
|
+
float _remap_(float i, float smin, float smax, float dmin, float dmax) {
|
|
44
|
+
return dmin + (i - smin) * (dmax - dmin) / (smax - smin);
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
params: "float i, float smin, float smax, float dmin, float dmax",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "_remap_",
|
|
51
|
+
code: `
|
|
52
|
+
vec3 _remap_(vec3 i, float smin, float smax, float dmin, float dmax) {
|
|
53
|
+
return dmin + (i - smin) * (dmax - dmin) / (smax - smin);
|
|
54
|
+
}
|
|
55
|
+
`,
|
|
56
|
+
params: "vec3 i, float smin, float smax, float dmin, float dmax",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
63
|
+
* that the names are always in sync.
|
|
64
|
+
*/
|
|
65
|
+
const Uniforms = {
|
|
66
|
+
input: "input",
|
|
67
|
+
intensity: "intensity",
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The shader binding for the ContrastBlock, used by the runtime
|
|
71
|
+
*/
|
|
72
|
+
class ContrastBlockShaderBinding extends DisableableShaderBinding {
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new shader binding instance for the block.
|
|
75
|
+
* @param parentBlock - IDisableableBlock
|
|
76
|
+
* @param input - The input runtime value
|
|
77
|
+
* @param intensity - The intensity runtime value
|
|
78
|
+
*/
|
|
79
|
+
constructor(parentBlock, input, intensity) {
|
|
80
|
+
super(parentBlock);
|
|
81
|
+
this._input = input;
|
|
82
|
+
this._intensity = intensity;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Binds all the required data to the shader when rendering.
|
|
86
|
+
* @param effect - defines the effect to bind the data to
|
|
87
|
+
*/
|
|
88
|
+
bind(effect) {
|
|
89
|
+
super.bind(effect);
|
|
90
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
91
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The implementation of the ContrastBlock
|
|
96
|
+
*/
|
|
97
|
+
export class ContrastBlock extends DisableableShaderBlock {
|
|
98
|
+
/**
|
|
99
|
+
* Instantiates a new ContrastBlock.
|
|
100
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
101
|
+
* @param name - The friendly name of the block
|
|
102
|
+
*/
|
|
103
|
+
constructor(smartFilter, name) {
|
|
104
|
+
super(smartFilter, name, false, BlockDisableStrategy.AutoSample);
|
|
105
|
+
/**
|
|
106
|
+
* The input connection point.
|
|
107
|
+
*/
|
|
108
|
+
this.input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
109
|
+
/**
|
|
110
|
+
/**
|
|
111
|
+
* The intensity connection point.
|
|
112
|
+
*/
|
|
113
|
+
this.intensity = this._registerOptionalInput("intensity", ConnectionPointType.Float, createStrongRef(0.5));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
117
|
+
* @returns The class instance that binds the data to the effect
|
|
118
|
+
*/
|
|
119
|
+
getShaderBinding() {
|
|
120
|
+
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
121
|
+
const intensity = this._confirmRuntimeDataSupplied(this.intensity);
|
|
122
|
+
return new ContrastBlockShaderBinding(this, input, intensity);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The class name of the block.
|
|
127
|
+
*/
|
|
128
|
+
ContrastBlock.ClassName = "ContrastBlock";
|
|
129
|
+
/**
|
|
130
|
+
* The namespace of the block.
|
|
131
|
+
*/
|
|
132
|
+
ContrastBlock.Namespace = "Babylon.Demo.Effects";
|
|
133
|
+
/**
|
|
134
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
135
|
+
*/
|
|
136
|
+
ContrastBlock.ShaderCode = BlockShaderProgram;
|
|
137
|
+
//# sourceMappingURL=contrastBlock.block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrastBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/contrastBlock.block.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+DAA+D;AAC/D,+DAA+D;AAC/D,+DAA+D;AAS/D,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EAEnB,sBAAsB,EAEtB,eAAe,EAEf,oBAAoB,EAAC,8BAAsB;AAE/C;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACtC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;uCAEsB;QAC/B,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,YAAY;QAC9B,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE;;;;;;;;;;;;;;;;;qBAiBD;gBACL,MAAM,EAAE,UAAU;aACrB;YACD;gBACI,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE;;;;qBAID;gBACL,MAAM,EAAE,yDAAyD;aACpE;YACD;gBACI,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE;;;;qBAID;gBACL,MAAM,EAAE,wDAAwD;aACnE;SACJ;KACJ;CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG;IACb,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;CACzB,CAAC;AAGF;;GAEG;AACH,MAAM,0BAA2B,SAAQ,wBAAwB;IAI7D;;;;;OAKG;IACH,YACI,WAA8B,EAC9B,KAA+C,EAC/C,SAAiD;QAEjD,KAAK,CAAC,WAAW,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAED;;;OAGG;IACa,IAAI,CAAC,MAAc;QAC/B,KAAK,CA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
1
|
+
import { DisableableShaderBinding, ConnectionPointType, type SmartFilter, DisableableShaderBlock, type ShaderProgram } from "@onerjs/smart-filters";
|
|
2
|
+
/**
|
|
3
|
+
* The implementation of the DesaturateBlock
|
|
4
|
+
*/
|
|
5
|
+
export declare class DesaturateBlock extends DisableableShaderBlock {
|
|
6
|
+
/**
|
|
7
|
+
* The class name of the block.
|
|
8
|
+
*/
|
|
9
|
+
static ClassName: string;
|
|
10
|
+
/**
|
|
11
|
+
* The namespace of the block.
|
|
12
|
+
*/
|
|
13
|
+
static Namespace: string;
|
|
14
|
+
/**
|
|
15
|
+
* The input connection point.
|
|
16
|
+
*/
|
|
17
|
+
readonly input: import("@onerjs/smart-filters").ConnectionPoint<ConnectionPointType.Texture>;
|
|
18
|
+
/**
|
|
19
|
+
/**
|
|
20
|
+
* The intensity connection point.
|
|
21
|
+
*/
|
|
22
|
+
readonly intensity: import("dev/smartFilters/dist/connection/connectionPointWithDefault").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
23
|
+
/**
|
|
24
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
25
|
+
*/
|
|
26
|
+
static ShaderCode: ShaderProgram;
|
|
27
|
+
/**
|
|
28
|
+
* Instantiates a new DesaturateBlock.
|
|
29
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
30
|
+
* @param name - The friendly name of the block
|
|
31
|
+
*/
|
|
32
|
+
constructor(smartFilter: SmartFilter, name: string);
|
|
33
|
+
/**
|
|
34
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
35
|
+
* @returns The class instance that binds the data to the effect
|
|
36
|
+
*/
|
|
37
|
+
getShaderBinding(): DisableableShaderBinding;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=desaturateBlock.block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desaturateBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/desaturateBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EACnB,KAAK,WAAW,EAChB,sBAAsB,EACtB,KAAK,aAAa,EAGG,8BAAsB;AA+E/C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,sBAAsB;IACvD;;OAEG;IACH,OAAuB,SAAS,SAAqB;IAErD;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D;;OAEG;IACH,SAAgB,KAAK,+EAAoE;IAEzF;;;OAGG;IACH,SAAgB,SAAS,8HAIvB;IAEF;;OAEG;IACH,OAAuB,UAAU,gBAAsB;IAEvD;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,wBAAwB;CAMtD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
// ************************************************************
|
|
3
|
+
// Note: this file is auto-generated, do not modify it directly
|
|
4
|
+
// ************************************************************
|
|
5
|
+
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, BlockDisableStrategy } from "@onerjs/smart-filters";
|
|
6
|
+
/**
|
|
7
|
+
* The shader program for the block.
|
|
8
|
+
*/
|
|
9
|
+
const BlockShaderProgram = {
|
|
10
|
+
vertex: undefined,
|
|
11
|
+
fragment: {
|
|
12
|
+
uniform: `
|
|
13
|
+
uniform sampler2D _input_; // main
|
|
14
|
+
uniform float _intensity_;`,
|
|
15
|
+
mainInputTexture: "_input_",
|
|
16
|
+
mainFunctionName: "_desaturate_",
|
|
17
|
+
functions: [
|
|
18
|
+
{
|
|
19
|
+
name: "_desaturate_",
|
|
20
|
+
code: `
|
|
21
|
+
vec4 _desaturate_(vec2 vUV) {
|
|
22
|
+
float saturationStrength = 1. - _intensity_;
|
|
23
|
+
|
|
24
|
+
vec4 color = texture2D(_input_, vUV);
|
|
25
|
+
|
|
26
|
+
float tempMin = min(min(color.x, color.y), color.z);
|
|
27
|
+
float tempMax = max(max(color.x, color.y), color.z);
|
|
28
|
+
float tempMerge = 0.5 * (tempMin + tempMax);
|
|
29
|
+
|
|
30
|
+
return vec4(mix(color.rgb, vec3(tempMerge, tempMerge, tempMerge), saturationStrength), color.a);
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
params: "vec2 vUV",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
40
|
+
* that the names are always in sync.
|
|
41
|
+
*/
|
|
42
|
+
const Uniforms = {
|
|
43
|
+
input: "input",
|
|
44
|
+
intensity: "intensity",
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The shader binding for the DesaturateBlock, used by the runtime
|
|
48
|
+
*/
|
|
49
|
+
class DesaturateBlockShaderBinding extends DisableableShaderBinding {
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new shader binding instance for the block.
|
|
52
|
+
* @param parentBlock - IDisableableBlock
|
|
53
|
+
* @param input - The input runtime value
|
|
54
|
+
* @param intensity - The intensity runtime value
|
|
55
|
+
*/
|
|
56
|
+
constructor(parentBlock, input, intensity) {
|
|
57
|
+
super(parentBlock);
|
|
58
|
+
this._input = input;
|
|
59
|
+
this._intensity = intensity;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Binds all the required data to the shader when rendering.
|
|
63
|
+
* @param effect - defines the effect to bind the data to
|
|
64
|
+
*/
|
|
65
|
+
bind(effect) {
|
|
66
|
+
super.bind(effect);
|
|
67
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
68
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The implementation of the DesaturateBlock
|
|
73
|
+
*/
|
|
74
|
+
export class DesaturateBlock extends DisableableShaderBlock {
|
|
75
|
+
/**
|
|
76
|
+
* Instantiates a new DesaturateBlock.
|
|
77
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
78
|
+
* @param name - The friendly name of the block
|
|
79
|
+
*/
|
|
80
|
+
constructor(smartFilter, name) {
|
|
81
|
+
super(smartFilter, name, false, BlockDisableStrategy.AutoSample);
|
|
82
|
+
/**
|
|
83
|
+
* The input connection point.
|
|
84
|
+
*/
|
|
85
|
+
this.input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
86
|
+
/**
|
|
87
|
+
/**
|
|
88
|
+
* The intensity connection point.
|
|
89
|
+
*/
|
|
90
|
+
this.intensity = this._registerOptionalInput("intensity", ConnectionPointType.Float, createStrongRef(0.3));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
94
|
+
* @returns The class instance that binds the data to the effect
|
|
95
|
+
*/
|
|
96
|
+
getShaderBinding() {
|
|
97
|
+
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
98
|
+
const intensity = this._confirmRuntimeDataSupplied(this.intensity);
|
|
99
|
+
return new DesaturateBlockShaderBinding(this, input, intensity);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The class name of the block.
|
|
104
|
+
*/
|
|
105
|
+
DesaturateBlock.ClassName = "DesaturateBlock";
|
|
106
|
+
/**
|
|
107
|
+
* The namespace of the block.
|
|
108
|
+
*/
|
|
109
|
+
DesaturateBlock.Namespace = "Babylon.Demo.Effects";
|
|
110
|
+
/**
|
|
111
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
112
|
+
*/
|
|
113
|
+
DesaturateBlock.ShaderCode = BlockShaderProgram;
|
|
114
|
+
//# sourceMappingURL=desaturateBlock.block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desaturateBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/desaturateBlock.block.ts"],"names":[],"mappings":"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