@onerjs/smart-filters-blocks 8.25.0

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.
Files changed (50) hide show
  1. package/license.md +21 -0
  2. package/package.json +54 -0
  3. package/readme.md +7 -0
  4. package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.glsl +18 -0
  5. package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.ts +133 -0
  6. package/src/blocks/babylon/demo/effects/blurBlock.deserializer.ts +37 -0
  7. package/src/blocks/babylon/demo/effects/blurBlock.serializer.ts +31 -0
  8. package/src/blocks/babylon/demo/effects/blurBlock.ts +115 -0
  9. package/src/blocks/babylon/demo/effects/compositionBlock.deserializer.ts +31 -0
  10. package/src/blocks/babylon/demo/effects/compositionBlock.fragment.glsl +38 -0
  11. package/src/blocks/babylon/demo/effects/compositionBlock.fragment.ts +74 -0
  12. package/src/blocks/babylon/demo/effects/compositionBlock.serializer.ts +28 -0
  13. package/src/blocks/babylon/demo/effects/compositionBlock.ts +211 -0
  14. package/src/blocks/babylon/demo/effects/contrastBlock.block.glsl +36 -0
  15. package/src/blocks/babylon/demo/effects/contrastBlock.block.ts +178 -0
  16. package/src/blocks/babylon/demo/effects/desaturateBlock.block.glsl +24 -0
  17. package/src/blocks/babylon/demo/effects/desaturateBlock.block.ts +155 -0
  18. package/src/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.ts +43 -0
  19. package/src/blocks/babylon/demo/effects/directionalBlurBlock.serializer.ts +30 -0
  20. package/src/blocks/babylon/demo/effects/directionalBlurBlock.ts +192 -0
  21. package/src/blocks/babylon/demo/effects/exposureBlock.block.glsl +15 -0
  22. package/src/blocks/babylon/demo/effects/exposureBlock.block.ts +142 -0
  23. package/src/blocks/babylon/demo/effects/greenScreenBlock.block.glsl +23 -0
  24. package/src/blocks/babylon/demo/effects/greenScreenBlock.block.ts +174 -0
  25. package/src/blocks/babylon/demo/effects/index.ts +14 -0
  26. package/src/blocks/babylon/demo/effects/kaleidoscopeBlock.ts +188 -0
  27. package/src/blocks/babylon/demo/effects/maskBlock.block.glsl +18 -0
  28. package/src/blocks/babylon/demo/effects/maskBlock.block.ts +145 -0
  29. package/src/blocks/babylon/demo/effects/pixelateBlock.block.glsl +29 -0
  30. package/src/blocks/babylon/demo/effects/pixelateBlock.block.ts +174 -0
  31. package/src/blocks/babylon/demo/effects/posterizeBlock.block.glsl +25 -0
  32. package/src/blocks/babylon/demo/effects/posterizeBlock.block.ts +156 -0
  33. package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.glsl +26 -0
  34. package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts +63 -0
  35. package/src/blocks/babylon/demo/effects/spritesheetBlock.ts +135 -0
  36. package/src/blocks/babylon/demo/effects/tintBlock.ts +51 -0
  37. package/src/blocks/babylon/demo/transitions/index.ts +1 -0
  38. package/src/blocks/babylon/demo/transitions/wipeBlock.block.glsl +11 -0
  39. package/src/blocks/babylon/demo/transitions/wipeBlock.block.ts +152 -0
  40. package/src/blocks/babylon/demo/utilities/index.ts +1 -0
  41. package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.glsl +14 -0
  42. package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.ts +129 -0
  43. package/src/blocks/blockNamespaces.ts +6 -0
  44. package/src/blocks/blockTypes.ts +23 -0
  45. package/src/blocks/index.ts +6 -0
  46. package/src/index.ts +3 -0
  47. package/src/registration/IBlockRegistration.ts +43 -0
  48. package/src/registration/blockSerializers.ts +50 -0
  49. package/src/registration/builtInBlockRegistrations.ts +293 -0
  50. package/src/registration/index.ts +4 -0
