@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,137 +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
|
-
import { createStrongRef } from "../../../../runtime/strongRef.js";
|
|
10
|
-
|
|
11
|
-
import { desaturateBlockType } from "../../../blockTypes.js";
|
|
12
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
13
|
-
|
|
14
|
-
const shaderProgram: ShaderProgram = {
|
|
15
|
-
fragment: {
|
|
16
|
-
uniform: `
|
|
17
|
-
uniform sampler2D _input_;
|
|
18
|
-
uniform float _intensity_;
|
|
19
|
-
`,
|
|
20
|
-
|
|
21
|
-
const: `
|
|
22
|
-
const float _aspect_ = 1.72;
|
|
23
|
-
`,
|
|
24
|
-
|
|
25
|
-
mainFunctionName: "_desaturate_",
|
|
26
|
-
|
|
27
|
-
mainInputTexture: "_input_",
|
|
28
|
-
|
|
29
|
-
functions: [
|
|
30
|
-
{
|
|
31
|
-
name: "_desaturate_",
|
|
32
|
-
code: `
|
|
33
|
-
vec4 _desaturate_(vec2 vUV)
|
|
34
|
-
{
|
|
35
|
-
float saturationStrength = 1. - _intensity_;
|
|
36
|
-
|
|
37
|
-
vec4 color = texture2D(_input_, vUV);
|
|
38
|
-
|
|
39
|
-
float tempMin = min(min(color.x, color.y), color.z);
|
|
40
|
-
float tempMax = max(max(color.x, color.y), color.z);
|
|
41
|
-
float tempMerge = 0.5 * (tempMin + tempMax);
|
|
42
|
-
|
|
43
|
-
return vec4(mix(color.rgb, vec3(tempMerge, tempMerge, tempMerge), saturationStrength), color.a);
|
|
44
|
-
}
|
|
45
|
-
`,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The shader bindings for the Desaturate block.
|
|
53
|
-
*/
|
|
54
|
-
export class DesaturateShaderBinding extends DisableableShaderBinding {
|
|
55
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
56
|
-
private readonly _intensity: RuntimeData<ConnectionPointType.Float>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new shader binding instance for the Desaturate block.
|
|
60
|
-
* @param parentBlock - The parent block
|
|
61
|
-
* @param inputTexture - The input texture
|
|
62
|
-
* @param intensity - The intensity of the desaturation
|
|
63
|
-
*/
|
|
64
|
-
constructor(
|
|
65
|
-
parentBlock: IDisableableBlock,
|
|
66
|
-
inputTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
67
|
-
intensity: RuntimeData<ConnectionPointType.Float>
|
|
68
|
-
) {
|
|
69
|
-
super(parentBlock);
|
|
70
|
-
this._inputTexture = inputTexture;
|
|
71
|
-
this._intensity = intensity;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Binds all the required data to the shader when rendering.
|
|
76
|
-
* @param effect - defines the effect to bind the data to
|
|
77
|
-
*/
|
|
78
|
-
public override bind(effect: Effect): void {
|
|
79
|
-
super.bind(effect);
|
|
80
|
-
effect.setTexture(this.getRemappedName("input"), this._inputTexture.value);
|
|
81
|
-
effect.setFloat(this.getRemappedName("intensity"), this._intensity.value);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* A simple block to desaturate the input texture.
|
|
87
|
-
*/
|
|
88
|
-
export class DesaturateBlock extends DisableableShaderBlock {
|
|
89
|
-
/**
|
|
90
|
-
* The class name of the block.
|
|
91
|
-
*/
|
|
92
|
-
public static override ClassName = desaturateBlockType;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The namespace of the block.
|
|
96
|
-
*/
|
|
97
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The input texture connection point.
|
|
101
|
-
*/
|
|
102
|
-
public readonly input = this._registerInput("input", ConnectionPointType.Texture);
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The intensity connection point.
|
|
106
|
-
*/
|
|
107
|
-
public readonly intensity = this._registerOptionalInput(
|
|
108
|
-
"intensity",
|
|
109
|
-
ConnectionPointType.Float,
|
|
110
|
-
createStrongRef(0.3)
|
|
111
|
-
);
|
|
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 input = this._confirmRuntimeDataSupplied(this.input);
|
|
133
|
-
const intensity = this.intensity.runtimeData;
|
|
134
|
-
|
|
135
|
-
return new DesaturateShaderBinding(this, input, intensity);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ISerializedBlockV1 } from "../../../../serialization/index.js";
|
|
2
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
3
|
-
import { DirectionalBlurBlock } from "./directionalBlurBlock.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The definition of the extra data serialized for directional blur blocks.
|
|
7
|
-
*/
|
|
8
|
-
export interface ISerializedDirectionalBlurBlockV1 extends ISerializedBlockV1 {
|
|
9
|
-
/**
|
|
10
|
-
* The extra data of the block.
|
|
11
|
-
*/
|
|
12
|
-
data: {
|
|
13
|
-
/**
|
|
14
|
-
* The horizontal width of the blur.
|
|
15
|
-
*/
|
|
16
|
-
blurHorizontalWidth: number;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The vertical width of the blur.
|
|
20
|
-
*/
|
|
21
|
-
blurVerticalWidth: number;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The blur texture ratio.
|
|
25
|
-
*/
|
|
26
|
-
blurTextureRatio: number;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* V1 Directional Blur Deserializer.
|
|
32
|
-
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
33
|
-
* @param serializedBlock - The serialized block data
|
|
34
|
-
* @returns A deserialized DirectionalBlurBlock
|
|
35
|
-
*/
|
|
36
|
-
export function directionalBlurDeserializer(
|
|
37
|
-
smartFilter: SmartFilter,
|
|
38
|
-
serializedBlock: ISerializedDirectionalBlurBlockV1
|
|
39
|
-
) {
|
|
40
|
-
const block = new DirectionalBlurBlock(smartFilter, serializedBlock.name);
|
|
41
|
-
|
|
42
|
-
// If data is missing, use the default value set by the block
|
|
43
|
-
block.blurHorizontalWidth = serializedBlock.data.blurHorizontalWidth ?? block.blurHorizontalWidth;
|
|
44
|
-
block.blurVerticalWidth = serializedBlock.data.blurVerticalWidth ?? block.blurVerticalWidth;
|
|
45
|
-
block.blurTextureRatio = serializedBlock.data.blurTextureRatio ?? block.blurTextureRatio;
|
|
46
|
-
return block;
|
|
47
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { BaseBlock } from "../../../../blockFoundation";
|
|
2
|
-
import type { IBlockSerializerV1 } from "../../../../serialization";
|
|
3
|
-
import type { DirectionalBlurBlock } from "./directionalBlurBlock";
|
|
4
|
-
import { directionalBlurBlockType } from "../../../blockTypes.js";
|
|
5
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The V1 serializer for a Directional Blur Block
|
|
9
|
-
*/
|
|
10
|
-
export const directionalBlurBlockSerializer: IBlockSerializerV1 = {
|
|
11
|
-
blockType: directionalBlurBlockType,
|
|
12
|
-
serialize: (block: BaseBlock) => {
|
|
13
|
-
if (block.getClassName() !== directionalBlurBlockType) {
|
|
14
|
-
throw new Error("Was asked to serialize an unrecognized block type");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const directionalBlurBlock = block as DirectionalBlurBlock;
|
|
18
|
-
return {
|
|
19
|
-
name: block.name,
|
|
20
|
-
uniqueId: block.uniqueId,
|
|
21
|
-
blockType: directionalBlurBlockType,
|
|
22
|
-
namespace: babylonDemoEffectsNamespace,
|
|
23
|
-
comments: block.comments,
|
|
24
|
-
data: {
|
|
25
|
-
blurTextureRatio: directionalBlurBlock.blurTextureRatio,
|
|
26
|
-
blurHorizontalWidth: directionalBlurBlock.blurHorizontalWidth,
|
|
27
|
-
blurVerticalWidth: directionalBlurBlock.blurVerticalWidth,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
};
|
|
@@ -1,193 +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 { ShaderBinding } from "../../../../runtime/shaderRuntime.js";
|
|
6
|
-
import type { ShaderProgram } from "../../../../utils/shaderCodeUtils.js";
|
|
7
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
8
|
-
import { ShaderBlock } from "../../../../blockFoundation/shaderBlock.js";
|
|
9
|
-
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../editorUtils/editableInPropertyPage.js";
|
|
10
|
-
|
|
11
|
-
import { directionalBlurBlockType } from "../../../blockTypes.js";
|
|
12
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
13
|
-
|
|
14
|
-
const shaderProgram: ShaderProgram = {
|
|
15
|
-
fragment: {
|
|
16
|
-
const: `
|
|
17
|
-
const float _epsilon_ = 0.01;
|
|
18
|
-
`,
|
|
19
|
-
uniform: `
|
|
20
|
-
uniform vec2 _texelStep_;
|
|
21
|
-
uniform sampler2D _input_;
|
|
22
|
-
`,
|
|
23
|
-
|
|
24
|
-
uniformSingle: `
|
|
25
|
-
uniform float[7] _weights_;
|
|
26
|
-
`,
|
|
27
|
-
|
|
28
|
-
mainFunctionName: "_directionalBlur_",
|
|
29
|
-
|
|
30
|
-
mainInputTexture: "_input_",
|
|
31
|
-
|
|
32
|
-
functions: [
|
|
33
|
-
{
|
|
34
|
-
name: "_directionalBlur_",
|
|
35
|
-
code: `
|
|
36
|
-
vec4 _directionalBlur_(vec2 vUV) {
|
|
37
|
-
vec2 start = vUV - 3.0 * _texelStep_;
|
|
38
|
-
|
|
39
|
-
vec4 finalWeightedColor = vec4(0., 0., 0., 0.);
|
|
40
|
-
|
|
41
|
-
for (int i = 0; i < 7; i++)
|
|
42
|
-
{
|
|
43
|
-
vec2 fetchUV = start + _texelStep_ * float(i);
|
|
44
|
-
fetchUV = clamp(fetchUV, 0., 1.);
|
|
45
|
-
vec4 colorSample = texture2D(_input_, fetchUV);
|
|
46
|
-
|
|
47
|
-
// Ignore samples from mostly transparent pixels
|
|
48
|
-
if (colorSample.a < _epsilon_) continue;
|
|
49
|
-
|
|
50
|
-
finalWeightedColor += colorSample * _weights_[i];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return finalWeightedColor;
|
|
54
|
-
}
|
|
55
|
-
`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const wideWeights = Float32Array.from([0.05, 0.1, 0.2, 0.3, 0.2, 0.1, 0.05]);
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The shader bindings for the DirectionalBlur block.
|
|
65
|
-
*/
|
|
66
|
-
export class DirectionalBlurShaderBinding extends ShaderBinding {
|
|
67
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
68
|
-
private readonly _blurHorizontalWidth: number;
|
|
69
|
-
private readonly _blurVerticalWidth: number;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Creates a new shader binding instance for the DirectionalBlur block.
|
|
73
|
-
* @param inputTexture - The input texture
|
|
74
|
-
* @param blurHorizontalWidth - The horizontal blur width
|
|
75
|
-
* @param blurVerticalWidth - The vertical blur width
|
|
76
|
-
*/
|
|
77
|
-
constructor(
|
|
78
|
-
inputTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
79
|
-
blurHorizontalWidth: number,
|
|
80
|
-
blurVerticalWidth: number
|
|
81
|
-
) {
|
|
82
|
-
super();
|
|
83
|
-
this._inputTexture = inputTexture;
|
|
84
|
-
this._blurHorizontalWidth = blurHorizontalWidth;
|
|
85
|
-
this._blurVerticalWidth = blurVerticalWidth;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Binds all the required data to the shader when rendering.
|
|
90
|
-
* @param effect - defines the effect to bind the data to
|
|
91
|
-
*/
|
|
92
|
-
public override bind(effect: Effect): void {
|
|
93
|
-
// Global pass Setup
|
|
94
|
-
effect.setFloatArray(this.getRemappedName("weights"), wideWeights);
|
|
95
|
-
|
|
96
|
-
// V blur
|
|
97
|
-
effect.setTexture(this.getRemappedName("input"), this._inputTexture.value);
|
|
98
|
-
|
|
99
|
-
// Texel size
|
|
100
|
-
if (this._inputTexture.value) {
|
|
101
|
-
const inputSize = this._inputTexture.value.getSize();
|
|
102
|
-
const texelWidth = this._blurHorizontalWidth / inputSize.width;
|
|
103
|
-
const texelHeight = this._blurVerticalWidth / inputSize.height;
|
|
104
|
-
effect.setFloat2(this.getRemappedName("texelStep"), texelWidth, texelHeight);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* A block performing a directional "gaussian" blur.
|
|
111
|
-
*
|
|
112
|
-
* It is aggregated as part of the @see BlurBlock.
|
|
113
|
-
*/
|
|
114
|
-
export class DirectionalBlurBlock extends ShaderBlock {
|
|
115
|
-
/**
|
|
116
|
-
* The class name of the block.
|
|
117
|
-
*/
|
|
118
|
-
public static override ClassName = directionalBlurBlockType;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The namespace of the block.
|
|
122
|
-
*/
|
|
123
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* The input texture connection point.
|
|
127
|
-
*/
|
|
128
|
-
public readonly input = this._registerInput("input", ConnectionPointType.Texture);
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Defines how smaller we should make the target compared to the screen size.
|
|
132
|
-
*/
|
|
133
|
-
@editableInPropertyPage("Texture Ratio", PropertyTypeForEdition.Float, "PROPERTIES", {
|
|
134
|
-
min: 0,
|
|
135
|
-
max: 1,
|
|
136
|
-
notifiers: { rebuild: true },
|
|
137
|
-
})
|
|
138
|
-
public blurTextureRatio = 0.5;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Defines the horizontal strength of the blur.
|
|
142
|
-
*/
|
|
143
|
-
@editableInPropertyPage("Horizontal strength", PropertyTypeForEdition.Float, "PROPERTIES", {
|
|
144
|
-
min: 0,
|
|
145
|
-
max: 1,
|
|
146
|
-
notifiers: { rebuild: true },
|
|
147
|
-
})
|
|
148
|
-
public blurHorizontalWidth = 0;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Defines the vertical strength of the blur.
|
|
152
|
-
*/
|
|
153
|
-
@editableInPropertyPage("Vertical strength", PropertyTypeForEdition.Float, "PROPERTIES", {
|
|
154
|
-
min: 0,
|
|
155
|
-
max: 1,
|
|
156
|
-
notifiers: { rebuild: true },
|
|
157
|
-
})
|
|
158
|
-
public blurVerticalWidth = 1;
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
162
|
-
*/
|
|
163
|
-
public static override ShaderCode = shaderProgram;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Instantiates a new Block.
|
|
167
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
168
|
-
* @param name - The friendly name of the block
|
|
169
|
-
*/
|
|
170
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
171
|
-
super(smartFilter, name, true);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Prepares the block for runtime.
|
|
176
|
-
* This is called by the smart filter just before creating the smart filter runtime.
|
|
177
|
-
*/
|
|
178
|
-
public override prepareForRuntime(): void {
|
|
179
|
-
super.prepareForRuntime();
|
|
180
|
-
|
|
181
|
-
this.outputTextureOptions.ratio = this.blurTextureRatio;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
186
|
-
* @returns The class instance that binds the data to the effect
|
|
187
|
-
*/
|
|
188
|
-
public getShaderBinding(): ShaderBinding {
|
|
189
|
-
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
190
|
-
|
|
191
|
-
return new DirectionalBlurShaderBinding(input, this.blurHorizontalWidth, this.blurVerticalWidth);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
@@ -1,120 +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 { exposureBlockType } from "../../../blockTypes.js";
|
|
11
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
12
|
-
|
|
13
|
-
const shaderProgram: ShaderProgram = {
|
|
14
|
-
fragment: {
|
|
15
|
-
uniform: `
|
|
16
|
-
uniform sampler2D _input_;
|
|
17
|
-
uniform float _amount_;
|
|
18
|
-
`,
|
|
19
|
-
|
|
20
|
-
mainFunctionName: "_exposure_",
|
|
21
|
-
|
|
22
|
-
mainInputTexture: "_input_",
|
|
23
|
-
|
|
24
|
-
functions: [
|
|
25
|
-
{
|
|
26
|
-
name: "_exposure_",
|
|
27
|
-
code: `
|
|
28
|
-
vec4 _exposure_(vec2 vUV) {
|
|
29
|
-
vec4 color = texture2D(_input_, vUV);
|
|
30
|
-
return vec4(color.rgb * _amount_, color.a);
|
|
31
|
-
}
|
|
32
|
-
`,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The shader bindings for the ExposureBlock.
|
|
40
|
-
*/
|
|
41
|
-
export class ExposureBinding extends DisableableShaderBinding {
|
|
42
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
43
|
-
private readonly _amount: RuntimeData<ConnectionPointType.Float>;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Creates a new shader binding instance for the exposure block.
|
|
47
|
-
* @param parentBlock - The parent block
|
|
48
|
-
* @param inputTexture - The input texture
|
|
49
|
-
* @param amount - The exposure adjustment amount (1.0 means no adjustment)
|
|
50
|
-
*/
|
|
51
|
-
constructor(
|
|
52
|
-
parentBlock: IDisableableBlock,
|
|
53
|
-
inputTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
54
|
-
amount: RuntimeData<ConnectionPointType.Float>
|
|
55
|
-
) {
|
|
56
|
-
super(parentBlock);
|
|
57
|
-
this._inputTexture = inputTexture;
|
|
58
|
-
this._amount = amount;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Binds all the required data to the shader when rendering.
|
|
63
|
-
* @param effect - defines the effect to bind the data to
|
|
64
|
-
*/
|
|
65
|
-
public override bind(effect: Effect): void {
|
|
66
|
-
super.bind(effect);
|
|
67
|
-
effect.setTexture(this.getRemappedName("input"), this._inputTexture.value);
|
|
68
|
-
effect.setFloat(this.getRemappedName("amount"), this._amount.value);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Applies an exposure adjustment to the input texture.
|
|
74
|
-
*/
|
|
75
|
-
export class ExposureBlock extends DisableableShaderBlock {
|
|
76
|
-
/**
|
|
77
|
-
* The class name of the block.
|
|
78
|
-
*/
|
|
79
|
-
public static override ClassName = exposureBlockType;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The namespace of the block.
|
|
83
|
-
*/
|
|
84
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The input texture connection point.
|
|
88
|
-
*/
|
|
89
|
-
public readonly input = this._registerInput("input", ConnectionPointType.Texture);
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The amount of exposure adjustment to apply (1.0 is no adjustment).
|
|
93
|
-
*/
|
|
94
|
-
public readonly amount = this._registerInput("amount", ConnectionPointType.Float);
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
98
|
-
*/
|
|
99
|
-
public static override ShaderCode = shaderProgram;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Instantiates a new Block.
|
|
103
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
104
|
-
* @param name - The friendly name of the block
|
|
105
|
-
*/
|
|
106
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
107
|
-
super(smartFilter, name);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
112
|
-
* @returns The class instance that binds the data to the effect
|
|
113
|
-
*/
|
|
114
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
115
|
-
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
116
|
-
const amount = this._confirmRuntimeDataSupplied(this.amount);
|
|
117
|
-
|
|
118
|
-
return new ExposureBinding(this, input, amount);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,152 +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
|
-
import { createStrongRef } from "../../../../runtime/strongRef.js";
|
|
10
|
-
|
|
11
|
-
import { greenScreenBlockType } from "../../../blockTypes.js";
|
|
12
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
13
|
-
|
|
14
|
-
const shaderProgram: ShaderProgram = {
|
|
15
|
-
fragment: {
|
|
16
|
-
uniform: `
|
|
17
|
-
uniform sampler2D _input_;
|
|
18
|
-
uniform sampler2D _background_;
|
|
19
|
-
uniform vec3 _reference_;
|
|
20
|
-
uniform float _distance_;
|
|
21
|
-
`,
|
|
22
|
-
|
|
23
|
-
mainFunctionName: "_greenScreen_",
|
|
24
|
-
|
|
25
|
-
mainInputTexture: "_input_",
|
|
26
|
-
|
|
27
|
-
functions: [
|
|
28
|
-
{
|
|
29
|
-
name: "_greenScreen_",
|
|
30
|
-
code: `
|
|
31
|
-
vec4 _greenScreen_(vec2 vUV)
|
|
32
|
-
{
|
|
33
|
-
vec4 color = texture2D(_input_, vUV);
|
|
34
|
-
vec4 background = texture2D(_background_, vUV);
|
|
35
|
-
|
|
36
|
-
if (length(color.rgb - _reference_) < _distance_) {
|
|
37
|
-
return background;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return color;
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The shader bindings for the Green block.
|
|
50
|
-
*/
|
|
51
|
-
export class GreenShaderBinding extends DisableableShaderBinding {
|
|
52
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
53
|
-
private readonly _backgroundTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
54
|
-
private readonly _reference: RuntimeData<ConnectionPointType.Color3>;
|
|
55
|
-
private readonly _distance: RuntimeData<ConnectionPointType.Float>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Creates a new shader binding instance for the Green block.
|
|
59
|
-
* @param parentBlock - The parent block
|
|
60
|
-
* @param inputTexture - the input texture
|
|
61
|
-
* @param backgroundTexture - the background texture
|
|
62
|
-
* @param reference - the reference color
|
|
63
|
-
* @param distance - the distance from the reference color
|
|
64
|
-
*/
|
|
65
|
-
constructor(
|
|
66
|
-
parentBlock: IDisableableBlock,
|
|
67
|
-
inputTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
68
|
-
backgroundTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
69
|
-
reference: RuntimeData<ConnectionPointType.Color3>,
|
|
70
|
-
distance: RuntimeData<ConnectionPointType.Float>
|
|
71
|
-
) {
|
|
72
|
-
super(parentBlock);
|
|
73
|
-
this._inputTexture = inputTexture;
|
|
74
|
-
this._backgroundTexture = backgroundTexture;
|
|
75
|
-
this._reference = reference;
|
|
76
|
-
this._distance = distance;
|
|
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
|
-
*/
|
|
83
|
-
public override bind(effect: Effect): void {
|
|
84
|
-
super.bind(effect);
|
|
85
|
-
effect.setTexture(this.getRemappedName("input"), this._inputTexture.value);
|
|
86
|
-
effect.setTexture(this.getRemappedName("background"), this._backgroundTexture.value);
|
|
87
|
-
effect.setColor3(this.getRemappedName("reference"), this._reference.value);
|
|
88
|
-
effect.setFloat(this.getRemappedName("distance"), this._distance.value);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* A simple block to insert a background in place of a green screen.
|
|
94
|
-
*/
|
|
95
|
-
export class GreenScreenBlock extends DisableableShaderBlock {
|
|
96
|
-
/**
|
|
97
|
-
* The class name of the block.
|
|
98
|
-
*/
|
|
99
|
-
public static override ClassName = greenScreenBlockType;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The namespace of the block.
|
|
103
|
-
*/
|
|
104
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The input texture connection point.
|
|
108
|
-
*/
|
|
109
|
-
public readonly input = this._registerInput("input", ConnectionPointType.Texture);
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The background texture connection point.
|
|
113
|
-
*/
|
|
114
|
-
public readonly background = this._registerInput("background", ConnectionPointType.Texture);
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The reference color of the green screen.
|
|
118
|
-
*/
|
|
119
|
-
public readonly reference = this._registerInput("reference", ConnectionPointType.Color3);
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* The "distance" from the color the reference is allowed to have for replacement.
|
|
123
|
-
*/
|
|
124
|
-
public readonly distance = this._registerOptionalInput("distance", ConnectionPointType.Float, createStrongRef(0.1));
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
128
|
-
*/
|
|
129
|
-
public static override ShaderCode = shaderProgram;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Instantiates a new Block.
|
|
133
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
134
|
-
* @param name - The friendly name of the block
|
|
135
|
-
*/
|
|
136
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
137
|
-
super(smartFilter, name);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
142
|
-
* @returns The class instance that binds the data to the effect
|
|
143
|
-
*/
|
|
144
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
145
|
-
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
146
|
-
const background = this._confirmRuntimeDataSupplied(this.background);
|
|
147
|
-
const reference = this._confirmRuntimeDataSupplied(this.reference);
|
|
148
|
-
const distance = this.distance.runtimeData;
|
|
149
|
-
|
|
150
|
-
return new GreenShaderBinding(this, input, background, reference, distance);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from "./blackAndWhiteBlock.js";
|
|
2
|
-
export * from "./blurBlock.js";
|
|
3
|
-
export * from "./compositionBlock.js";
|
|
4
|
-
export * from "./contrastBlock.js";
|
|
5
|
-
export * from "./desaturateBlock.js";
|
|
6
|
-
export * from "./directionalBlurBlock.js";
|
|
7
|
-
export * from "./exposureBlock.js";
|
|
8
|
-
export * from "./greenScreenBlock.js";
|
|
9
|
-
export * from "./kaleidoscopeBlock.js";
|
|
10
|
-
export * from "./maskBlock.js";
|
|
11
|
-
export * from "./pixelateBlock.js";
|
|
12
|
-
export * from "./posterizeBlock.js";
|
|
13
|
-
export * from "./spritesheetBlock.js";
|
|
14
|
-
export * from "./tintBlock.js";
|