@babylonjs/smart-filters-blocks 1.0.13 → 8.19.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.
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js +5 -5
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js +3 -5
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.js +8 -13
- package/dist/blocks/babylon/demo/effects/blurBlock.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts +7 -7
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js +2 -3
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts +4 -2
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js +5 -2
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.js +2 -6
- package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js +1 -1
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.js +6 -6
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js +6 -6
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts +3 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js +4 -5
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js +32 -37
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js +1 -1
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.js +7 -7
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js +11 -11
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts +6 -1
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js +71 -71
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/maskBlock.block.js +7 -7
- package/dist/blocks/babylon/demo/effects/maskBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts +2 -2
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js +8 -8
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js +6 -6
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts +5 -5
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts +4 -2
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js +5 -2
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js.map +1 -1
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts +1 -1
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/effects/tintBlock.js +10 -10
- package/dist/blocks/babylon/demo/effects/tintBlock.js.map +1 -1
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js +9 -9
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js.map +1 -1
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts.map +1 -1
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js +5 -5
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js.map +1 -1
- package/dist/blocks/blockNamespaces.d.ts.map +1 -1
- package/dist/blocks/blockNamespaces.js +2 -0
- package/dist/blocks/blockNamespaces.js.map +1 -1
- package/dist/blocks/blockTypes.d.ts.map +1 -1
- package/dist/blocks/blockTypes.js +2 -0
- package/dist/blocks/blockTypes.js.map +1 -1
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +1 -0
- package/dist/blocks/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/registration/IBlockRegistration.d.ts +1 -1
- package/dist/registration/IBlockRegistration.d.ts.map +1 -1
- package/dist/registration/blockSerializers.d.ts.map +1 -1
- package/dist/registration/blockSerializers.js +6 -8
- package/dist/registration/blockSerializers.js.map +1 -1
- package/dist/registration/builtInBlockRegistrations.d.ts +1 -1
- package/dist/registration/builtInBlockRegistrations.d.ts.map +1 -1
- package/dist/registration/builtInBlockRegistrations.js +50 -52
- package/dist/registration/builtInBlockRegistrations.js.map +1 -1
- package/dist/registration/index.d.ts +1 -0
- package/dist/registration/index.d.ts.map +1 -1
- package/dist/registration/index.js +2 -0
- package/dist/registration/index.js.map +1 -1
- package/license.md +21 -21
- package/package.json +15 -13
- package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.ts +8 -7
- package/src/blocks/babylon/demo/effects/blurBlock.deserializer.ts +37 -37
- package/src/blocks/babylon/demo/effects/blurBlock.serializer.ts +31 -31
- package/src/blocks/babylon/demo/effects/blurBlock.ts +115 -122
- package/src/blocks/babylon/demo/effects/compositionBlock.deserializer.ts +31 -31
- package/src/blocks/babylon/demo/effects/compositionBlock.fragment.ts +7 -3
- package/src/blocks/babylon/demo/effects/compositionBlock.serializer.ts +28 -28
- package/src/blocks/babylon/demo/effects/compositionBlock.ts +211 -243
- package/src/blocks/babylon/demo/effects/contrastBlock.block.ts +9 -8
- package/src/blocks/babylon/demo/effects/desaturateBlock.block.ts +9 -8
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.ts +43 -46
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.serializer.ts +30 -30
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.ts +192 -196
- package/src/blocks/babylon/demo/effects/exposureBlock.block.ts +10 -9
- package/src/blocks/babylon/demo/effects/greenScreenBlock.block.ts +14 -13
- package/src/blocks/babylon/demo/effects/index.ts +14 -14
- package/src/blocks/babylon/demo/effects/kaleidoscopeBlock.ts +188 -192
- package/src/blocks/babylon/demo/effects/maskBlock.block.ts +10 -9
- package/src/blocks/babylon/demo/effects/pixelateBlock.block.ts +11 -10
- package/src/blocks/babylon/demo/effects/posterizeBlock.block.ts +9 -8
- package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts +7 -3
- package/src/blocks/babylon/demo/effects/spritesheetBlock.ts +135 -138
- package/src/blocks/babylon/demo/effects/tintBlock.ts +51 -51
- package/src/blocks/babylon/demo/transitions/index.ts +1 -1
- package/src/blocks/babylon/demo/transitions/wipeBlock.block.ts +12 -11
- package/src/blocks/babylon/demo/utilities/index.ts +1 -1
- package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.ts +8 -7
- package/src/blocks/blockNamespaces.ts +6 -4
- package/src/blocks/blockTypes.ts +23 -21
- package/src/blocks/index.ts +6 -5
- package/src/index.ts +3 -2
- package/src/registration/IBlockRegistration.ts +43 -48
- package/src/registration/blockSerializers.ts +50 -52
- package/src/registration/builtInBlockRegistrations.ts +293 -403
- package/src/registration/index.ts +4 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// to the block. This file will get overwritten when the build
|
|
9
9
|
// is run or during a watch when the .glsl file is updated.
|
|
10
10
|
|
|
11
|
-
import type { Effect } from "
|
|
11
|
+
import type { Effect } from "core/Materials/effect.js";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
DisableableShaderBinding,
|
|
@@ -19,12 +19,12 @@ import {
|
|
|
19
19
|
type ShaderProgram,
|
|
20
20
|
createStrongRef,
|
|
21
21
|
type IDisableableBlock,
|
|
22
|
-
BlockDisableStrategy} from "
|
|
22
|
+
BlockDisableStrategy} from "smart-filters";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* The shader program for the block.
|
|
26
26
|
*/
|
|
27
|
-
const
|
|
27
|
+
const BlockShaderProgram: ShaderProgram = {
|
|
28
28
|
vertex: undefined,
|
|
29
29
|
fragment: {
|
|
30
30
|
uniform: `
|
|
@@ -59,11 +59,12 @@ const shaderProgram: ShaderProgram = {
|
|
|
59
59
|
* The uniform names for this shader, to be used in the shader binding so
|
|
60
60
|
* that the names are always in sync.
|
|
61
61
|
*/
|
|
62
|
-
const
|
|
62
|
+
const Uniforms = {
|
|
63
63
|
input: "input",
|
|
64
64
|
intensity: "intensity",
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
|
|
67
68
|
/**
|
|
68
69
|
* The shader binding for the PosterizeBlock, used by the runtime
|
|
69
70
|
*/
|
|
@@ -93,8 +94,8 @@ class PosterizeBlockShaderBinding extends DisableableShaderBinding {
|
|
|
93
94
|
*/
|
|
94
95
|
public override bind(effect: Effect): void {
|
|
95
96
|
super.bind(effect);
|
|
96
|
-
effect.setTexture(this.getRemappedName(
|
|
97
|
-
effect.setFloat(this.getRemappedName(
|
|
97
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
98
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -115,7 +116,7 @@ export class PosterizeBlock extends DisableableShaderBlock {
|
|
|
115
116
|
/**
|
|
116
117
|
* The input connection point.
|
|
117
118
|
*/
|
|
118
|
-
public readonly input = this._registerInput(
|
|
119
|
+
public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
119
120
|
|
|
120
121
|
/**
|
|
121
122
|
/**
|
|
@@ -130,7 +131,7 @@ export class PosterizeBlock extends DisableableShaderBlock {
|
|
|
130
131
|
/**
|
|
131
132
|
* The shader program (vertex and fragment code) to use to render the block
|
|
132
133
|
*/
|
|
133
|
-
public static override ShaderCode =
|
|
134
|
+
public static override ShaderCode = BlockShaderProgram;
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
137
|
* Instantiates a new PosterizeBlock.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ShaderProgram } from "
|
|
1
|
+
import type { ShaderProgram } from "smart-filters";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The shader program for the block.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const BlockShaderProgram: ShaderProgram = {
|
|
7
7
|
vertex: undefined,
|
|
8
8
|
fragment: {
|
|
9
9
|
uniform: `
|
|
@@ -49,7 +49,7 @@ export const shaderProgram: ShaderProgram = {
|
|
|
49
49
|
* The uniform names for this shader, to be used in the shader binding so
|
|
50
50
|
* that the names are always in sync.
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
const Uniforms = {
|
|
53
53
|
input: "input",
|
|
54
54
|
time: "time",
|
|
55
55
|
rows: "rows",
|
|
@@ -57,3 +57,7 @@ export const uniforms = {
|
|
|
57
57
|
frames: "frames",
|
|
58
58
|
disabled: "disabled",
|
|
59
59
|
};
|
|
60
|
+
|
|
61
|
+
export { BlockShaderProgram, Uniforms };
|
|
62
|
+
// Back compat for when camelCase was used
|
|
63
|
+
export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
|
|
@@ -1,138 +1,135 @@
|
|
|
1
|
-
import type { Effect } from "
|
|
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 "
|
|
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(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return new SpritesheetShaderBinding(this, input, time, rows, columns, frames);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
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
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { ConnectionPointType, type SerializedShaderBlockDefinition } from "
|
|
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
|
|
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
|
-
};
|
|
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
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./wipeBlock.block.js";
|
|
1
|
+
export * from "./wipeBlock.block.js";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// to the block. This file will get overwritten when the build
|
|
9
9
|
// is run or during a watch when the .glsl file is updated.
|
|
10
10
|
|
|
11
|
-
import type { Effect } from "
|
|
11
|
+
import type { Effect } from "core/Materials/effect.js";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
ShaderBinding,
|
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
type SmartFilter,
|
|
18
18
|
ShaderBlock,
|
|
19
19
|
type ShaderProgram,
|
|
20
|
-
} from "
|
|
20
|
+
} from "smart-filters";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* The shader program for the block.
|
|
24
24
|
*/
|
|
25
|
-
const
|
|
25
|
+
const BlockShaderProgram: ShaderProgram = {
|
|
26
26
|
vertex: undefined,
|
|
27
27
|
fragment: {
|
|
28
28
|
uniform: `
|
|
@@ -51,12 +51,13 @@ const shaderProgram: ShaderProgram = {
|
|
|
51
51
|
* The uniform names for this shader, to be used in the shader binding so
|
|
52
52
|
* that the names are always in sync.
|
|
53
53
|
*/
|
|
54
|
-
const
|
|
54
|
+
const Uniforms = {
|
|
55
55
|
textureA: "textureA",
|
|
56
56
|
textureB: "textureB",
|
|
57
57
|
progress: "progress",
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
|
|
60
61
|
/**
|
|
61
62
|
* The shader binding for the WipeBlock, used by the runtime
|
|
62
63
|
*/
|
|
@@ -87,9 +88,9 @@ class WipeBlockShaderBinding extends ShaderBinding {
|
|
|
87
88
|
* @param effect - defines the effect to bind the data to
|
|
88
89
|
*/
|
|
89
90
|
public override bind(effect: Effect): void {
|
|
90
|
-
effect.setTexture(this.getRemappedName(
|
|
91
|
-
effect.setTexture(this.getRemappedName(
|
|
92
|
-
effect.setFloat(this.getRemappedName(
|
|
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);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -110,22 +111,22 @@ export class WipeBlock extends ShaderBlock {
|
|
|
110
111
|
/**
|
|
111
112
|
* The textureA connection point.
|
|
112
113
|
*/
|
|
113
|
-
public readonly textureA = this._registerInput(
|
|
114
|
+
public readonly textureA = this._registerInput(Uniforms.textureA, ConnectionPointType.Texture);
|
|
114
115
|
|
|
115
116
|
/**
|
|
116
117
|
* The textureB connection point.
|
|
117
118
|
*/
|
|
118
|
-
public readonly textureB = this._registerInput(
|
|
119
|
+
public readonly textureB = this._registerInput(Uniforms.textureB, ConnectionPointType.Texture);
|
|
119
120
|
|
|
120
121
|
/**
|
|
121
122
|
* The progress connection point.
|
|
122
123
|
*/
|
|
123
|
-
public readonly progress = this._registerInput(
|
|
124
|
+
public readonly progress = this._registerInput(Uniforms.progress, ConnectionPointType.Float);
|
|
124
125
|
|
|
125
126
|
/**
|
|
126
127
|
* The shader program (vertex and fragment code) to use to render the block
|
|
127
128
|
*/
|
|
128
|
-
public static override ShaderCode =
|
|
129
|
+
public static override ShaderCode = BlockShaderProgram;
|
|
129
130
|
|
|
130
131
|
/**
|
|
131
132
|
* Instantiates a new WipeBlock.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./premultiplyAlphaBlock.block.js";
|
|
1
|
+
export * from "./premultiplyAlphaBlock.block.js";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// to the block. This file will get overwritten when the build
|
|
9
9
|
// is run or during a watch when the .glsl file is updated.
|
|
10
10
|
|
|
11
|
-
import type { Effect } from "
|
|
11
|
+
import type { Effect } from "core/Materials/effect.js";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
DisableableShaderBinding,
|
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
DisableableShaderBlock,
|
|
19
19
|
type ShaderProgram,
|
|
20
20
|
type IDisableableBlock,
|
|
21
|
-
BlockDisableStrategy} from "
|
|
21
|
+
BlockDisableStrategy} from "smart-filters";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The shader program for the block.
|
|
25
25
|
*/
|
|
26
|
-
const
|
|
26
|
+
const BlockShaderProgram: ShaderProgram = {
|
|
27
27
|
vertex: undefined,
|
|
28
28
|
fragment: {
|
|
29
29
|
uniform: `
|
|
@@ -49,10 +49,11 @@ const shaderProgram: ShaderProgram = {
|
|
|
49
49
|
* The uniform names for this shader, to be used in the shader binding so
|
|
50
50
|
* that the names are always in sync.
|
|
51
51
|
*/
|
|
52
|
-
const
|
|
52
|
+
const Uniforms = {
|
|
53
53
|
input: "input",
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
|
|
56
57
|
/**
|
|
57
58
|
* The shader binding for the PremultiplyAlphaBlock, used by the runtime
|
|
58
59
|
*/
|
|
@@ -78,7 +79,7 @@ class PremultiplyAlphaBlockShaderBinding extends DisableableShaderBinding {
|
|
|
78
79
|
*/
|
|
79
80
|
public override bind(effect: Effect): void {
|
|
80
81
|
super.bind(effect);
|
|
81
|
-
effect.setTexture(this.getRemappedName(
|
|
82
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -99,12 +100,12 @@ export class PremultiplyAlphaBlock extends DisableableShaderBlock {
|
|
|
99
100
|
/**
|
|
100
101
|
* The input connection point.
|
|
101
102
|
*/
|
|
102
|
-
public readonly input = this._registerInput(
|
|
103
|
+
public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
103
104
|
|
|
104
105
|
/**
|
|
105
106
|
* The shader program (vertex and fragment code) to use to render the block
|
|
106
107
|
*/
|
|
107
|
-
public static override ShaderCode =
|
|
108
|
+
public static override ShaderCode = BlockShaderProgram;
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
111
|
* Instantiates a new PremultiplyAlphaBlock.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
export const babylonDemoEffectsNamespace = "Babylon.Demo.Effects";
|
|
3
|
+
export const babylonDemoUtilitiesNamespace = "Babylon.Demo.Utilities";
|
|
4
|
+
export const babylonDemoTransitionsNamespace = "Babylon.Demo.Transitions";
|
|
5
|
+
export const inputsNamespace = "Inputs";
|
|
6
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|