@@ -0,0 +1,156 @@
1
+ /* eslint-disable prettier/prettier */
2
+ // ************************************************************
3
+ // Note: this file is auto-generated, do not modify it directly
4
+ // ************************************************************
5
+
6
+ // It was generated by convertGlslIntoBlock() from
7
+ // an annotated .glsl file. Modify the .glsl file to make changes
8
+ // to the block. This file will get overwritten when the build
9
+ // is run or during a watch when the .glsl file is updated.
10
+
11
+ import type { Effect } from "core/Materials/effect.js";
12
+
13
+ import {
14
+ DisableableShaderBinding,
15
+ type RuntimeData,
16
+ ConnectionPointType,
17
+ type SmartFilter,
18
+ DisableableShaderBlock,
19
+ type ShaderProgram,
20
+ createStrongRef,
21
+ type IDisableableBlock,
22
+ BlockDisableStrategy} from "smart-filters";
23
+
24
+ /**
25
+ * The shader program for the block.
26
+ */
27
+ const BlockShaderProgram: ShaderProgram = {
28
+ vertex: undefined,
29
+ fragment: {
30
+ uniform: `
31
+ uniform sampler2D _input_; // main
32
+ uniform float _intensity_;`,
33
+ const: ` const float _posterizePower_ = 6.0;
34
+ const float _minLevel_ = 2.0;
35
+ const float _maxLevel_ = 256.0;`,
36
+ mainInputTexture: "_input_",
37
+ mainFunctionName: "_posterize_",
38
+ functions: [
39
+ {
40
+ name: "_posterize_",
41
+ code: `
42
+ vec4 _posterize_(vec2 vUV) {
43
+ vec4 color = texture2D(_input_, vUV);
44
+
45
+ float posterizeStrength = mix(_minLevel_, _maxLevel_, pow(1. - _intensity_, _posterizePower_));
46
+ vec3 _posterize_ = vec3(posterizeStrength);
47
+ color.rgb = floor(color.rgb / (1.0 / _posterize_)) * (1.0 / _posterize_);
48
+
49
+ return color;
50
+ }
51
+ `,
52
+ params: "vec2 vUV",
53
+ },
54
+ ],
55
+ },
56
+ };
57
+
58
+ /**
59
+ * The uniform names for this shader, to be used in the shader binding so
60
+ * that the names are always in sync.
61
+ */
62
+ const Uniforms = {
63
+ input: "input",
64
+ intensity: "intensity",
65
+ };
66
+
67
+
68
+ /**
69
+ * The shader binding for the PosterizeBlock, used by the runtime
70
+ */
71
+ class PosterizeBlockShaderBinding extends DisableableShaderBinding {
72
+ private readonly _input: RuntimeData<ConnectionPointType.Texture>;
73
+ private readonly _intensity: RuntimeData<ConnectionPointType.Float>;
74
+
75
+ /**
76
+ * Creates a new shader binding instance for the block.
77
+ * @param parentBlock - IDisableableBlock
78
+ * @param input - The input runtime value
79
+ * @param intensity - The intensity runtime value
80
+ */
81
+ constructor(
82
+ parentBlock: IDisableableBlock,
83
+ input: RuntimeData<ConnectionPointType.Texture>,
84
+ intensity: RuntimeData<ConnectionPointType.Float>
85
+ ) {
86
+ super(parentBlock);
87
+ this._input = input;
88
+ this._intensity = intensity;
89
+ }
90
+
91
+ /**
92
+ * Binds all the required data to the shader when rendering.
93
+ * @param effect - defines the effect to bind the data to
94
+ */
95
+ public override bind(effect: Effect): void {
96
+ super.bind(effect);
97
+ effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
98
+ effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * The implementation of the PosterizeBlock
104
+ */
105
+ export class PosterizeBlock extends DisableableShaderBlock {
106
+ /**
107
+ * The class name of the block.
108
+ */
109
+ public static override ClassName = "PosterizeBlock";
110
+
111
+ /**
112
+ * The namespace of the block.
113
+ */
114
+ public static override Namespace = "Babylon.Demo.Effects";
115
+
116
+ /**
117
+ * The input connection point.
118
+ */
119
+ public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
120
+
121
+ /**
122
+ /**
123
+ * The intensity connection point.
124
+ */
125
+ public readonly intensity = this._registerOptionalInput(
126
+ "intensity",
127
+ ConnectionPointType.Float,
128
+ createStrongRef(0.3)
129
+ );
130
+
131
+ /**
132
+ * The shader program (vertex and fragment code) to use to render the block
133
+ */
134
+ public static override ShaderCode = BlockShaderProgram;
135
+
136
+ /**
137
+ * Instantiates a new PosterizeBlock.
138
+ * @param smartFilter - The smart filter this block belongs to
139
+ * @param name - The friendly name of the block
140
+ */
141
+ constructor(smartFilter: SmartFilter, name: string) {
142
+ super(smartFilter, name, false, BlockDisableStrategy.AutoSample);
143
+ }
144
+
145
+ /**
146
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
147
+ * @returns The class instance that binds the data to the effect
148
+ */
149
+ public getShaderBinding(): DisableableShaderBinding {
150
+ const input = this._confirmRuntimeDataSupplied(this.input);
151
+ const intensity = this._confirmRuntimeDataSupplied(this.intensity);
152
+
153
+ return new PosterizeBlockShaderBinding(this,input,intensity);
154
+ }
155
+ }
156
+
@@ -0,0 +1,26 @@
1
+ uniform sampler2D input; // main
2
+ uniform float time;
3
+ uniform float rows;
4
+ uniform float cols;
5
+ uniform float frames;
6
+ uniform bool disabled;
7
+
8
+ vec4 mainImage(vec2 vUV) { // main
9
+ if (!disabled) {
10
+ float invRows = 1.0 / rows;
11
+ float invCols = 1.0 / cols;
12
+
13
+ // Get offset of frame
14
+ float frame = mod(floor(time), frames);
15
+ float row = (rows - 1.0) - floor(frame * invCols); // Reverse row direction b/c UVs start from bottom
16
+ float col = mod(frame, cols);
17
+
18
+ // Add offset, then scale UV down to frame size
19
+ vUV = vec2(
20
+ (vUV.x + col) * invCols,
21
+ (vUV.y + row) * invRows
22
+ );
23
+ }
24
+
25
+ return texture2D(input, vUV);
26
+ }
@@ -0,0 +1,63 @@
1
+ import type { ShaderProgram } from "smart-filters";
2
+
3
+ /**
4
+ * The shader program for the block.
5
+ */
6
+ const BlockShaderProgram: ShaderProgram = {
7
+ vertex: undefined,
8
+ fragment: {
9
+ uniform: `
10
+ uniform sampler2D _input_; // main
11
+ uniform float _time_;
12
+ uniform float _rows_;
13
+ uniform float _cols_;
14
+ uniform float _frames_;
15
+ uniform bool _disabled_;`,
16
+ mainInputTexture: "_input_",
17
+ mainFunctionName: "_mainImage_",
18
+ functions: [
19
+ {
20
+ name: "_mainImage_",
21
+ code: `
22
+ vec4 _mainImage_(vec2 vUV) {
23
+ if (!_disabled_) {
24
+ float invRows = 1.0 / _rows_;
25
+ float invCols = 1.0 / _cols_;
26
+
27
+ // Get offset of frame
28
+ float frame = mod(floor(_time_), _frames_);
29
+ float row = (_rows_ - 1.0) - floor(frame * invCols); // Reverse row direction b/c UVs start from bottom
30
+ float col = mod(frame, _cols_);
31
+
32
+ // Add offset, then scale UV down to frame size
33
+ vUV = vec2(
34
+ (vUV.x + col) * invCols,
35
+ (vUV.y + row) * invRows
36
+ );
37
+ }
38
+
39
+ return texture2D(_input_, vUV);
40
+ }
41
+ `,
42
+ params: "vec2 vUV",
43
+ },
44
+ ],
45
+ },
46
+ };
47
+
48
+ /**
49
+ * The uniform names for this shader, to be used in the shader binding so
50
+ * that the names are always in sync.
51
+ */
52
+ const Uniforms = {
53
+ input: "input",
54
+ time: "time",
55
+ rows: "rows",
56
+ cols: "cols",
57
+ frames: "frames",
58
+ disabled: "disabled",
59
+ };
60
+
61
+ export { BlockShaderProgram, Uniforms };
62
+ // Back compat for when camelCase was used
63
+ export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
@@ -0,0 +1,135 @@
1
+ import type { Effect } from "core/Materials/effect.js";
2
+
3
+ import { spritesheetBlockType } from "../../../blockTypes.js";
4
+ import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
5
+ import { shaderProgram, uniforms } from "./spritesheetBlock.fragment.js";
6
+ import {
7
+ DisableableShaderBinding,
8
+ type RuntimeData,
9
+ ConnectionPointType,
10
+ type IDisableableBlock,
11
+ DisableableShaderBlock,
12
+ type SmartFilter,
13
+ createStrongRef,
14
+ BlockDisableStrategy,
15
+ } from "smart-filters";
16
+
17
+ /**
18
+ * The shader bindings for the Spritesheet block.
19
+ */
20
+ export class SpritesheetShaderBinding extends DisableableShaderBinding {
21
+ private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
22
+ private readonly _time: RuntimeData<ConnectionPointType.Float>;
23
+ private readonly _rows: RuntimeData<ConnectionPointType.Float>;
24
+ private readonly _cols: RuntimeData<ConnectionPointType.Float>;
25
+ private readonly _frames: RuntimeData<ConnectionPointType.Float>;
26
+
27
+ /**
28
+ * Creates a new shader binding instance for the SpriteSheet block.
29
+ * @param parentBlock - The parent block
30
+ * @param inputTexture - The input texture
31
+ * @param time - The time passed since the start of the effect
32
+ * @param rows - The number of rows in the sprite sheet
33
+ * @param cols - The number of columns in the sprite sheet
34
+ * @param frames - The number of frames to show
35
+ */
36
+ constructor(
37
+ parentBlock: IDisableableBlock,
38
+ inputTexture: RuntimeData<ConnectionPointType.Texture>,
39
+ time: RuntimeData<ConnectionPointType.Float>,
40
+ rows: RuntimeData<ConnectionPointType.Float>,
41
+ cols: RuntimeData<ConnectionPointType.Float>,
42
+ frames: RuntimeData<ConnectionPointType.Float>
43
+ ) {
44
+ super(parentBlock);
45
+ this._inputTexture = inputTexture;
46
+ this._time = time;
47
+ this._rows = rows;
48
+ this._cols = cols;
49
+ this._frames = frames;
50
+ }
51
+
52
+ /**
53
+ * Binds all the required data to the shader when rendering.
54
+ * @param effect - defines the effect to bind the data to
55
+ */
56
+ public override bind(effect: Effect): void {
57
+ super.bind(effect);
58
+ effect.setTexture(this.getRemappedName(uniforms.input), this._inputTexture.value);
59
+ effect.setFloat(this.getRemappedName(uniforms.time), this._time.value);
60
+ effect.setFloat(this.getRemappedName(uniforms.rows), this._rows.value);
61
+ effect.setFloat(this.getRemappedName(uniforms.cols), this._cols.value);
62
+
63
+ // Apply default value for frame count if it was not provided
64
+ effect.setFloat(this.getRemappedName(uniforms.frames), this._frames.value > 0 ? this._frames.value : this._rows.value * this._cols.value);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * A block that animates a sprite sheet texture.
70
+ */
71
+ export class SpritesheetBlock extends DisableableShaderBlock {
72
+ /**
73
+ * The class name of the block.
74
+ */
75
+ public static override ClassName = spritesheetBlockType;
76
+
77
+ /**
78
+ * The namespace of the block.
79
+ */
80
+ public static override Namespace = babylonDemoEffectsNamespace;
81
+
82
+ /**
83
+ * The input texture connection point
84
+ */
85
+ public readonly input = this._registerInput("input", ConnectionPointType.Texture);
86
+
87
+ /**
88
+ * The time connection point to animate the effect.
89
+ */
90
+ public readonly time = this._registerOptionalInput("time", ConnectionPointType.Float, createStrongRef(0.0));
91
+
92
+ /**
93
+ * The number of rows in the sprite sheet, as a connection point.
94
+ */
95
+ public readonly rows = this._registerOptionalInput("rows", ConnectionPointType.Float, createStrongRef(1.0));
96
+
97
+ /**
98
+ * The number of columns in the sprite sheet, as a connection point.
99
+ */
100
+ public readonly columns = this._registerOptionalInput("columns", ConnectionPointType.Float, createStrongRef(1.0));
101
+
102
+ /**
103
+ * The number of frames to animate from the beginning, as a connection point.
104
+ * Defaults to rows * columns at runtime.
105
+ */
106
+ public readonly frames = this._registerOptionalInput("frames", ConnectionPointType.Float, createStrongRef(0.0));
107
+
108
+ /**
109
+ * The shader program (vertex and fragment code) to use to render the block
110
+ */
111
+ public static override ShaderCode = shaderProgram;
112
+
113
+ /**
114
+ * Instantiates a new Block.
115
+ * @param smartFilter - The smart filter this block belongs to
116
+ * @param name - The friendly name of the block
117
+ */
118
+ constructor(smartFilter: SmartFilter, name: string) {
119
+ super(smartFilter, name, false, BlockDisableStrategy.Manual);
120
+ }
121
+
122
+ /**
123
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
124
+ * @returns The class instance that binds the data to the effect
125
+ */
126
+ public getShaderBinding(): DisableableShaderBinding {
127
+ const input = this._confirmRuntimeDataSupplied(this.input);
128
+ const rows = this.rows.runtimeData;
129
+ const columns = this.columns.runtimeData;
130
+ const time = this.time.runtimeData;
131
+ const frames = this.frames.runtimeData;
132
+
133
+ return new SpritesheetShaderBinding(this, input, time, rows, columns, frames);
134
+ }
135
+ }
@@ -0,0 +1,51 @@
1
+ import { ConnectionPointType, type SerializedShaderBlockDefinition } from "smart-filters";
2
+
3
+ /**
4
+ * This is included to show how a serialized block definition can be loaded and used.
5
+ * This object could have been deserialized from a JSON file, for example.
6
+ */
7
+ export const DeserializedTintBlockDefinition: SerializedShaderBlockDefinition = {
8
+ format: "shaderBlockDefinition",
9
+ formatVersion: 1,
10
+ blockType: "TintBlock",
11
+ namespace: "Babylon.Demo.Effects",
12
+ shaderProgram: {
13
+ fragment: {
14
+ uniform: `
15
+ uniform sampler2D _input_; // main
16
+ uniform vec3 _tint_;
17
+ uniform float _amount_;
18
+ `,
19
+ mainInputTexture: "_input_",
20
+ mainFunctionName: "_mainImage_",
21
+ functions: [
22
+ {
23
+ name: "_mainImage_",
24
+ code: `
25
+ vec4 _mainImage_(vec2 vUV) {
26
+ vec4 color = texture2D(_input_, vUV);
27
+ vec3 tinted = mix(color.rgb, _tint_, _amount_);
28
+ return vec4(tinted, color.a);
29
+ }`,
30
+ },
31
+ ],
32
+ },
33
+ },
34
+ inputConnectionPoints: [
35
+ {
36
+ name: "input",
37
+ type: ConnectionPointType.Texture,
38
+ },
39
+ {
40
+ name: "tint",
41
+ type: ConnectionPointType.Color3,
42
+ defaultValue: { r: 1, g: 0, b: 0 },
43
+ },
44
+ {
45
+ name: "amount",
46
+ type: ConnectionPointType.Float,
47
+ defaultValue: 0.25,
48
+ },
49
+ ],
50
+ disableOptimization: false,
51
+ };
@@ -0,0 +1 @@
1
+ export * from "./wipeBlock.block.js";
@@ -0,0 +1,11 @@
1
+ // { "smartFilterBlockType": "WipeBlock", "namespace": "Babylon.Demo.Transitions" }
2
+
3
+ uniform sampler2D textureA;
4
+ uniform sampler2D textureB;
5
+ uniform float progress;
6
+
7
+ vec4 wipe(vec2 vUV) { // main
8
+ vec4 colorA = texture2D(textureA, vUV);
9
+ vec4 colorB = texture2D(textureB, vUV);
10
+ return mix(colorB, colorA, step(progress, vUV.y));
11
+ }
@@ -0,0 +1,152 @@
1
+ /* eslint-disable prettier/prettier */
2
+ // ************************************************************
3
+ // Note: this file is auto-generated, do not modify it directly
4
+ // ************************************************************
5
+
6
+ // It was generated by convertGlslIntoBlock() from
7
+ // an annotated .glsl file. Modify the .glsl file to make changes
8
+ // to the block. This file will get overwritten when the build
9
+ // is run or during a watch when the .glsl file is updated.
10
+
11
+ import type { Effect } from "core/Materials/effect.js";
12
+
13
+ import {
14
+ ShaderBinding,
15
+ type RuntimeData,
16
+ ConnectionPointType,
17
+ type SmartFilter,
18
+ ShaderBlock,
19
+ type ShaderProgram,
20
+ } from "smart-filters";
21
+
22
+ /**
23
+ * The shader program for the block.
24
+ */
25
+ const BlockShaderProgram: ShaderProgram = {
26
+ vertex: undefined,
27
+ fragment: {
28
+ uniform: `
29
+ uniform sampler2D _textureA_;
30
+ uniform sampler2D _textureB_;
31
+ uniform float _progress_;`,
32
+ mainInputTexture: "",
33
+ mainFunctionName: "_wipe_",
34
+ functions: [
35
+ {
36
+ name: "_wipe_",
37
+ code: `
38
+ vec4 _wipe_(vec2 vUV) {
39
+ vec4 colorA = texture2D(_textureA_, vUV);
40
+ vec4 colorB = texture2D(_textureB_, vUV);
41
+ return mix(colorB, colorA, step(_progress_, vUV.y));
42
+ }
43
+ `,
44
+ params: "vec2 vUV",
45
+ },
46
+ ],
47
+ },
48
+ };
49
+
50
+ /**
51
+ * The uniform names for this shader, to be used in the shader binding so
52
+ * that the names are always in sync.
53
+ */
54
+ const Uniforms = {
55
+ textureA: "textureA",
56
+ textureB: "textureB",
57
+ progress: "progress",
58
+ };
59
+
60
+
61
+ /**
62
+ * The shader binding for the WipeBlock, used by the runtime
63
+ */
64
+ class WipeBlockShaderBinding extends ShaderBinding {
65
+ private readonly _textureA: RuntimeData<ConnectionPointType.Texture>;
66
+ private readonly _textureB: RuntimeData<ConnectionPointType.Texture>;
67
+ private readonly _progress: RuntimeData<ConnectionPointType.Float>;
68
+
69
+ /**
70
+ * Creates a new shader binding instance for the block.
71
+ * @param textureA - The textureA runtime value
72
+ * @param textureB - The textureB runtime value
73
+ * @param progress - The progress runtime value
74
+ */
75
+ constructor(
76
+ textureA: RuntimeData<ConnectionPointType.Texture>,
77
+ textureB: RuntimeData<ConnectionPointType.Texture>,
78
+ progress: RuntimeData<ConnectionPointType.Float>
79
+ ) {
80
+ super();
81
+ this._textureA = textureA;
82
+ this._textureB = textureB;
83
+ this._progress = progress;
84
+ }
85
+
86
+ /**
87
+ * Binds all the required data to the shader when rendering.
88
+ * @param effect - defines the effect to bind the data to
89
+ */
90
+ public override bind(effect: Effect): void {
91
+ effect.setTexture(this.getRemappedName(Uniforms.textureA), this._textureA.value);
92
+ effect.setTexture(this.getRemappedName(Uniforms.textureB), this._textureB.value);
93
+ effect.setFloat(this.getRemappedName(Uniforms.progress), this._progress.value);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * The implementation of the WipeBlock
99
+ */
100
+ export class WipeBlock extends ShaderBlock {
101
+ /**
102
+ * The class name of the block.
103
+ */
104
+ public static override ClassName = "WipeBlock";
105
+
106
+ /**
107
+ * The namespace of the block.
108
+ */
109
+ public static override Namespace = "Babylon.Demo.Transitions";
110
+
111
+ /**
112
+ * The textureA connection point.
113
+ */
114
+ public readonly textureA = this._registerInput(Uniforms.textureA, ConnectionPointType.Texture);
115
+
116
+ /**
117
+ * The textureB connection point.
118
+ */
119
+ public readonly textureB = this._registerInput(Uniforms.textureB, ConnectionPointType.Texture);
120
+
121
+ /**
122
+ * The progress connection point.
123
+ */
124
+ public readonly progress = this._registerInput(Uniforms.progress, ConnectionPointType.Float);
125
+
126
+ /**
127
+ * The shader program (vertex and fragment code) to use to render the block
128
+ */
129
+ public static override ShaderCode = BlockShaderProgram;
130
+
131
+ /**
132
+ * Instantiates a new WipeBlock.
133
+ * @param smartFilter - The smart filter this block belongs to
134
+ * @param name - The friendly name of the block
135
+ */
136
+ constructor(smartFilter: SmartFilter, name: string) {
137
+ super(smartFilter, name, false);
138
+ }
139
+
140
+ /**
141
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
142
+ * @returns The class instance that binds the data to the effect
143
+ */
144
+ public getShaderBinding(): ShaderBinding {
145
+ const textureA = this._confirmRuntimeDataSupplied(this.textureA);
146
+ const textureB = this._confirmRuntimeDataSupplied(this.textureB);
147
+ const progress = this._confirmRuntimeDataSupplied(this.progress);
148
+
149
+ return new WipeBlockShaderBinding(textureA,textureB,progress);
150
+ }
151
+ }
152
+
@@ -0,0 +1 @@
1
+ export * from "./premultiplyAlphaBlock.block.js";
@@ -0,0 +1,14 @@
1
+ /*
2
+ {
3
+ "smartFilterBlockType": "PremultiplyAlphaBlock",
4
+ "namespace": "Babylon.Demo.Utilities",
5
+ "blockDisableStrategy": "AutoSample"
6
+ }
7
+ */
8
+
9
+ uniform sampler2D input; // main
10
+
11
+ vec4 premultiply(vec2 vUV) { // main
12
+ vec4 color = texture2D(input, vUV);
13
+ return vec4(color.rgb * color.a, color.a);
14
+ }