@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,119 +0,0 @@
|
|
|
1
|
-
import { AggregateBlock } from "../../../../blockFoundation/aggregateBlock.js";
|
|
2
|
-
import type { ConnectionPoint } from "../../../../connection/connectionPoint.js";
|
|
3
|
-
import type { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
4
|
-
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../editorUtils/editableInPropertyPage.js";
|
|
5
|
-
import { SmartFilter } from "../../../../smartFilter.js";
|
|
6
|
-
import { DirectionalBlurBlock } from "./directionalBlurBlock.js";
|
|
7
|
-
import { blurBlockType } from "../../../blockTypes.js";
|
|
8
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
9
|
-
|
|
10
|
-
const defaultBlurTextureRatioPerPass = 0.5;
|
|
11
|
-
const defaultBlurSize = 2;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A block performing a blur on the input texture.
|
|
15
|
-
*
|
|
16
|
-
* It performs the blur in 4 consecutive passes, 2 verticals and 2 horizontals downsizing the texture as we go.
|
|
17
|
-
*/
|
|
18
|
-
export class BlurBlock extends AggregateBlock {
|
|
19
|
-
/**
|
|
20
|
-
* The class name of the block.
|
|
21
|
-
*/
|
|
22
|
-
public static override ClassName = blurBlockType;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The namespace of the block.
|
|
26
|
-
*/
|
|
27
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The input texture connection point.
|
|
31
|
-
*/
|
|
32
|
-
public readonly input: ConnectionPoint<ConnectionPointType.Texture>;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The output blurred texture connection point.
|
|
36
|
-
*/
|
|
37
|
-
public readonly output: ConnectionPoint<ConnectionPointType.Texture>;
|
|
38
|
-
|
|
39
|
-
private _blurTextureRatioPerPass = defaultBlurTextureRatioPerPass;
|
|
40
|
-
private _blurSize = defaultBlurSize;
|
|
41
|
-
|
|
42
|
-
private readonly _intermediateBlurV: DirectionalBlurBlock;
|
|
43
|
-
private readonly _intermediateBlurH: DirectionalBlurBlock;
|
|
44
|
-
private readonly _finalBlurV: DirectionalBlurBlock;
|
|
45
|
-
private readonly _finalBlurH: DirectionalBlurBlock;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gets how much smaller we should make the texture between the 2 consecutive bi lateral passes.
|
|
49
|
-
*/
|
|
50
|
-
public get blurTextureRatioPerPass(): number {
|
|
51
|
-
return this._blurTextureRatioPerPass;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Sets how much smaller we should make the texture between the 2 consecutive bi lateral passes.
|
|
56
|
-
*/
|
|
57
|
-
@editableInPropertyPage("Pass Texture Ratio", PropertyTypeForEdition.Float, "PROPERTIES", {
|
|
58
|
-
min: 0,
|
|
59
|
-
max: 1,
|
|
60
|
-
notifiers: { rebuild: true },
|
|
61
|
-
})
|
|
62
|
-
public set blurTextureRatioPerPass(value: number) {
|
|
63
|
-
this._blurTextureRatioPerPass = value;
|
|
64
|
-
this._intermediateBlurV.blurTextureRatio = value;
|
|
65
|
-
this._intermediateBlurH.blurTextureRatio = value;
|
|
66
|
-
this._finalBlurV.blurTextureRatio = value * value;
|
|
67
|
-
this._finalBlurH.blurTextureRatio = value * value;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Gets how far the kernel might fetch the data from.
|
|
72
|
-
*/
|
|
73
|
-
public get blurSize(): number {
|
|
74
|
-
return this._blurSize;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Sets how far the kernel might fetch the data from.
|
|
79
|
-
*/
|
|
80
|
-
@editableInPropertyPage("Size", PropertyTypeForEdition.Float, "PROPERTIES", {
|
|
81
|
-
notifiers: { rebuild: true },
|
|
82
|
-
})
|
|
83
|
-
public set blurSize(value: number) {
|
|
84
|
-
this._blurSize = value;
|
|
85
|
-
this._intermediateBlurV.blurHorizontalWidth = value;
|
|
86
|
-
this._intermediateBlurH.blurVerticalWidth = value;
|
|
87
|
-
this._finalBlurV.blurHorizontalWidth = value;
|
|
88
|
-
this._finalBlurH.blurVerticalWidth = value;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Instantiates a new Block.
|
|
93
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
94
|
-
* @param name - The friendly name of the block
|
|
95
|
-
*/
|
|
96
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
97
|
-
super(smartFilter, name);
|
|
98
|
-
|
|
99
|
-
const internalFilter = new SmartFilter(name + "_BlurBlock_Aggregated");
|
|
100
|
-
this._intermediateBlurV = new DirectionalBlurBlock(internalFilter, name + "IV");
|
|
101
|
-
this._intermediateBlurH = new DirectionalBlurBlock(internalFilter, name + "IH");
|
|
102
|
-
this._finalBlurV = new DirectionalBlurBlock(internalFilter, name + "V");
|
|
103
|
-
this._finalBlurH = new DirectionalBlurBlock(internalFilter, name + "H");
|
|
104
|
-
|
|
105
|
-
this._intermediateBlurV.output.connectTo(this._intermediateBlurH.input);
|
|
106
|
-
this._intermediateBlurH.output.connectTo(this._finalBlurV.input);
|
|
107
|
-
this._finalBlurV.output.connectTo(this._finalBlurH.input);
|
|
108
|
-
|
|
109
|
-
this.input = this._registerSubfilterInput("input", [this._intermediateBlurV.input]);
|
|
110
|
-
this.output = this._registerSubfilterOutput("output", this._finalBlurH.output);
|
|
111
|
-
|
|
112
|
-
this.blurSize = defaultBlurSize;
|
|
113
|
-
this.blurTextureRatioPerPass = defaultBlurTextureRatioPerPass;
|
|
114
|
-
this._intermediateBlurV.blurVerticalWidth = 0;
|
|
115
|
-
this._intermediateBlurH.blurHorizontalWidth = 0;
|
|
116
|
-
this._finalBlurV.blurVerticalWidth = 0;
|
|
117
|
-
this._finalBlurH.blurHorizontalWidth = 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ISerializedBlockV1 } from "../../../../serialization/index.js";
|
|
2
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
3
|
-
import { CompositionBlock } from "./compositionBlock.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The definition of the extra data serialized for composition blocks.
|
|
7
|
-
*/
|
|
8
|
-
export interface ISerializedCompositionBlockV1 extends ISerializedBlockV1 {
|
|
9
|
-
/**
|
|
10
|
-
* The extra data of the block.
|
|
11
|
-
*/
|
|
12
|
-
data: {
|
|
13
|
-
/**
|
|
14
|
-
* The alpha mode of the composition.
|
|
15
|
-
*/
|
|
16
|
-
alphaMode: number;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* V1 Composition Deserializer.
|
|
22
|
-
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
23
|
-
* @param serializedBlock - The serialized block data
|
|
24
|
-
* @returns A deserialized CompositionBlock
|
|
25
|
-
*/
|
|
26
|
-
export function compositionDeserializer(smartFilter: SmartFilter, serializedBlock: ISerializedCompositionBlockV1) {
|
|
27
|
-
const block = new CompositionBlock(smartFilter, serializedBlock.name);
|
|
28
|
-
|
|
29
|
-
// If data is missing, use the default value set by the block
|
|
30
|
-
block.alphaMode = serializedBlock.data.alphaMode ?? block.alphaMode;
|
|
31
|
-
return block;
|
|
32
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { BaseBlock } from "../../../../blockFoundation";
|
|
2
|
-
import type { IBlockSerializerV1 } from "../../../../serialization";
|
|
3
|
-
import type { CompositionBlock } from "./compositionBlock";
|
|
4
|
-
import { compositionBlockType } from "../../../blockTypes.js";
|
|
5
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The V1 serializer for a Composition Block
|
|
9
|
-
*/
|
|
10
|
-
export const compositionBlockSerializer: IBlockSerializerV1 = {
|
|
11
|
-
blockType: compositionBlockType,
|
|
12
|
-
serialize: (block: BaseBlock) => {
|
|
13
|
-
if (block.getClassName() !== compositionBlockType) {
|
|
14
|
-
throw new Error("Was asked to serialize an unrecognized block type");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const compositionBlock = block as CompositionBlock;
|
|
18
|
-
return {
|
|
19
|
-
name: block.name,
|
|
20
|
-
uniqueId: block.uniqueId,
|
|
21
|
-
blockType: compositionBlockType,
|
|
22
|
-
namespace: babylonDemoEffectsNamespace,
|
|
23
|
-
comments: block.comments,
|
|
24
|
-
data: {
|
|
25
|
-
alphaMode: compositionBlock.alphaMode,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
};
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
-
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../editorUtils/editableInPropertyPage.js";
|
|
3
|
-
import { type IDisableableBlock, DisableableShaderBlock } from "../../../../blockFoundation/disableableShaderBlock.js";
|
|
4
|
-
import type { RuntimeData } from "../../../../connection/connectionPoint.js";
|
|
5
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
6
|
-
import type { ShaderProgram } from "../../../../utils/shaderCodeUtils.js";
|
|
7
|
-
import { DisableableShaderBinding } from "../../../../runtime/shaderRuntime.js";
|
|
8
|
-
import { createStrongRef } from "../../../../runtime/strongRef.js";
|
|
9
|
-
import { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
10
|
-
|
|
11
|
-
import { compositionBlockType } from "../../../blockTypes.js";
|
|
12
|
-
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
13
|
-
|
|
14
|
-
/** Defines that alpha blending is disabled */
|
|
15
|
-
export const ALPHA_DISABLE = 0;
|
|
16
|
-
/** Defines that alpha blending is SRC ALPHA * SRC + DEST */
|
|
17
|
-
export const ALPHA_ADD = 1;
|
|
18
|
-
/** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
|
|
19
|
-
export const ALPHA_COMBINE = 2;
|
|
20
|
-
/** Defines that alpha blending is DEST - SRC * DEST */
|
|
21
|
-
export const ALPHA_SUBTRACT = 3;
|
|
22
|
-
/** Defines that alpha blending is SRC * DEST */
|
|
23
|
-
export const ALPHA_MULTIPLY = 4;
|
|
24
|
-
|
|
25
|
-
const shaderProgram: ShaderProgram = {
|
|
26
|
-
fragment: {
|
|
27
|
-
uniform: `
|
|
28
|
-
uniform sampler2D _background_;
|
|
29
|
-
uniform sampler2D _foreground_;
|
|
30
|
-
|
|
31
|
-
uniform vec2 _scaleUV_;
|
|
32
|
-
uniform vec2 _translateUV_;
|
|
33
|
-
uniform int _alphaMode_;
|
|
34
|
-
uniform float _foregroundAlphaScale_;
|
|
35
|
-
`,
|
|
36
|
-
|
|
37
|
-
mainFunctionName: "_composition_",
|
|
38
|
-
|
|
39
|
-
mainInputTexture: "_background_",
|
|
40
|
-
|
|
41
|
-
functions: [
|
|
42
|
-
{
|
|
43
|
-
name: "_composition_",
|
|
44
|
-
code: `
|
|
45
|
-
vec4 _composition_(vec2 vUV) {
|
|
46
|
-
vec4 background = texture2D(_background_, vUV);
|
|
47
|
-
|
|
48
|
-
vec2 transformedUV = vUV * (1.0 / _scaleUV_) + _translateUV_;
|
|
49
|
-
if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
|
|
50
|
-
return background;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
vec4 foreground = texture2D(_foreground_, transformedUV);
|
|
54
|
-
foreground.a *= _foregroundAlphaScale_;
|
|
55
|
-
|
|
56
|
-
// SRC is foreground, DEST is background
|
|
57
|
-
if (_alphaMode_ == 0) {
|
|
58
|
-
return foreground;
|
|
59
|
-
}
|
|
60
|
-
else if (_alphaMode_ == 1) {
|
|
61
|
-
return foreground.a * foreground + background;
|
|
62
|
-
}
|
|
63
|
-
else if (_alphaMode_ == 2) {
|
|
64
|
-
return mix(background, foreground, foreground.a);
|
|
65
|
-
}
|
|
66
|
-
else if (_alphaMode_ == 3) {
|
|
67
|
-
return background - foreground * background;
|
|
68
|
-
}
|
|
69
|
-
else if (_alphaMode_ == 4) {
|
|
70
|
-
return foreground * background;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return background;
|
|
74
|
-
}
|
|
75
|
-
`,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The shader bindings for the Composition block.
|
|
83
|
-
*/
|
|
84
|
-
export class CompositionShaderBinding extends DisableableShaderBinding {
|
|
85
|
-
private readonly _backgroundTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
86
|
-
private readonly _foregroundTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
87
|
-
private readonly _foregroundTop: RuntimeData<ConnectionPointType.Float>;
|
|
88
|
-
private readonly _foregroundLeft: RuntimeData<ConnectionPointType.Float>;
|
|
89
|
-
private readonly _foregroundWidth: RuntimeData<ConnectionPointType.Float>;
|
|
90
|
-
private readonly _foregroundHeight: RuntimeData<ConnectionPointType.Float>;
|
|
91
|
-
private readonly _foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>;
|
|
92
|
-
private readonly _alphaMode: number;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Creates a new shader binding instance for the Composition block.
|
|
96
|
-
* @param parentBlock - The parent block
|
|
97
|
-
* @param backgroundTexture - the background texture
|
|
98
|
-
* @param foregroundTexture - the foreground texture
|
|
99
|
-
* @param foregroundTop - the top position of the foreground texture
|
|
100
|
-
* @param foregroundLeft - the left position of the foreground texture
|
|
101
|
-
* @param foregroundWidth - the width of the foreground texture
|
|
102
|
-
* @param foregroundHeight - the height of the foreground texture
|
|
103
|
-
* @param foregroundAlphaScale - the alpha scale of the foreground texture
|
|
104
|
-
* @param alphaMode - the alpha mode to use
|
|
105
|
-
*/
|
|
106
|
-
constructor(
|
|
107
|
-
parentBlock: IDisableableBlock,
|
|
108
|
-
backgroundTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
109
|
-
foregroundTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
110
|
-
foregroundTop: RuntimeData<ConnectionPointType.Float>,
|
|
111
|
-
foregroundLeft: RuntimeData<ConnectionPointType.Float>,
|
|
112
|
-
foregroundWidth: RuntimeData<ConnectionPointType.Float>,
|
|
113
|
-
foregroundHeight: RuntimeData<ConnectionPointType.Float>,
|
|
114
|
-
foregroundAlphaScale: RuntimeData<ConnectionPointType.Float>,
|
|
115
|
-
alphaMode: number
|
|
116
|
-
) {
|
|
117
|
-
super(parentBlock);
|
|
118
|
-
this._backgroundTexture = backgroundTexture;
|
|
119
|
-
this._foregroundTexture = foregroundTexture;
|
|
120
|
-
this._foregroundTop = foregroundTop;
|
|
121
|
-
this._foregroundLeft = foregroundLeft;
|
|
122
|
-
this._foregroundWidth = foregroundWidth;
|
|
123
|
-
this._foregroundHeight = foregroundHeight;
|
|
124
|
-
this._foregroundAlphaScale = foregroundAlphaScale;
|
|
125
|
-
this._alphaMode = alphaMode;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Binds all the required data to the shader when rendering.
|
|
130
|
-
* @param effect - defines the effect to bind the data to
|
|
131
|
-
* @param width - defines the width of the output
|
|
132
|
-
* @param height - defines the height of the output
|
|
133
|
-
*/
|
|
134
|
-
public override bind(effect: Effect, width: number, height: number): void {
|
|
135
|
-
super.bind(effect, width, height);
|
|
136
|
-
|
|
137
|
-
const background = this._backgroundTexture.value;
|
|
138
|
-
const foreground = this._foregroundTexture.value;
|
|
139
|
-
const foregroundTop = this._foregroundTop.value;
|
|
140
|
-
const foregroundLeft = this._foregroundLeft.value;
|
|
141
|
-
const foregroundWidth = this._foregroundWidth.value;
|
|
142
|
-
const foregroundHeight = this._foregroundHeight.value;
|
|
143
|
-
const foregroundAlphaScale = this._foregroundAlphaScale.value;
|
|
144
|
-
const alphaMode = this._alphaMode;
|
|
145
|
-
|
|
146
|
-
effect.setInt(this.getRemappedName("alphaMode"), alphaMode);
|
|
147
|
-
effect.setTexture(this.getRemappedName("background"), background);
|
|
148
|
-
effect.setTexture(this.getRemappedName("foreground"), foreground);
|
|
149
|
-
|
|
150
|
-
// NOTE: textures may always be undefined if connected to another shader block when the graph is optimized
|
|
151
|
-
|
|
152
|
-
effect.setFloat2(this.getRemappedName("scaleUV"), foregroundWidth, foregroundHeight);
|
|
153
|
-
effect.setFloat2(this.getRemappedName("translateUV"), -1 * foregroundLeft, foregroundTop);
|
|
154
|
-
effect.setFloat(this.getRemappedName("foregroundAlphaScale"), foregroundAlphaScale);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* A simple compositing Block letting the filter "blend" 2 different layers.
|
|
160
|
-
*
|
|
161
|
-
* The alpha mode of the block can be set to one of the following:
|
|
162
|
-
* - ALPHA_DISABLE: alpha blending is disabled
|
|
163
|
-
* - ALPHA_ADD: alpha blending is SRC ALPHA * SRC + DEST
|
|
164
|
-
* - ALPHA_COMBINE: alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST
|
|
165
|
-
* - ALPHA_SUBTRACT: alpha blending is DEST - SRC * DEST
|
|
166
|
-
* - ALPHA_MULTIPLY: alpha blending is SRC * DEST
|
|
167
|
-
*/
|
|
168
|
-
export class CompositionBlock extends DisableableShaderBlock {
|
|
169
|
-
/**
|
|
170
|
-
* The class name of the block.
|
|
171
|
-
*/
|
|
172
|
-
public static override ClassName = compositionBlockType;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* The namespace of the block.
|
|
176
|
-
*/
|
|
177
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* The background texture to composite on to.
|
|
181
|
-
*/
|
|
182
|
-
public readonly background = this._registerInput("background", ConnectionPointType.Texture);
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The foreground texture to composite in.
|
|
186
|
-
*/
|
|
187
|
-
public readonly foreground = this._registerOptionalInput(
|
|
188
|
-
"foreground",
|
|
189
|
-
ConnectionPointType.Texture,
|
|
190
|
-
createStrongRef(null)
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Defines where the top of the texture to composite in should be displayed. (between 0 and 1).
|
|
195
|
-
*/
|
|
196
|
-
public readonly foregroundTop = this._registerOptionalInput(
|
|
197
|
-
"foregroundTop",
|
|
198
|
-
ConnectionPointType.Float,
|
|
199
|
-
createStrongRef(0.0)
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Defines where the left of the texture to composite in should be displayed. (between 0 and 1).
|
|
204
|
-
*/
|
|
205
|
-
public readonly foregroundLeft = this._registerOptionalInput(
|
|
206
|
-
"foregroundLeft",
|
|
207
|
-
ConnectionPointType.Float,
|
|
208
|
-
createStrongRef(0.0)
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Defines the width of the texture in the composition.
|
|
213
|
-
*/
|
|
214
|
-
public readonly foregroundWidth = this._registerOptionalInput(
|
|
215
|
-
"foregroundWidth",
|
|
216
|
-
ConnectionPointType.Float,
|
|
217
|
-
createStrongRef(1.0)
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Defines the height of the texture in the composition.
|
|
222
|
-
*/
|
|
223
|
-
public readonly foregroundHeight = this._registerOptionalInput(
|
|
224
|
-
"foregroundHeight",
|
|
225
|
-
ConnectionPointType.Float,
|
|
226
|
-
createStrongRef(1.0)
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Defines a multiplier applied to the foreground's alpha channel.
|
|
231
|
-
*/
|
|
232
|
-
public readonly foregroundAlphaScale = this._registerOptionalInput(
|
|
233
|
-
"foregroundAlphaScale",
|
|
234
|
-
ConnectionPointType.Float,
|
|
235
|
-
createStrongRef(1.0)
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Defines blend mode of the composition.
|
|
240
|
-
*/
|
|
241
|
-
@editableInPropertyPage("Alpha Mode", PropertyTypeForEdition.List, "PROPERTIES", {
|
|
242
|
-
notifiers: { rebuild: true },
|
|
243
|
-
options: [
|
|
244
|
-
{ label: "Disable", value: ALPHA_DISABLE },
|
|
245
|
-
{ label: "Add", value: ALPHA_ADD },
|
|
246
|
-
{ label: "Combine", value: ALPHA_COMBINE },
|
|
247
|
-
{ label: "Subtract", value: ALPHA_SUBTRACT },
|
|
248
|
-
{ label: "Multiply", value: ALPHA_MULTIPLY },
|
|
249
|
-
],
|
|
250
|
-
})
|
|
251
|
-
public alphaMode: number = ALPHA_COMBINE;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
255
|
-
*/
|
|
256
|
-
public static override ShaderCode = shaderProgram;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Instantiates a new Block.
|
|
260
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
261
|
-
* @param name - The friendly name of the block
|
|
262
|
-
*/
|
|
263
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
264
|
-
super(smartFilter, name, true);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
269
|
-
* @returns The class instance that binds the data to the effect
|
|
270
|
-
*/
|
|
271
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
272
|
-
const background = this._confirmRuntimeDataSupplied(this.background);
|
|
273
|
-
const foreground = this._confirmRuntimeDataSupplied(this.foreground);
|
|
274
|
-
const foregroundWidth = this.foregroundWidth.runtimeData;
|
|
275
|
-
const foregroundLeft = this.foregroundLeft.runtimeData;
|
|
276
|
-
const foregroundHeight = this.foregroundHeight.runtimeData;
|
|
277
|
-
const foregroundTop = this.foregroundTop.runtimeData;
|
|
278
|
-
const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
|
|
279
|
-
const alphaMode = this.alphaMode;
|
|
280
|
-
|
|
281
|
-
return new CompositionShaderBinding(
|
|
282
|
-
this,
|
|
283
|
-
background,
|
|
284
|
-
foreground,
|
|
285
|
-
foregroundTop,
|
|
286
|
-
foregroundLeft,
|
|
287
|
-
foregroundWidth,
|
|
288
|
-
foregroundHeight,
|
|
289
|
-
foregroundAlphaScale,
|
|
290
|
-
alphaMode
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
-
import { DisableableShaderBinding } from "../../../../runtime/shaderRuntime.js";
|
|
3
|
-
import { DisableableShaderBlock, type IDisableableBlock } from "../../../../blockFoundation/disableableShaderBlock.js";
|
|
4
|
-
import type { RuntimeData } from "../../../../connection/connectionPoint.js";
|
|
5
|
-
import { ConnectionPointType } from "../../../../connection/connectionPointType.js";
|
|
6
|
-
import type { SmartFilter } from "../../../../smartFilter.js";
|
|
7
|
-
import { createStrongRef } from "../../../../runtime/strongRef.js";
|
|
8
|
-
import type { ShaderProgram } from "../../../../utils/shaderCodeUtils.js";
|
|
9
|
-
|
|
10
|
-
import { contrastBlockType } 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 _intensity_;
|
|
18
|
-
`,
|
|
19
|
-
|
|
20
|
-
const: `
|
|
21
|
-
const float contrastIntensity = 0.44;
|
|
22
|
-
`,
|
|
23
|
-
|
|
24
|
-
mainFunctionName: "_contrast_",
|
|
25
|
-
|
|
26
|
-
mainInputTexture: "_input_",
|
|
27
|
-
|
|
28
|
-
functions: [
|
|
29
|
-
{
|
|
30
|
-
name: "_contrast_",
|
|
31
|
-
code: `
|
|
32
|
-
vec4 _contrast_(vec2 vUV) {
|
|
33
|
-
vec4 color = texture2D(_input_, vUV);
|
|
34
|
-
|
|
35
|
-
float contrastLMin = mix(-2., 0., _intensity_ * 2.0);
|
|
36
|
-
float contrastLMax = mix(3., 1., _intensity_ * 2.0);
|
|
37
|
-
|
|
38
|
-
vec3 contrastMin = _remap_(color.rgb, contrastLMin, contrastLMax, 0., 1.);
|
|
39
|
-
|
|
40
|
-
float intensityMapped = _remap_(_intensity_, 0.5, 1., 0., 1.0);
|
|
41
|
-
float contrastHMin = mix(0., 0.45, intensityMapped);
|
|
42
|
-
float contrastHMax = mix(1., 0.5, intensityMapped);
|
|
43
|
-
|
|
44
|
-
vec3 contrastMax = _remap_(color.rgb, contrastHMin, contrastHMax, 0., 1.);
|
|
45
|
-
|
|
46
|
-
return vec4(mix(contrastMin, contrastMax, step(_intensity_, 0.5)), color.a);
|
|
47
|
-
}
|
|
48
|
-
`,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "_remap_",
|
|
52
|
-
code: `
|
|
53
|
-
float _remap_(float i, float smin, float smax, float dmin, float dmax) {
|
|
54
|
-
return dmin + (i - smin) * (dmax - dmin) / (smax - smin);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
vec3 _remap_(vec3 i, float smin, float smax, float dmin, float dmax) {
|
|
58
|
-
return dmin + (i - smin) * (dmax - dmin) / (smax - smin);
|
|
59
|
-
}
|
|
60
|
-
`,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The shader bindings for the Contrast block.
|
|
68
|
-
*/
|
|
69
|
-
export class ContrastShaderBinding extends DisableableShaderBinding {
|
|
70
|
-
private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
|
|
71
|
-
private readonly _intensity: RuntimeData<ConnectionPointType.Float>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Creates a new shader binding instance for the Contrast block.
|
|
75
|
-
* @param parentBlock - The parent block
|
|
76
|
-
* @param inputTexture - The input texture
|
|
77
|
-
* @param intensity - The intensity of the effect
|
|
78
|
-
*/
|
|
79
|
-
constructor(
|
|
80
|
-
parentBlock: IDisableableBlock,
|
|
81
|
-
inputTexture: RuntimeData<ConnectionPointType.Texture>,
|
|
82
|
-
intensity: RuntimeData<ConnectionPointType.Float>
|
|
83
|
-
) {
|
|
84
|
-
super(parentBlock);
|
|
85
|
-
this._inputTexture = inputTexture;
|
|
86
|
-
this._intensity = intensity;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Binds all the required data to the shader when rendering.
|
|
91
|
-
* @param effect - defines the effect to bind the data to
|
|
92
|
-
*/
|
|
93
|
-
public override bind(effect: Effect): void {
|
|
94
|
-
super.bind(effect);
|
|
95
|
-
effect.setTexture(this.getRemappedName("input"), this._inputTexture.value);
|
|
96
|
-
effect.setFloat(this.getRemappedName("intensity"), this._intensity.value);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* A simple block to change the contrast of a texture.
|
|
102
|
-
*/
|
|
103
|
-
export class ContrastBlock extends DisableableShaderBlock {
|
|
104
|
-
/**
|
|
105
|
-
* The class name of the block.
|
|
106
|
-
*/
|
|
107
|
-
public static override ClassName = contrastBlockType;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The namespace of the block.
|
|
111
|
-
*/
|
|
112
|
-
public static override Namespace = babylonDemoEffectsNamespace;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* The input texture connection point.
|
|
116
|
-
*/
|
|
117
|
-
public readonly input = this._registerInput("input", ConnectionPointType.Texture);
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The intensity connection point.
|
|
121
|
-
*/
|
|
122
|
-
public readonly intensity = this._registerOptionalInput(
|
|
123
|
-
"intensity",
|
|
124
|
-
ConnectionPointType.Float,
|
|
125
|
-
createStrongRef(0.5)
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The shader program (vertex and fragment code) to use to render the block
|
|
130
|
-
*/
|
|
131
|
-
public static override ShaderCode = shaderProgram;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Instantiates a new Block.
|
|
135
|
-
* @param smartFilter - The smart filter this block belongs to
|
|
136
|
-
* @param name - The friendly name of the block
|
|
137
|
-
*/
|
|
138
|
-
constructor(smartFilter: SmartFilter, name: string) {
|
|
139
|
-
super(smartFilter, name);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
144
|
-
* @returns The class instance that binds the data to the effect
|
|
145
|
-
*/
|
|
146
|
-
public getShaderBinding(): DisableableShaderBinding {
|
|
147
|
-
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
148
|
-
const intensity = this.intensity.runtimeData;
|
|
149
|
-
|
|
150
|
-
return new ContrastShaderBinding(this, input, intensity);
|
|
151
|
-
}
|
|
152
|
-
}
|