@babylonjs/smart-filters-blocks 1.0.13 → 8.18.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
|
@@ -1,243 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** Defines that alpha blending is
|
|
20
|
-
export const
|
|
21
|
-
/** Defines that alpha blending is SRC ALPHA * SRC +
|
|
22
|
-
export const
|
|
23
|
-
/** Defines that alpha blending is
|
|
24
|
-
export const
|
|
25
|
-
/** Defines that alpha blending is SRC * DEST */
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
private readonly
|
|
37
|
-
private readonly
|
|
38
|
-
private readonly
|
|
39
|
-
private readonly
|
|
40
|
-
private readonly
|
|
41
|
-
private readonly
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
-
* @param
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
effect.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
effect.
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Defines
|
|
163
|
-
*/
|
|
164
|
-
public readonly
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*/
|
|
213
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
214
|
-
super(smartFilter, name, true);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
219
|
-
* @returns The class instance that binds the data to the effect
|
|
220
|
-
*/
|
|
221
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
222
|
-
const background = this._confirmRuntimeDataSupplied(this.background);
|
|
223
|
-
const foreground = this._confirmRuntimeDataSupplied(this.foreground);
|
|
224
|
-
const foregroundWidth = this.foregroundWidth.runtimeData;
|
|
225
|
-
const foregroundLeft = this.foregroundLeft.runtimeData;
|
|
226
|
-
const foregroundHeight = this.foregroundHeight.runtimeData;
|
|
227
|
-
const foregroundTop = this.foregroundTop.runtimeData;
|
|
228
|
-
const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
|
|
229
|
-
const alphaMode = this.alphaMode;
|
|
230
|
-
|
|
231
|
-
return new CompositionShaderBinding(
|
|
232
|
-
this,
|
|
233
|
-
background,
|
|
234
|
-
foreground,
|
|
235
|
-
foregroundTop,
|
|
236
|
-
foregroundLeft,
|
|
237
|
-
foregroundWidth,
|
|
238
|
-
foregroundHeight,
|
|
239
|
-
foregroundAlphaScale,
|
|
240
|
-
alphaMode
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
|
|
3
|
+
import type { Effect } from "core/Materials/effect.js";
|
|
4
|
+
import {
|
|
5
|
+
DisableableShaderBinding,
|
|
6
|
+
type RuntimeData,
|
|
7
|
+
ConnectionPointType,
|
|
8
|
+
type IDisableableBlock,
|
|
9
|
+
DisableableShaderBlock,
|
|
10
|
+
type SmartFilter,
|
|
11
|
+
createStrongRef,
|
|
12
|
+
PropertyTypeForEdition,
|
|
13
|
+
editableInPropertyPage,
|
|
14
|
+
} from "smart-filters";
|
|
15
|
+
import { compositionBlockType } from "../../../blockTypes.js";
|
|
16
|
+
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
17
|
+
import { uniforms, shaderProgram } from "./compositionBlock.fragment.js";
|
|
18
|
+
|
|
19
|
+
/** Defines that alpha blending is disabled */
|
|
20
|
+
export const ALPHA_DISABLE = 0;
|
|
21
|
+
/** Defines that alpha blending is SRC ALPHA * SRC + DEST */
|
|
22
|
+
export const ALPHA_ADD = 1;
|
|
23
|
+
/** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
|
|
24
|
+
export const ALPHA_COMBINE = 2;
|
|
25
|
+
/** Defines that alpha blending is DEST - SRC * DEST */
|
|
26
|
+
export const ALPHA_SUBTRACT = 3;
|
|
27
|
+
/** Defines that alpha blending is SRC * DEST */
|
|
28
|
+
export const ALPHA_MULTIPLY = 4;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The shader bindings for the Composition block.
|
|
32
|
+
* This demonstrates how multiple input connection point values can be packed into a single
|
|
33
|
+
* uniform.
|
|
34
|
+
*/
|
|
35
|
+
export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
36
|
+
private readonly _backgroundTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
37
|
+
private readonly _foregroundTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
38
|
+
private readonly _foregroundTop: RuntimeData<ConnectionPointType.Float>;
|
|
39
|
+
private readonly _foregroundLeft: RuntimeData<ConnectionPointType.Float>;
|
|
40
|
+
private readonly _foregroundWidth: RuntimeData<ConnectionPointType.Float>;
|
|
41
|
+
private readonly _foregroundHeight: RuntimeData<ConnectionPointType.Float>;
|
|
42
|
+
private readonly _foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>;
|
|
43
|
+
private readonly _alphaMode: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new shader binding instance for the Composition block.
|
|
47
|
+
* @param parentBlock - The parent block
|
|
48
|
+
* @param backgroundTexture - the background texture
|
|
49
|
+
* @param foregroundTexture - the foreground texture
|
|
50
|
+
* @param foregroundTop - the top position of the foreground texture
|
|
51
|
+
* @param foregroundLeft - the left position of the foreground texture
|
|
52
|
+
* @param foregroundWidth - the width of the foreground texture
|
|
53
|
+
* @param foregroundHeight - the height of the foreground texture
|
|
54
|
+
* @param foregroundAlphaScale - the alpha scale of the foreground texture
|
|
55
|
+
* @param alphaMode - the alpha mode to use
|
|
56
|
+
*/
|
|
57
|
+
constructor(
|
|
58
|
+
parentBlock: IDisableableBlock,
|
|
59
|
+
backgroundTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
60
|
+
foregroundTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
61
|
+
foregroundTop: RuntimeData<ConnectionPointType.Float>,
|
|
62
|
+
foregroundLeft: RuntimeData<ConnectionPointType.Float>,
|
|
63
|
+
foregroundWidth: RuntimeData<ConnectionPointType.Float>,
|
|
64
|
+
foregroundHeight: RuntimeData<ConnectionPointType.Float>,
|
|
65
|
+
foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>,
|
|
66
|
+
alphaMode: number
|
|
67
|
+
) {
|
|
68
|
+
super(parentBlock);
|
|
69
|
+
this._backgroundTexture = backgroundTexture;
|
|
70
|
+
this._foregroundTexture = foregroundTexture;
|
|
71
|
+
this._foregroundTop = foregroundTop;
|
|
72
|
+
this._foregroundLeft = foregroundLeft;
|
|
73
|
+
this._foregroundWidth = foregroundWidth;
|
|
74
|
+
this._foregroundHeight = foregroundHeight;
|
|
75
|
+
this._foregroundAlphaScale = foregroundAlphaScale;
|
|
76
|
+
this._alphaMode = alphaMode;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Binds all the required data to the shader when rendering.
|
|
81
|
+
* @param effect - defines the effect to bind the data to
|
|
82
|
+
* @param width - defines the width of the output
|
|
83
|
+
* @param height - defines the height of the output
|
|
84
|
+
*/
|
|
85
|
+
public override bind(effect: Effect, width: number, height: number): void {
|
|
86
|
+
super.bind(effect, width, height);
|
|
87
|
+
|
|
88
|
+
const background = this._backgroundTexture.value;
|
|
89
|
+
const foreground = this._foregroundTexture.value;
|
|
90
|
+
const foregroundTop = this._foregroundTop.value;
|
|
91
|
+
const foregroundLeft = this._foregroundLeft.value;
|
|
92
|
+
const foregroundWidth = this._foregroundWidth.value;
|
|
93
|
+
const foregroundHeight = this._foregroundHeight.value;
|
|
94
|
+
const foregroundAlphaScale = this._foregroundAlphaScale.value;
|
|
95
|
+
const alphaMode = this._alphaMode;
|
|
96
|
+
|
|
97
|
+
effect.setFloat(this.getRemappedName(uniforms.alphaMode), alphaMode);
|
|
98
|
+
effect.setTexture(this.getRemappedName(uniforms.background), background);
|
|
99
|
+
effect.setTexture(this.getRemappedName(uniforms.foreground), foreground);
|
|
100
|
+
|
|
101
|
+
// NOTE: textures may always be undefined if connected to another shader block when the graph is optimized
|
|
102
|
+
|
|
103
|
+
effect.setFloat2(this.getRemappedName(uniforms.scaleUV), foregroundWidth, foregroundHeight);
|
|
104
|
+
effect.setFloat2(this.getRemappedName(uniforms.translateUV), -1 * foregroundLeft, foregroundTop);
|
|
105
|
+
effect.setFloat(this.getRemappedName(uniforms.foregroundAlphaScale), foregroundAlphaScale);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A simple compositing Block letting the filter "blend" 2 different layers.
|
|
111
|
+
* It demonstrates how a block can use properties for values which will not change at runtime (alphaMode)
|
|
112
|
+
*
|
|
113
|
+
* The alpha mode of the block can be set to one of the following:
|
|
114
|
+
* - ALPHA_DISABLE: alpha blending is disabled
|
|
115
|
+
* - ALPHA_ADD: alpha blending is SRC ALPHA * SRC + DEST
|
|
116
|
+
* - ALPHA_COMBINE: alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST
|
|
117
|
+
* - ALPHA_SUBTRACT: alpha blending is DEST - SRC * DEST
|
|
118
|
+
* - ALPHA_MULTIPLY: alpha blending is SRC * DEST
|
|
119
|
+
*/
|
|
120
|
+
export class CompositionBlock extends DisableableShaderBlock {
|
|
121
|
+
/**
|
|
122
|
+
* The class name of the block.
|
|
123
|
+
*/
|
|
124
|
+
public static override ClassName = compositionBlockType;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The namespace of the block.
|
|
128
|
+
*/
|
|
129
|
+
public static override Namespace = babylonDemoEffectsNamespace;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The background texture to composite on to.
|
|
133
|
+
*/
|
|
134
|
+
public readonly background = this._registerInput(uniforms.background, ConnectionPointType.Texture);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The foreground texture to composite in.
|
|
138
|
+
*/
|
|
139
|
+
public readonly foreground = this._registerOptionalInput(uniforms.foreground, ConnectionPointType.Texture, createStrongRef(null));
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Defines where the top of the texture to composite in should be displayed. (between 0 and 1).
|
|
143
|
+
*/
|
|
144
|
+
public readonly foregroundTop = this._registerOptionalInput("foregroundTop", ConnectionPointType.Float, createStrongRef(0.0));
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Defines where the left of the texture to composite in should be displayed. (between 0 and 1).
|
|
148
|
+
*/
|
|
149
|
+
public readonly foregroundLeft = this._registerOptionalInput("foregroundLeft", ConnectionPointType.Float, createStrongRef(0.0));
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Defines the width of the texture in the composition.
|
|
153
|
+
*/
|
|
154
|
+
public readonly foregroundWidth = this._registerOptionalInput("foregroundWidth", ConnectionPointType.Float, createStrongRef(1.0));
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Defines the height of the texture in the composition.
|
|
158
|
+
*/
|
|
159
|
+
public readonly foregroundHeight = this._registerOptionalInput("foregroundHeight", ConnectionPointType.Float, createStrongRef(1.0));
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Defines a multiplier applied to the foreground's alpha channel.
|
|
163
|
+
*/
|
|
164
|
+
public readonly foregroundAlphaScale = this._registerOptionalInput(uniforms.foregroundAlphaScale, ConnectionPointType.Float, createStrongRef(1.0));
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Defines blend mode of the composition.
|
|
168
|
+
*/
|
|
169
|
+
@editableInPropertyPage("Alpha Mode", PropertyTypeForEdition.List, "PROPERTIES", {
|
|
170
|
+
notifiers: { rebuild: true },
|
|
171
|
+
options: [
|
|
172
|
+
{ label: "Disable", value: ALPHA_DISABLE },
|
|
173
|
+
{ label: "Add", value: ALPHA_ADD },
|
|
174
|
+
{ label: "Combine", value: ALPHA_COMBINE },
|
|
175
|
+
{ label: "Subtract", value: ALPHA_SUBTRACT },
|
|
176
|
+
{ label: "Multiply", value: ALPHA_MULTIPLY },
|
|
177
|
+
],
|
|
178
|
+
})
|
|
179
|
+
public alphaMode: number = ALPHA_COMBINE;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
183
|
+
*/
|
|
184
|
+
public static override ShaderCode = shaderProgram;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Instantiates a new Block.
|
|
188
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
189
|
+
* @param name - The friendly name of the block
|
|
190
|
+
*/
|
|
191
|
+
constructor(smartFilter: SmartFilter, name: string) {
|
|
192
|
+
super(smartFilter, name, true);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
197
|
+
* @returns The class instance that binds the data to the effect
|
|
198
|
+
*/
|
|
199
|
+
public getShaderBinding(): DisableableShaderBinding {
|
|
200
|
+
const background = this._confirmRuntimeDataSupplied(this.background);
|
|
201
|
+
const foreground = this._confirmRuntimeDataSupplied(this.foreground);
|
|
202
|
+
const foregroundWidth = this.foregroundWidth.runtimeData;
|
|
203
|
+
const foregroundLeft = this.foregroundLeft.runtimeData;
|
|
204
|
+
const foregroundHeight = this.foregroundHeight.runtimeData;
|
|
205
|
+
const foregroundTop = this.foregroundTop.runtimeData;
|
|
206
|
+
const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
|
|
207
|
+
const alphaMode = this.alphaMode;
|
|
208
|
+
|
|
209
|
+
return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale, alphaMode);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -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: `
|
|
@@ -81,11 +81,12 @@ const shaderProgram: ShaderProgram = {
|
|
|
81
81
|
* The uniform names for this shader, to be used in the shader binding so
|
|
82
82
|
* that the names are always in sync.
|
|
83
83
|
*/
|
|
84
|
-
const
|
|
84
|
+
const Uniforms = {
|
|
85
85
|
input: "input",
|
|
86
86
|
intensity: "intensity",
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
|
|
89
90
|
/**
|
|
90
91
|
* The shader binding for the ContrastBlock, used by the runtime
|
|
91
92
|
*/
|
|
@@ -115,8 +116,8 @@ class ContrastBlockShaderBinding extends DisableableShaderBinding {
|
|
|
115
116
|
*/
|
|
116
117
|
public override bind(effect: Effect): void {
|
|
117
118
|
super.bind(effect);
|
|
118
|
-
effect.setTexture(this.getRemappedName(
|
|
119
|
-
effect.setFloat(this.getRemappedName(
|
|
119
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
120
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -137,7 +138,7 @@ export class ContrastBlock extends DisableableShaderBlock {
|
|
|
137
138
|
/**
|
|
138
139
|
* The input connection point.
|
|
139
140
|
*/
|
|
140
|
-
public readonly input = this._registerInput(
|
|
141
|
+
public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
141
142
|
|
|
142
143
|
/**
|
|
143
144
|
/**
|
|
@@ -152,7 +153,7 @@ export class ContrastBlock extends DisableableShaderBlock {
|
|
|
152
153
|
/**
|
|
153
154
|
* The shader program (vertex and fragment code) to use to render the block
|
|
154
155
|
*/
|
|
155
|
-
public static override ShaderCode =
|
|
156
|
+
public static override ShaderCode = BlockShaderProgram;
|
|
156
157
|
|
|
157
158
|
/**
|
|
158
159
|
* Instantiates a new ContrastBlock.
|
|
@@ -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: `
|
|
@@ -58,11 +58,12 @@ const shaderProgram: ShaderProgram = {
|
|
|
58
58
|
* The uniform names for this shader, to be used in the shader binding so
|
|
59
59
|
* that the names are always in sync.
|
|
60
60
|
*/
|
|
61
|
-
const
|
|
61
|
+
const Uniforms = {
|
|
62
62
|
input: "input",
|
|
63
63
|
intensity: "intensity",
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
|
|
66
67
|
/**
|
|
67
68
|
* The shader binding for the DesaturateBlock, used by the runtime
|
|
68
69
|
*/
|
|
@@ -92,8 +93,8 @@ class DesaturateBlockShaderBinding extends DisableableShaderBinding {
|
|
|
92
93
|
*/
|
|
93
94
|
public override bind(effect: Effect): void {
|
|
94
95
|
super.bind(effect);
|
|
95
|
-
effect.setTexture(this.getRemappedName(
|
|
96
|
-
effect.setFloat(this.getRemappedName(
|
|
96
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
97
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -114,7 +115,7 @@ export class DesaturateBlock extends DisableableShaderBlock {
|
|
|
114
115
|
/**
|
|
115
116
|
* The input connection point.
|
|
116
117
|
*/
|
|
117
|
-
public readonly input = this._registerInput(
|
|
118
|
+
public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
118
119
|
|
|
119
120
|
/**
|
|
120
121
|
/**
|
|
@@ -129,7 +130,7 @@ export class DesaturateBlock extends DisableableShaderBlock {
|
|
|
129
130
|
/**
|
|
130
131
|
* The shader program (vertex and fragment code) to use to render the block
|
|
131
132
|
*/
|
|
132
|
-
public static override ShaderCode =
|
|
133
|
+
public static override ShaderCode = BlockShaderProgram;
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
136
|
* Instantiates a new DesaturateBlock.
|