@babylonjs/smart-filters 0.7.11-alpha → 0.7.12-alpha
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/blockFoundation/outputBlock.d.ts +5 -0
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/outputBlock.js +30 -1
- package/dist/blockFoundation/outputBlock.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -10
- package/readme.md +2 -0
- package/src/blockFoundation/outputBlock.ts +33 -1
- package/src/index.ts +0 -2
- package/src/version.ts +1 -1
- package/dist/blockFoundation/outputBlock.shader.d.ts +0 -13
- package/dist/blockFoundation/outputBlock.shader.d.ts.map +0 -1
- package/dist/blockFoundation/outputBlock.shader.js +0 -31
- package/dist/blockFoundation/outputBlock.shader.js.map +0 -1
- package/dist/blockRegistration/IBlockRegistration.d.ts +0 -36
- package/dist/blockRegistration/IBlockRegistration.d.ts.map +0 -1
- package/dist/blockRegistration/IBlockRegistration.js +0 -2
- package/dist/blockRegistration/IBlockRegistration.js.map +0 -1
- package/dist/blockRegistration/blockSerializers.d.ts +0 -13
- package/dist/blockRegistration/blockSerializers.d.ts.map +0 -1
- package/dist/blockRegistration/blockSerializers.js +0 -35
- package/dist/blockRegistration/blockSerializers.js.map +0 -1
- package/dist/blockRegistration/builtInBlockRegistrations.d.ts +0 -13
- package/dist/blockRegistration/builtInBlockRegistrations.d.ts.map +0 -1
- package/dist/blockRegistration/builtInBlockRegistrations.js +0 -266
- package/dist/blockRegistration/builtInBlockRegistrations.js.map +0 -1
- package/dist/blockRegistration/index.d.ts +0 -3
- package/dist/blockRegistration/index.d.ts.map +0 -1
- package/dist/blockRegistration/index.js +0 -3
- package/dist/blockRegistration/index.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.d.ts +0 -56
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.js +0 -66
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.shader.d.ts +0 -13
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.shader.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.shader.js +0 -36
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.shader.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts +0 -56
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts +0 -29
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js +0 -16
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.js +0 -100
- package/dist/blocks/babylon/demo/effects/blurBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts +0 -8
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js +0 -28
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts +0 -118
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts +0 -25
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js +0 -15
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.js +0 -219
- package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts +0 -6
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js +0 -25
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/contrastBlock.d.ts +0 -63
- package/dist/blocks/babylon/demo/effects/contrastBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/contrastBlock.js +0 -122
- package/dist/blocks/babylon/demo/effects/contrastBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/desaturateBlock.d.ts +0 -63
- package/dist/blocks/babylon/demo/effects/desaturateBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/desaturateBlock.js +0 -107
- package/dist/blocks/babylon/demo/effects/desaturateBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts +0 -79
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts +0 -33
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js +0 -17
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js +0 -171
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts +0 -6
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js +0 -27
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/exposureBlock.d.ts +0 -63
- package/dist/blocks/babylon/demo/effects/exposureBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/exposureBlock.js +0 -95
- package/dist/blocks/babylon/demo/effects/exposureBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.d.ts +0 -75
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.js +0 -121
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/index.d.ts +0 -15
- package/dist/blocks/babylon/demo/effects/index.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/index.js +0 -15
- package/dist/blocks/babylon/demo/effects/index.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts +0 -63
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js +0 -159
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/maskBlock.d.ts +0 -62
- package/dist/blocks/babylon/demo/effects/maskBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/maskBlock.js +0 -75
- package/dist/blocks/babylon/demo/effects/maskBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/maskBlock.shader.d.ts +0 -14
- package/dist/blocks/babylon/demo/effects/maskBlock.shader.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/maskBlock.shader.js +0 -37
- package/dist/blocks/babylon/demo/effects/maskBlock.shader.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.d.ts +0 -62
- package/dist/blocks/babylon/demo/effects/pixelateBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.js +0 -77
- package/dist/blocks/babylon/demo/effects/pixelateBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.shader.d.ts +0 -15
- package/dist/blocks/babylon/demo/effects/pixelateBlock.shader.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.shader.js +0 -44
- package/dist/blocks/babylon/demo/effects/pixelateBlock.shader.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/posterizeBlock.d.ts +0 -63
- package/dist/blocks/babylon/demo/effects/posterizeBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/posterizeBlock.js +0 -108
- package/dist/blocks/babylon/demo/effects/posterizeBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts +0 -81
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js +0 -103
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.shader.d.ts +0 -18
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.shader.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.shader.js +0 -57
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.shader.js.map +0 -1
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts +0 -7
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/effects/tintBlock.js +0 -51
- package/dist/blocks/babylon/demo/effects/tintBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/transitions/index.d.ts +0 -2
- package/dist/blocks/babylon/demo/transitions/index.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/transitions/index.js +0 -2
- package/dist/blocks/babylon/demo/transitions/index.js.map +0 -1
- package/dist/blocks/babylon/demo/transitions/wipeBlock.d.ts +0 -69
- package/dist/blocks/babylon/demo/transitions/wipeBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/transitions/wipeBlock.js +0 -110
- package/dist/blocks/babylon/demo/transitions/wipeBlock.js.map +0 -1
- package/dist/blocks/babylon/demo/utilities/index.d.ts +0 -2
- package/dist/blocks/babylon/demo/utilities/index.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/utilities/index.js +0 -2
- package/dist/blocks/babylon/demo/utilities/index.js.map +0 -1
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.d.ts +0 -58
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.d.ts.map +0 -1
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.js +0 -87
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.js.map +0 -1
- package/dist/blocks/blockNamespaces.d.ts +0 -5
- package/dist/blocks/blockNamespaces.d.ts.map +0 -1
- package/dist/blocks/blockNamespaces.js +0 -5
- package/dist/blocks/blockNamespaces.js.map +0 -1
- package/dist/blocks/blockTypes.d.ts +0 -22
- package/dist/blocks/blockTypes.d.ts.map +0 -1
- package/dist/blocks/blockTypes.js +0 -22
- package/dist/blocks/blockTypes.js.map +0 -1
- package/dist/blocks/index.d.ts +0 -6
- package/dist/blocks/index.d.ts.map +0 -1
- package/dist/blocks/index.js +0 -6
- package/dist/blocks/index.js.map +0 -1
- package/src/blockFoundation/outputBlock.fragment.glsl +0 -5
- package/src/blockFoundation/outputBlock.shader.ts +0 -33
- package/src/blockRegistration/IBlockRegistration.ts +0 -45
- package/src/blockRegistration/blockSerializers.ts +0 -52
- package/src/blockRegistration/builtInBlockRegistrations.ts +0 -390
- package/src/blockRegistration/index.ts +0 -2
- package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.fragment.glsl +0 -10
- package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.shader.ts +0 -38
- package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.ts +0 -80
- package/src/blocks/babylon/demo/effects/blurBlock.deserializer.ts +0 -38
- package/src/blocks/babylon/demo/effects/blurBlock.serializer.ts +0 -32
- package/src/blocks/babylon/demo/effects/blurBlock.ts +0 -119
- package/src/blocks/babylon/demo/effects/compositionBlock.deserializer.ts +0 -32
- package/src/blocks/babylon/demo/effects/compositionBlock.serializer.ts +0 -29
- package/src/blocks/babylon/demo/effects/compositionBlock.ts +0 -293
- package/src/blocks/babylon/demo/effects/contrastBlock.ts +0 -152
- package/src/blocks/babylon/demo/effects/desaturateBlock.ts +0 -137
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.ts +0 -47
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.serializer.ts +0 -31
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.ts +0 -193
- package/src/blocks/babylon/demo/effects/exposureBlock.ts +0 -120
- package/src/blocks/babylon/demo/effects/greenScreenBlock.ts +0 -152
- package/src/blocks/babylon/demo/effects/index.ts +0 -14
- package/src/blocks/babylon/demo/effects/kaleidoscopeBlock.ts +0 -186
- package/src/blocks/babylon/demo/effects/maskBlock.fragment.glsl +0 -10
- package/src/blocks/babylon/demo/effects/maskBlock.shader.ts +0 -39
- package/src/blocks/babylon/demo/effects/maskBlock.ts +0 -94
- package/src/blocks/babylon/demo/effects/pixelateBlock.fragment.glsl +0 -18
- package/src/blocks/babylon/demo/effects/pixelateBlock.shader.ts +0 -46
- package/src/blocks/babylon/demo/effects/pixelateBlock.ts +0 -101
- package/src/blocks/babylon/demo/effects/posterizeBlock.ts +0 -139
- package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.glsl +0 -26
- package/src/blocks/babylon/demo/effects/spritesheetBlock.shader.ts +0 -59
- package/src/blocks/babylon/demo/effects/spritesheetBlock.ts +0 -135
- package/src/blocks/babylon/demo/effects/tintBlock.ts +0 -52
- package/src/blocks/babylon/demo/transitions/index.ts +0 -1
- package/src/blocks/babylon/demo/transitions/wipeBlock.ts +0 -138
- package/src/blocks/babylon/demo/utilities/index.ts +0 -1
- package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.ts +0 -106
- package/src/blocks/blockNamespaces.ts +0 -4
- package/src/blocks/blockTypes.ts +0 -21
- package/src/blocks/index.ts +0 -5
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { ShaderProgram } from "../../../../utils/shaderCodeUtils";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The shader program for the block.
|
|
5
|
-
*/
|
|
6
|
-
export const shaderProgram: 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
|
-
`,
|
|
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
|
-
export const uniforms = {
|
|
53
|
-
input: "input",
|
|
54
|
-
time: "time",
|
|
55
|
-
rows: "rows",
|
|
56
|
-
cols: "cols",
|
|
57
|
-
frames: "frames",
|
|
58
|
-
disabled: "disabled",
|
|
59
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
-
|
|
3
|
-
import { spritesheetBlockType } from "../../../blockTypes.js";
|
|
4
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
5
|
-
import { shaderProgram, uniforms } from "./spritesheetBlock.shader.js";
|
|
6
|
-
import { type RuntimeData } from "../../../../connection/connectionPoint.js";
|
|
7
|
-
import { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
8
|
-
import { type IDisableableBlock, DisableableShaderBlock } from "../../../../blockFoundation/disableableShaderBlock.js";
|
|
9
|
-
import { DisableStrategy } from "../../../../blockFoundation/index.js";
|
|
10
|
-
import { DisableableShaderBinding } from "../../../../runtime/shaderRuntime.js";
|
|
11
|
-
import { createStrongRef } from "../../../../runtime/strongRef.js";
|
|
12
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The shader bindings for the Spritesheet block.
|
|
16
|
-
*/
|
|
17
|
-
export class SpritesheetShaderBinding extends DisableableShaderBinding {
|
|
18
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
19
|
-
private readonly _time: RuntimeData<ConnectionPointType.Float>;
|
|
20
|
-
private readonly _rows: RuntimeData<ConnectionPointType.Float>;
|
|
21
|
-
private readonly _cols: RuntimeData<ConnectionPointType.Float>;
|
|
22
|
-
private readonly _frames: RuntimeData<ConnectionPointType.Float>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new shader binding instance for the SpriteSheet block.
|
|
26
|
-
* @param parentBlock - The parent block
|
|
27
|
-
* @param inputTexture - The input texture
|
|
28
|
-
* @param time - The time passed since the start of the effect
|
|
29
|
-
* @param rows - The number of rows in the sprite sheet
|
|
30
|
-
* @param cols - The number of columns in the sprite sheet
|
|
31
|
-
* @param frames - The number of frames to show
|
|
32
|
-
*/
|
|
33
|
-
constructor(
|
|
34
|
-
parentBlock: IDisableableBlock,
|
|
35
|
-
inputTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
36
|
-
time: RuntimeData<ConnectionPointType.Float>,
|
|
37
|
-
rows: RuntimeData<ConnectionPointType.Float>,
|
|
38
|
-
cols: RuntimeData<ConnectionPointType.Float>,
|
|
39
|
-
frames: RuntimeData<ConnectionPointType.Float>
|
|
40
|
-
) {
|
|
41
|
-
super(parentBlock);
|
|
42
|
-
this._inputTexture = inputTexture;
|
|
43
|
-
this._time = time;
|
|
44
|
-
this._rows = rows;
|
|
45
|
-
this._cols = cols;
|
|
46
|
-
this._frames = frames;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Binds all the required data to the shader when rendering.
|
|
51
|
-
* @param effect - defines the effect to bind the data to
|
|
52
|
-
*/
|
|
53
|
-
public override bind(effect: Effect): void {
|
|
54
|
-
super.bind(effect);
|
|
55
|
-
effect.setTexture(this.getRemappedName(uniforms.input), this._inputTexture.value);
|
|
56
|
-
effect.setFloat(this.getRemappedName(uniforms.time), this._time.value);
|
|
57
|
-
effect.setFloat(this.getRemappedName(uniforms.rows), this._rows.value);
|
|
58
|
-
effect.setFloat(this.getRemappedName(uniforms.cols), this._cols.value);
|
|
59
|
-
|
|
60
|
-
// Apply default value for frame count if it was not provided
|
|
61
|
-
effect.setFloat(
|
|
62
|
-
this.getRemappedName(uniforms.frames),
|
|
63
|
-
this._frames.value > 0 ? this._frames.value : this._rows.value * this._cols.value
|
|
64
|
-
);
|
|
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, DisableStrategy.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
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
2
|
-
import type { SerializedShaderBlockDefinition } from "../../../../serialization";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This is included to show how a serialized block definition can be loaded and used.
|
|
6
|
-
* This object could have been deserialized from a JSON file, for example.
|
|
7
|
-
*/
|
|
8
|
-
export const deserializedTintBlockDefinition: SerializedShaderBlockDefinition = {
|
|
9
|
-
format: "shaderBlockDefinition",
|
|
10
|
-
formatVersion: 1,
|
|
11
|
-
blockType: "TintBlock",
|
|
12
|
-
namespace: "Babylon.Demo.Effects",
|
|
13
|
-
shaderProgram: {
|
|
14
|
-
fragment: {
|
|
15
|
-
uniform: `
|
|
16
|
-
uniform sampler2D _input_; // main
|
|
17
|
-
uniform vec3 _tint_;
|
|
18
|
-
uniform float _amount_;
|
|
19
|
-
`,
|
|
20
|
-
mainInputTexture: "_input_",
|
|
21
|
-
mainFunctionName: "_mainImage_",
|
|
22
|
-
functions: [
|
|
23
|
-
{
|
|
24
|
-
name: "_mainImage_",
|
|
25
|
-
code: `
|
|
26
|
-
vec4 _mainImage_(vec2 vUV) {
|
|
27
|
-
vec4 color = texture2D(_input_, vUV);
|
|
28
|
-
vec3 tinted = mix(color.rgb, _tint_, _amount_);
|
|
29
|
-
return vec4(tinted, color.a);
|
|
30
|
-
}`,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
inputConnectionPoints: [
|
|
36
|
-
{
|
|
37
|
-
name: "input",
|
|
38
|
-
type: ConnectionPointType.Texture,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "tint",
|
|
42
|
-
type: ConnectionPointType.Color3,
|
|
43
|
-
defaultValue: { r: 1, g: 0, b: 0 },
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "amount",
|
|
47
|
-
type: ConnectionPointType.Float,
|
|
48
|
-
defaultValue: 0.25,
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
disableOptimization: false,
|
|
52
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./wipeBlock.js";
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
-
|
|
3
|
-
import { type RuntimeData } from "../../../../connection/connectionPoint.js";
|
|
4
|
-
import { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
5
|
-
import { type IDisableableBlock, DisableableShaderBlock } from "../../../../blockFoundation/disableableShaderBlock.js";
|
|
6
|
-
import { DisableableShaderBinding } from "../../../../runtime/shaderRuntime.js";
|
|
7
|
-
import type { ShaderProgram } from "../../../../utils/shaderCodeUtils.js";
|
|
8
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
9
|
-
|
|
10
|
-
import { babylonDemoTransitionsNamespace } from "../../../blockNamespaces.js";
|
|
11
|
-
import { wipeBlockType } from "../../../blockTypes.js";
|
|
12
|
-
|
|
13
|
-
const shaderProgram: ShaderProgram = {
|
|
14
|
-
fragment: {
|
|
15
|
-
const: `
|
|
16
|
-
const float HALF_PI = 1.57079632679;
|
|
17
|
-
const float LARGE = 10000.0;
|
|
18
|
-
`,
|
|
19
|
-
uniform: `
|
|
20
|
-
uniform sampler2D _textureA_;
|
|
21
|
-
uniform sampler2D _textureB_;
|
|
22
|
-
uniform float _mix_;
|
|
23
|
-
`,
|
|
24
|
-
|
|
25
|
-
mainFunctionName: "_wipe_",
|
|
26
|
-
|
|
27
|
-
mainInputTexture: "_textureB_",
|
|
28
|
-
|
|
29
|
-
functions: [
|
|
30
|
-
{
|
|
31
|
-
name: "_wipe_",
|
|
32
|
-
code: `
|
|
33
|
-
vec4 _wipe_(vec2 vUV)
|
|
34
|
-
{
|
|
35
|
-
vec4 colorA = texture2D(_textureA_, vUV);
|
|
36
|
-
vec4 colorB = texture2D(_textureB_, vUV);
|
|
37
|
-
return mix(colorB, colorA, step(_mix_, vUV.y));
|
|
38
|
-
}
|
|
39
|
-
`,
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The shader bindings for the Wipe block.
|
|
47
|
-
*/
|
|
48
|
-
export class WipeShaderBinding extends DisableableShaderBinding {
|
|
49
|
-
private readonly _textureA: RuntimeData<ConnectionPointType.Texture>;
|
|
50
|
-
private readonly _textureB: RuntimeData<ConnectionPointType.Texture>;
|
|
51
|
-
private readonly _mix: RuntimeData<ConnectionPointType.Float>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Creates a new shader binding instance for the Wipe block.
|
|
55
|
-
* @param parentBlock - The parent block
|
|
56
|
-
* @param textureA - The first texture
|
|
57
|
-
* @param textureB - The second texture
|
|
58
|
-
* @param mix - The mix value between the two textures
|
|
59
|
-
*/
|
|
60
|
-
constructor(
|
|
61
|
-
parentBlock: IDisableableBlock,
|
|
62
|
-
textureA: RuntimeData<ConnectionPointType.Texture>,
|
|
63
|
-
textureB: RuntimeData<ConnectionPointType.Texture>,
|
|
64
|
-
mix: RuntimeData<ConnectionPointType.Float>
|
|
65
|
-
) {
|
|
66
|
-
super(parentBlock);
|
|
67
|
-
this._textureA = textureA;
|
|
68
|
-
this._textureB = textureB;
|
|
69
|
-
this._mix = mix;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Binds all the required data to the shader when rendering.
|
|
74
|
-
* @param effect - defines the effect to bind the data to
|
|
75
|
-
*/
|
|
76
|
-
public override bind(effect: Effect): void {
|
|
77
|
-
super.bind(effect);
|
|
78
|
-
effect.setTexture(this.getRemappedName("textureA"), this._textureA.value);
|
|
79
|
-
effect.setTexture(this.getRemappedName("textureB"), this._textureB.value);
|
|
80
|
-
effect.setFloat(this.getRemappedName("mix"), this._mix.value);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* A block simulating a wipe effect to transition between two textures according to the mix value.
|
|
86
|
-
*/
|
|
87
|
-
export class WipeBlock extends DisableableShaderBlock {
|
|
88
|
-
/**
|
|
89
|
-
* The class name of the block.
|
|
90
|
-
*/
|
|
91
|
-
public static override ClassName = wipeBlockType;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* The namespace of the block.
|
|
95
|
-
*/
|
|
96
|
-
public static override Namespace = babylonDemoTransitionsNamespace;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* The first texture connection point.
|
|
100
|
-
*/
|
|
101
|
-
public readonly textureA = this._registerInput("textureA", ConnectionPointType.Texture);
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The second texture connection point.
|
|
105
|
-
*/
|
|
106
|
-
public readonly textureB = this._registerInput("textureB", ConnectionPointType.Texture);
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* The connection point containing the transition value between 0 (textureA) and 1 (textureB).
|
|
110
|
-
*/
|
|
111
|
-
public readonly mix = this._registerInput("mix", ConnectionPointType.Float);
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
115
|
-
*/
|
|
116
|
-
public static override ShaderCode = shaderProgram;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Instantiates a new Block.
|
|
120
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
121
|
-
* @param name - The friendly name of the block
|
|
122
|
-
*/
|
|
123
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
124
|
-
super(smartFilter, name);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
129
|
-
* @returns The class instance that binds the data to the effect
|
|
130
|
-
*/
|
|
131
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
132
|
-
const textureA = this._confirmRuntimeDataSupplied(this.textureA);
|
|
133
|
-
const textureB = this._confirmRuntimeDataSupplied(this.textureB);
|
|
134
|
-
const mix = this._confirmRuntimeDataSupplied(this.mix);
|
|
135
|
-
|
|
136
|
-
return new WipeShaderBinding(this, textureA, textureB, mix);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./premultiplyAlphaBlock.js";
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
-
|
|
3
|
-
import { type RuntimeData } from "../../../../connection/connectionPoint.js";
|
|
4
|
-
import { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
5
|
-
import { type IDisableableBlock, DisableableShaderBlock } from "../../../../blockFoundation/disableableShaderBlock.js";
|
|
6
|
-
import { DisableableShaderBinding } from "../../../../runtime/shaderRuntime.js";
|
|
7
|
-
import type { ShaderProgram } from "../../../../utils/shaderCodeUtils.js";
|
|
8
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
9
|
-
|
|
10
|
-
import { babylonDemoUtilitiesNamespace } from "../../../blockNamespaces.js";
|
|
11
|
-
import { premultiplyAlphaBlockType } from "../../../blockTypes.js";
|
|
12
|
-
|
|
13
|
-
const shaderProgram: ShaderProgram = {
|
|
14
|
-
fragment: {
|
|
15
|
-
uniform: `
|
|
16
|
-
uniform sampler2D _input_;
|
|
17
|
-
`,
|
|
18
|
-
|
|
19
|
-
mainFunctionName: "_premultiply_",
|
|
20
|
-
|
|
21
|
-
mainInputTexture: "_input_",
|
|
22
|
-
|
|
23
|
-
functions: [
|
|
24
|
-
{
|
|
25
|
-
name: "_premultiply_",
|
|
26
|
-
code: `
|
|
27
|
-
vec4 _premultiply_(vec2 vUV) {
|
|
28
|
-
vec4 color = texture2D(_input_, vUV);
|
|
29
|
-
return vec4(color.rgb * color.a, color.a);
|
|
30
|
-
}
|
|
31
|
-
`,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The shader bindings for the PremultiplyAlpha block.
|
|
39
|
-
*/
|
|
40
|
-
export class PremultiplyAlphaShaderBinding extends DisableableShaderBinding {
|
|
41
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates a new shader binding instance for the PremultiplyAlpha block.
|
|
45
|
-
* @param parentBlock - The parent block
|
|
46
|
-
* @param inputTexture - The input texture
|
|
47
|
-
*/
|
|
48
|
-
constructor(parentBlock: IDisableableBlock, inputTexture: RuntimeData<ConnectionPointType.Texture>) {
|
|
49
|
-
super(parentBlock);
|
|
50
|
-
this._inputTexture = inputTexture;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Binds all the required data to the shader when rendering.
|
|
55
|
-
* @param effect - defines the effect to bind the data to
|
|
56
|
-
*/
|
|
57
|
-
public override bind(effect: Effect): void {
|
|
58
|
-
super.bind(effect);
|
|
59
|
-
effect.setTexture(this.getRemappedName("input"), this._inputTexture.value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A utility block that premultiplies the input texture against its alpha.
|
|
65
|
-
* This is useful for preserving transparency when the WebGL context expects colors with pre-multiplied alpha (true by default).
|
|
66
|
-
*/
|
|
67
|
-
export class PremultiplyAlphaBlock extends DisableableShaderBlock {
|
|
68
|
-
/**
|
|
69
|
-
* The class name of the block.
|
|
70
|
-
*/
|
|
71
|
-
public static override ClassName = premultiplyAlphaBlockType;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* The namespace of the block.
|
|
75
|
-
*/
|
|
76
|
-
public static override Namespace = babylonDemoUtilitiesNamespace;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The input texture connection point.
|
|
80
|
-
*/
|
|
81
|
-
public readonly input = this._registerInput("input", ConnectionPointType.Texture);
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
85
|
-
*/
|
|
86
|
-
public static override ShaderCode = shaderProgram;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Instantiates a new block.
|
|
90
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
91
|
-
* @param name - The friendly name of the block
|
|
92
|
-
*/
|
|
93
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
94
|
-
super(smartFilter, name);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
99
|
-
* @returns The class instance that binds the data to the effect
|
|
100
|
-
*/
|
|
101
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
102
|
-
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
103
|
-
|
|
104
|
-
return new PremultiplyAlphaShaderBinding(this, input);
|
|
105
|
-
}
|
|
106
|
-
}
|
package/src/blocks/blockTypes.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const pixelateBlockType = "PixelateBlock";
|
|
2
|
-
export const blackAndWhiteBlockType = "BlackAndWhiteBlock";
|
|
3
|
-
export const exposureBlockType = "ExposureBlock";
|
|
4
|
-
export const contrastBlockType = "ContrastBlock";
|
|
5
|
-
export const desaturateBlockType = "DesaturateBlock";
|
|
6
|
-
export const posterizeBlockType = "PosterizeBlock";
|
|
7
|
-
export const kaleidoscopeBlockType = "KaleidoscopeBlock";
|
|
8
|
-
export const greenScreenBlockType = "GreenScreenBlock";
|
|
9
|
-
export const glassBlockType = "GlassBlock";
|
|
10
|
-
export const frameBlockType = "FrameBlock";
|
|
11
|
-
export const blurBlockType = "BlurBlock";
|
|
12
|
-
export const directionalBlurBlockType = "DirectionalBlurBlock";
|
|
13
|
-
export const compositionBlockType = "CompositionBlock";
|
|
14
|
-
export const glitchBlockType = "GlitchBlock";
|
|
15
|
-
export const tileBlockType = "TileBlock";
|
|
16
|
-
export const wipeBlockType = "WipeBlock";
|
|
17
|
-
export const maskBlockType = "MaskBlock";
|
|
18
|
-
export const particleBlockType = "ParticleBlock";
|
|
19
|
-
export const spritesheetBlockType = "SpritesheetBlock";
|
|
20
|
-
export const tintBlockType = "TintBlock";
|
|
21
|
-
export const premultiplyAlphaBlockType = "PremultiplyAlphaBlock";
|