@onerjs/smart-filters-blocks 8.25.2 → 8.25.3
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 +34 -0
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js +100 -0
- package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts +53 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts +28 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js +15 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.js +93 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts +8 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js +28 -0
- package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts +116 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts +24 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js +14 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts +20 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js +71 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.js +163 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts +6 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js +25 -0
- package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts +39 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.js +137 -0
- package/dist/blocks/babylon/demo/effects/contrastBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts +39 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js +114 -0
- package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts +76 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts +32 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js +16 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js +162 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts +6 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js +27 -0
- package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts +38 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.js +106 -0
- package/dist/blocks/babylon/demo/effects/exposureBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts +46 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js +132 -0
- package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/index.d.ts +15 -0
- package/dist/blocks/babylon/demo/effects/index.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/index.js +15 -0
- package/dist/blocks/babylon/demo/effects/index.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts +63 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js +158 -0
- package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts +38 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.js +109 -0
- package/dist/blocks/babylon/demo/effects/maskBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts +44 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js +129 -0
- package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts +39 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js +115 -0
- package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts +77 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts +20 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js +60 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js +98 -0
- package/dist/blocks/babylon/demo/effects/spritesheetBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts +7 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.js +51 -0
- package/dist/blocks/babylon/demo/effects/tintBlock.js.map +1 -0
- package/dist/blocks/babylon/demo/transitions/index.d.ts +2 -0
- package/dist/blocks/babylon/demo/transitions/index.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/transitions/index.js +2 -0
- package/dist/blocks/babylon/demo/transitions/index.js.map +1 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts +42 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js +115 -0
- package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js.map +1 -0
- package/dist/blocks/babylon/demo/utilities/index.d.ts +2 -0
- package/dist/blocks/babylon/demo/utilities/index.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/utilities/index.js +2 -0
- package/dist/blocks/babylon/demo/utilities/index.js.map +1 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts +34 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts.map +1 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js +96 -0
- package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js.map +1 -0
- package/dist/blocks/blockNamespaces.d.ts +5 -0
- package/dist/blocks/blockNamespaces.d.ts.map +1 -0
- package/dist/blocks/blockNamespaces.js +7 -0
- package/dist/blocks/blockNamespaces.js.map +1 -0
- package/dist/blocks/blockTypes.d.ts +22 -0
- package/dist/blocks/blockTypes.d.ts.map +1 -0
- package/dist/blocks/blockTypes.js +24 -0
- package/dist/blocks/blockTypes.js.map +1 -0
- package/dist/blocks/index.d.ts +6 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +7 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/registration/IBlockRegistration.d.ts +38 -0
- package/dist/registration/IBlockRegistration.d.ts.map +1 -0
- package/dist/registration/IBlockRegistration.js +2 -0
- package/dist/registration/IBlockRegistration.js.map +1 -0
- package/dist/registration/blockSerializers.d.ts +13 -0
- package/dist/registration/blockSerializers.d.ts.map +1 -0
- package/dist/registration/blockSerializers.js +33 -0
- package/dist/registration/blockSerializers.js.map +1 -0
- package/dist/registration/builtInBlockRegistrations.d.ts +13 -0
- package/dist/registration/builtInBlockRegistrations.d.ts.map +1 -0
- package/dist/registration/builtInBlockRegistrations.js +273 -0
- package/dist/registration/builtInBlockRegistrations.js.map +1 -0
- package/dist/registration/index.d.ts +4 -0
- package/dist/registration/index.d.ts.map +1 -0
- package/dist/registration/index.js +5 -0
- package/dist/registration/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
// ************************************************************
|
|
3
|
+
// Note: this file is auto-generated, do not modify it directly
|
|
4
|
+
// ************************************************************
|
|
5
|
+
import { ShaderBinding, ConnectionPointType, ShaderBlock, createStrongRef } from "@onerjs/smart-filters";
|
|
6
|
+
/**
|
|
7
|
+
* The shader program for the block.
|
|
8
|
+
*/
|
|
9
|
+
const BlockShaderProgram = {
|
|
10
|
+
vertex: undefined,
|
|
11
|
+
fragment: {
|
|
12
|
+
uniform: `
|
|
13
|
+
uniform sampler2D _input_; // main
|
|
14
|
+
uniform float _intensity_;
|
|
15
|
+
uniform bool _disabled_;
|
|
16
|
+
uniform vec2 _aspect_;`,
|
|
17
|
+
const: ` const float _videoPixelatePower_ = 6.0;
|
|
18
|
+
const float _videoPixelateMin_ = 10.0;
|
|
19
|
+
const float _videoPixelateMax_ = 1920.0;`,
|
|
20
|
+
mainInputTexture: "_input_",
|
|
21
|
+
mainFunctionName: "_pixelate_",
|
|
22
|
+
functions: [
|
|
23
|
+
{
|
|
24
|
+
name: "_pixelate_",
|
|
25
|
+
code: `
|
|
26
|
+
vec4 _pixelate_(vec2 vUV) {
|
|
27
|
+
if (!_disabled_) {
|
|
28
|
+
float pixelateStrength = mix(_videoPixelateMin_, _videoPixelateMax_, pow(1. - _intensity_, _videoPixelatePower_));
|
|
29
|
+
vec2 _pixelate_ = vec2(pixelateStrength * _aspect_.x, pixelateStrength);
|
|
30
|
+
vec2 pixelSize = vec2(1. / _pixelate_);
|
|
31
|
+
vUV = pixelSize * (floor(_pixelate_ * vUV) + 0.5);
|
|
32
|
+
}
|
|
33
|
+
return texture2D(_input_, vUV);
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
params: "vec2 vUV",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
43
|
+
* that the names are always in sync.
|
|
44
|
+
*/
|
|
45
|
+
const Uniforms = {
|
|
46
|
+
input: "input",
|
|
47
|
+
intensity: "intensity",
|
|
48
|
+
disabled: "disabled",
|
|
49
|
+
aspect: "aspect",
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The shader binding for the PixelateBlock, used by the runtime
|
|
53
|
+
*/
|
|
54
|
+
class PixelateBlockShaderBinding extends ShaderBinding {
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new shader binding instance for the block.
|
|
57
|
+
* @param input - The input runtime value
|
|
58
|
+
* @param intensity - The intensity runtime value
|
|
59
|
+
* @param disabled - The disabled runtime value
|
|
60
|
+
*/
|
|
61
|
+
constructor(input, intensity, disabled) {
|
|
62
|
+
super();
|
|
63
|
+
this._input = input;
|
|
64
|
+
this._intensity = intensity;
|
|
65
|
+
this._disabled = disabled;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Binds all the required data to the shader when rendering.
|
|
69
|
+
* @param effect - defines the effect to bind the data to
|
|
70
|
+
* @param width - defines the width of the output
|
|
71
|
+
* @param height - defines the height of the output
|
|
72
|
+
*/
|
|
73
|
+
bind(effect, width, height) {
|
|
74
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
75
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
76
|
+
effect.setBool(this.getRemappedName(Uniforms.disabled), this._disabled.value);
|
|
77
|
+
effect.setFloat2(this.getRemappedName(Uniforms.aspect), width / height, height / width);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The implementation of the PixelateBlock
|
|
82
|
+
*/
|
|
83
|
+
export class PixelateBlock extends ShaderBlock {
|
|
84
|
+
/**
|
|
85
|
+
* Instantiates a new PixelateBlock.
|
|
86
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
87
|
+
* @param name - The friendly name of the block
|
|
88
|
+
*/
|
|
89
|
+
constructor(smartFilter, name) {
|
|
90
|
+
super(smartFilter, name, false);
|
|
91
|
+
/**
|
|
92
|
+
* The input connection point.
|
|
93
|
+
*/
|
|
94
|
+
this.input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
95
|
+
/**
|
|
96
|
+
/**
|
|
97
|
+
* The intensity connection point.
|
|
98
|
+
*/
|
|
99
|
+
this.intensity = this._registerOptionalInput("intensity", ConnectionPointType.Float, createStrongRef(0.3));
|
|
100
|
+
/**
|
|
101
|
+
/**
|
|
102
|
+
* The disabled connection point.
|
|
103
|
+
*/
|
|
104
|
+
this.disabled = this._registerOptionalInput("disabled", ConnectionPointType.Boolean, createStrongRef(false));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
108
|
+
* @returns The class instance that binds the data to the effect
|
|
109
|
+
*/
|
|
110
|
+
getShaderBinding() {
|
|
111
|
+
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
112
|
+
const intensity = this._confirmRuntimeDataSupplied(this.intensity);
|
|
113
|
+
const disabled = this._confirmRuntimeDataSupplied(this.disabled);
|
|
114
|
+
return new PixelateBlockShaderBinding(input, intensity, disabled);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The class name of the block.
|
|
119
|
+
*/
|
|
120
|
+
PixelateBlock.ClassName = "PixelateBlock";
|
|
121
|
+
/**
|
|
122
|
+
* The namespace of the block.
|
|
123
|
+
*/
|
|
124
|
+
PixelateBlock.Namespace = "Babylon.Demo.Effects";
|
|
125
|
+
/**
|
|
126
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
127
|
+
*/
|
|
128
|
+
PixelateBlock.ShaderCode = BlockShaderProgram;
|
|
129
|
+
//# sourceMappingURL=pixelateBlock.block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelateBlock.block.js","sourceRoot":"","sources":["../../../../../src/bloc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DD;;GAEG;AACoB,uBAAS,GAAG,eAAe,AAAlB,CAAmB;AAEnD;;GAEG;AACoB,uBAAS,GAAG,sBAAsB,AAAzB,CAA0B;AA2B1D;;GAEG;AACoB,wBAAU,GAAG,kBAAkB,AAArB,CAAsB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DisableableShaderBinding, ConnectionPointType, type SmartFilter, DisableableShaderBlock, type ShaderProgram } from "@onerjs/smart-filters";
|
|
2
|
+
/**
|
|
3
|
+
* The implementation of the PosterizeBlock
|
|
4
|
+
*/
|
|
5
|
+
export declare class PosterizeBlock extends DisableableShaderBlock {
|
|
6
|
+
/**
|
|
7
|
+
* The class name of the block.
|
|
8
|
+
*/
|
|
9
|
+
static ClassName: string;
|
|
10
|
+
/**
|
|
11
|
+
* The namespace of the block.
|
|
12
|
+
*/
|
|
13
|
+
static Namespace: string;
|
|
14
|
+
/**
|
|
15
|
+
* The input connection point.
|
|
16
|
+
*/
|
|
17
|
+
readonly input: import("@onerjs/smart-filters").ConnectionPoint<ConnectionPointType.Texture>;
|
|
18
|
+
/**
|
|
19
|
+
/**
|
|
20
|
+
* The intensity connection point.
|
|
21
|
+
*/
|
|
22
|
+
readonly intensity: import("dev/smartFilters/dist/connection/connectionPointWithDefault").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
23
|
+
/**
|
|
24
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
25
|
+
*/
|
|
26
|
+
static ShaderCode: ShaderProgram;
|
|
27
|
+
/**
|
|
28
|
+
* Instantiates a new PosterizeBlock.
|
|
29
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
30
|
+
* @param name - The friendly name of the block
|
|
31
|
+
*/
|
|
32
|
+
constructor(smartFilter: SmartFilter, name: string);
|
|
33
|
+
/**
|
|
34
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
35
|
+
* @returns The class instance that binds the data to the effect
|
|
36
|
+
*/
|
|
37
|
+
getShaderBinding(): DisableableShaderBinding;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=posterizeBlock.block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posterizeBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/posterizeBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EACnB,KAAK,WAAW,EAChB,sBAAsB,EACtB,KAAK,aAAa,EAGG,8BAAsB;AAgF/C;;GAEG;AACH,qBAAa,cAAe,SAAQ,sBAAsB;IACtD;;OAEG;IACH,OAAuB,SAAS,SAAoB;IAEpD;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D;;OAEG;IACH,SAAgB,KAAK,+EAAoE;IAEzF;;;OAGG;IACH,SAAgB,SAAS,8HAIvB;IAEF;;OAEG;IACH,OAAuB,UAAU,gBAAsB;IAEvD;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,wBAAwB;CAMtD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
// ************************************************************
|
|
3
|
+
// Note: this file is auto-generated, do not modify it directly
|
|
4
|
+
// ************************************************************
|
|
5
|
+
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, BlockDisableStrategy } from "@onerjs/smart-filters";
|
|
6
|
+
/**
|
|
7
|
+
* The shader program for the block.
|
|
8
|
+
*/
|
|
9
|
+
const BlockShaderProgram = {
|
|
10
|
+
vertex: undefined,
|
|
11
|
+
fragment: {
|
|
12
|
+
uniform: `
|
|
13
|
+
uniform sampler2D _input_; // main
|
|
14
|
+
uniform float _intensity_;`,
|
|
15
|
+
const: ` const float _posterizePower_ = 6.0;
|
|
16
|
+
const float _minLevel_ = 2.0;
|
|
17
|
+
const float _maxLevel_ = 256.0;`,
|
|
18
|
+
mainInputTexture: "_input_",
|
|
19
|
+
mainFunctionName: "_posterize_",
|
|
20
|
+
functions: [
|
|
21
|
+
{
|
|
22
|
+
name: "_posterize_",
|
|
23
|
+
code: `
|
|
24
|
+
vec4 _posterize_(vec2 vUV) {
|
|
25
|
+
vec4 color = texture2D(_input_, vUV);
|
|
26
|
+
|
|
27
|
+
float posterizeStrength = mix(_minLevel_, _maxLevel_, pow(1. - _intensity_, _posterizePower_));
|
|
28
|
+
vec3 _posterize_ = vec3(posterizeStrength);
|
|
29
|
+
color.rgb = floor(color.rgb / (1.0 / _posterize_)) * (1.0 / _posterize_);
|
|
30
|
+
|
|
31
|
+
return color;
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
34
|
+
params: "vec2 vUV",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
41
|
+
* that the names are always in sync.
|
|
42
|
+
*/
|
|
43
|
+
const Uniforms = {
|
|
44
|
+
input: "input",
|
|
45
|
+
intensity: "intensity",
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The shader binding for the PosterizeBlock, used by the runtime
|
|
49
|
+
*/
|
|
50
|
+
class PosterizeBlockShaderBinding extends DisableableShaderBinding {
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new shader binding instance for the block.
|
|
53
|
+
* @param parentBlock - IDisableableBlock
|
|
54
|
+
* @param input - The input runtime value
|
|
55
|
+
* @param intensity - The intensity runtime value
|
|
56
|
+
*/
|
|
57
|
+
constructor(parentBlock, input, intensity) {
|
|
58
|
+
super(parentBlock);
|
|
59
|
+
this._input = input;
|
|
60
|
+
this._intensity = intensity;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Binds all the required data to the shader when rendering.
|
|
64
|
+
* @param effect - defines the effect to bind the data to
|
|
65
|
+
*/
|
|
66
|
+
bind(effect) {
|
|
67
|
+
super.bind(effect);
|
|
68
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
69
|
+
effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The implementation of the PosterizeBlock
|
|
74
|
+
*/
|
|
75
|
+
export class PosterizeBlock extends DisableableShaderBlock {
|
|
76
|
+
/**
|
|
77
|
+
* Instantiates a new PosterizeBlock.
|
|
78
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
79
|
+
* @param name - The friendly name of the block
|
|
80
|
+
*/
|
|
81
|
+
constructor(smartFilter, name) {
|
|
82
|
+
super(smartFilter, name, false, BlockDisableStrategy.AutoSample);
|
|
83
|
+
/**
|
|
84
|
+
* The input connection point.
|
|
85
|
+
*/
|
|
86
|
+
this.input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
87
|
+
/**
|
|
88
|
+
/**
|
|
89
|
+
* The intensity connection point.
|
|
90
|
+
*/
|
|
91
|
+
this.intensity = this._registerOptionalInput("intensity", ConnectionPointType.Float, createStrongRef(0.3));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
95
|
+
* @returns The class instance that binds the data to the effect
|
|
96
|
+
*/
|
|
97
|
+
getShaderBinding() {
|
|
98
|
+
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
99
|
+
const intensity = this._confirmRuntimeDataSupplied(this.intensity);
|
|
100
|
+
return new PosterizeBlockShaderBinding(this, input, intensity);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The class name of the block.
|
|
105
|
+
*/
|
|
106
|
+
PosterizeBlock.ClassName = "PosterizeBlock";
|
|
107
|
+
/**
|
|
108
|
+
* The namespace of the block.
|
|
109
|
+
*/
|
|
110
|
+
PosterizeBlock.Namespace = "Babylon.Demo.Effects";
|
|
111
|
+
/**
|
|
112
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
113
|
+
*/
|
|
114
|
+
PosterizeBlock.ShaderCode = BlockShaderProgram;
|
|
115
|
+
//# sourceMappingURL=posterizeBlock.block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posterizeBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/posterizeBlock.block.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+DAA+D;AAC/D,+DAA+D;AAC/D,+DAA+D;AAS/D,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EAEnB,sBAAsB,EAEtB,eAAe,EAEf,oBAAoB,EAAC,8BAAsB;AAE/C;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACtC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;uCAEsB;QAC/B,KAAK,EAAE;;4CAE6B;QACpC,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,aAAa;QAC/B,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE;;;;;;;;;;qBAUD;gBACL,MAAM,EAAE,UAAU;aACrB;SACJ;KACJ;CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG;IACb,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;CACzB,CAAC;AAGF;;GAEG;AACH,MAAM,2BAA4B,SAAQ,wBAAwB;IAI9D;;;;;OAKG;IACH,YACI,WAA8B,EAC9B,KAA+C,EAC/C,SAAiD;QAEjD,KAAK,CAAC,WAAW,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAED;;;OAGG;IACa,IAAI,CAAC,MAAc;QAC/B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,sBAAsB;IA+BtD;;;;OAIG;IACH,YAAY,WAAwB,EAAE,IAAY;QAC9C,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;QA1BrE;;WAEG;QACa,UAAK,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEzF;;;WAGG;QACa,cAAS,GAAG,IAAI,CAAC,sBAAsB,CACnD,WAAW,EACX,mBAAmB,CAAC,KAAK,EACzB,eAAe,CAAC,GAAG,CAAC,CACvB,CAAC;IAcF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEnE,OAAO,IAAI,2BAA2B,CAAC,IAAI,EAAC,KAAK,EAAC,SAAS,CAAC,CAAC;IACjE,CAAC;;AAhDD;;GAEG;AACoB,wBAAS,GAAG,gBAAgB,AAAnB,CAAoB;AAEpD;;GAEG;AACoB,wBAAS,GAAG,sBAAsB,AAAzB,CAA0B;AAiB1D;;GAEG;AACoB,yBAAU,GAAG,kBAAkB,AAArB,CAAsB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Effect } from "@onerjs/core/Materials/effect.js";
|
|
2
|
+
import { DisableableShaderBinding, type RuntimeData, ConnectionPointType, type IDisableableBlock, DisableableShaderBlock, type SmartFilter } from "@onerjs/smart-filters";
|
|
3
|
+
/**
|
|
4
|
+
* The shader bindings for the Spritesheet block.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SpritesheetShaderBinding extends DisableableShaderBinding {
|
|
7
|
+
private readonly _inputTexture;
|
|
8
|
+
private readonly _time;
|
|
9
|
+
private readonly _rows;
|
|
10
|
+
private readonly _cols;
|
|
11
|
+
private readonly _frames;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new shader binding instance for the SpriteSheet block.
|
|
14
|
+
* @param parentBlock - The parent block
|
|
15
|
+
* @param inputTexture - The input texture
|
|
16
|
+
* @param time - The time passed since the start of the effect
|
|
17
|
+
* @param rows - The number of rows in the sprite sheet
|
|
18
|
+
* @param cols - The number of columns in the sprite sheet
|
|
19
|
+
* @param frames - The number of frames to show
|
|
20
|
+
*/
|
|
21
|
+
constructor(parentBlock: IDisableableBlock, inputTexture: RuntimeData<ConnectionPointType.Texture>, time: RuntimeData<ConnectionPointType.Float>, rows: RuntimeData<ConnectionPointType.Float>, cols: RuntimeData<ConnectionPointType.Float>, frames: RuntimeData<ConnectionPointType.Float>);
|
|
22
|
+
/**
|
|
23
|
+
* Binds all the required data to the shader when rendering.
|
|
24
|
+
* @param effect - defines the effect to bind the data to
|
|
25
|
+
*/
|
|
26
|
+
bind(effect: Effect): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A block that animates a sprite sheet texture.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SpritesheetBlock extends DisableableShaderBlock {
|
|
32
|
+
/**
|
|
33
|
+
* The class name of the block.
|
|
34
|
+
*/
|
|
35
|
+
static ClassName: string;
|
|
36
|
+
/**
|
|
37
|
+
* The namespace of the block.
|
|
38
|
+
*/
|
|
39
|
+
static Namespace: string;
|
|
40
|
+
/**
|
|
41
|
+
* The input texture connection point
|
|
42
|
+
*/
|
|
43
|
+
readonly input: import("@onerjs/smart-filters").ConnectionPoint<ConnectionPointType.Texture>;
|
|
44
|
+
/**
|
|
45
|
+
* The time connection point to animate the effect.
|
|
46
|
+
*/
|
|
47
|
+
readonly time: import("dev/smartFilters/dist/connection/connectionPointWithDefault.js").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
48
|
+
/**
|
|
49
|
+
* The number of rows in the sprite sheet, as a connection point.
|
|
50
|
+
*/
|
|
51
|
+
readonly rows: import("dev/smartFilters/dist/connection/connectionPointWithDefault.js").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
52
|
+
/**
|
|
53
|
+
* The number of columns in the sprite sheet, as a connection point.
|
|
54
|
+
*/
|
|
55
|
+
readonly columns: import("dev/smartFilters/dist/connection/connectionPointWithDefault.js").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
56
|
+
/**
|
|
57
|
+
* The number of frames to animate from the beginning, as a connection point.
|
|
58
|
+
* Defaults to rows * columns at runtime.
|
|
59
|
+
*/
|
|
60
|
+
readonly frames: import("dev/smartFilters/dist/connection/connectionPointWithDefault.js").ConnectionPointWithDefault<ConnectionPointType.Float>;
|
|
61
|
+
/**
|
|
62
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
63
|
+
*/
|
|
64
|
+
static ShaderCode: import("@onerjs/smart-filters").ShaderProgram;
|
|
65
|
+
/**
|
|
66
|
+
* Instantiates a new Block.
|
|
67
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
68
|
+
* @param name - The friendly name of the block
|
|
69
|
+
*/
|
|
70
|
+
constructor(smartFilter: SmartFilter, name: string);
|
|
71
|
+
/**
|
|
72
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
73
|
+
* @returns The class instance that binds the data to the effect
|
|
74
|
+
*/
|
|
75
|
+
getShaderBinding(): DisableableShaderBinding;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=spritesheetBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spritesheetBlock.d.ts","sourceRoot":"","sources":["../../../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F;IAEhH;;OAEG;IACH,OAAuB,UAAU,gDAAiB;IAElD;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,wBAAwB;CAStD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ShaderProgram } from "@onerjs/smart-filters";
|
|
2
|
+
/**
|
|
3
|
+
* The shader program for the block.
|
|
4
|
+
*/
|
|
5
|
+
declare const BlockShaderProgram: ShaderProgram;
|
|
6
|
+
/**
|
|
7
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
8
|
+
* that the names are always in sync.
|
|
9
|
+
*/
|
|
10
|
+
declare const Uniforms: {
|
|
11
|
+
input: string;
|
|
12
|
+
time: string;
|
|
13
|
+
rows: string;
|
|
14
|
+
cols: string;
|
|
15
|
+
frames: string;
|
|
16
|
+
disabled: string;
|
|
17
|
+
};
|
|
18
|
+
export { BlockShaderProgram, Uniforms };
|
|
19
|
+
export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
|
|
20
|
+
//# sourceMappingURL=spritesheetBlock.fragment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spritesheetBlock.fragment.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAAsB;AAEnD;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAwCzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,QAAQ;;;;;;;CAOb,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;AAExC,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,QAAQ,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shader program for the block.
|
|
3
|
+
*/
|
|
4
|
+
const BlockShaderProgram = {
|
|
5
|
+
vertex: undefined,
|
|
6
|
+
fragment: {
|
|
7
|
+
uniform: `
|
|
8
|
+
uniform sampler2D _input_; // main
|
|
9
|
+
uniform float _time_;
|
|
10
|
+
uniform float _rows_;
|
|
11
|
+
uniform float _cols_;
|
|
12
|
+
uniform float _frames_;
|
|
13
|
+
uniform bool _disabled_;`,
|
|
14
|
+
mainInputTexture: "_input_",
|
|
15
|
+
mainFunctionName: "_mainImage_",
|
|
16
|
+
functions: [
|
|
17
|
+
{
|
|
18
|
+
name: "_mainImage_",
|
|
19
|
+
code: `
|
|
20
|
+
vec4 _mainImage_(vec2 vUV) {
|
|
21
|
+
if (!_disabled_) {
|
|
22
|
+
float invRows = 1.0 / _rows_;
|
|
23
|
+
float invCols = 1.0 / _cols_;
|
|
24
|
+
|
|
25
|
+
// Get offset of frame
|
|
26
|
+
float frame = mod(floor(_time_), _frames_);
|
|
27
|
+
float row = (_rows_ - 1.0) - floor(frame * invCols); // Reverse row direction b/c UVs start from bottom
|
|
28
|
+
float col = mod(frame, _cols_);
|
|
29
|
+
|
|
30
|
+
// Add offset, then scale UV down to frame size
|
|
31
|
+
vUV = vec2(
|
|
32
|
+
(vUV.x + col) * invCols,
|
|
33
|
+
(vUV.y + row) * invRows
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return texture2D(_input_, vUV);
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
params: "vec2 vUV",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
47
|
+
* that the names are always in sync.
|
|
48
|
+
*/
|
|
49
|
+
const Uniforms = {
|
|
50
|
+
input: "input",
|
|
51
|
+
time: "time",
|
|
52
|
+
rows: "rows",
|
|
53
|
+
cols: "cols",
|
|
54
|
+
frames: "frames",
|
|
55
|
+
disabled: "disabled",
|
|
56
|
+
};
|
|
57
|
+
export { BlockShaderProgram, Uniforms };
|
|
58
|
+
// Back compat for when camelCase was used
|
|
59
|
+
export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
|
|
60
|
+
//# sourceMappingURL=spritesheetBlock.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spritesheetBlock.fragment.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACtC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;;;;;qCAMoB;QAC7B,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,aAAa;QAC/B,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;qBAoBD;gBACL,MAAM,EAAE,UAAU;aACrB;SACJ;KACJ;CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG;IACb,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACvB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;AACxC,0CAA0C;AAC1C,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,QAAQ,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { spritesheetBlockType } from "../../../blockTypes.js";
|
|
2
|
+
import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
|
|
3
|
+
import { shaderProgram, uniforms } from "./spritesheetBlock.fragment.js";
|
|
4
|
+
import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, BlockDisableStrategy, } from "@onerjs/smart-filters";
|
|
5
|
+
/**
|
|
6
|
+
* The shader bindings for the Spritesheet block.
|
|
7
|
+
*/
|
|
8
|
+
export class SpritesheetShaderBinding extends DisableableShaderBinding {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new shader binding instance for the SpriteSheet block.
|
|
11
|
+
* @param parentBlock - The parent block
|
|
12
|
+
* @param inputTexture - The input texture
|
|
13
|
+
* @param time - The time passed since the start of the effect
|
|
14
|
+
* @param rows - The number of rows in the sprite sheet
|
|
15
|
+
* @param cols - The number of columns in the sprite sheet
|
|
16
|
+
* @param frames - The number of frames to show
|
|
17
|
+
*/
|
|
18
|
+
constructor(parentBlock, inputTexture, time, rows, cols, frames) {
|
|
19
|
+
super(parentBlock);
|
|
20
|
+
this._inputTexture = inputTexture;
|
|
21
|
+
this._time = time;
|
|
22
|
+
this._rows = rows;
|
|
23
|
+
this._cols = cols;
|
|
24
|
+
this._frames = frames;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Binds all the required data to the shader when rendering.
|
|
28
|
+
* @param effect - defines the effect to bind the data to
|
|
29
|
+
*/
|
|
30
|
+
bind(effect) {
|
|
31
|
+
super.bind(effect);
|
|
32
|
+
effect.setTexture(this.getRemappedName(uniforms.input), this._inputTexture.value);
|
|
33
|
+
effect.setFloat(this.getRemappedName(uniforms.time), this._time.value);
|
|
34
|
+
effect.setFloat(this.getRemappedName(uniforms.rows), this._rows.value);
|
|
35
|
+
effect.setFloat(this.getRemappedName(uniforms.cols), this._cols.value);
|
|
36
|
+
// Apply default value for frame count if it was not provided
|
|
37
|
+
effect.setFloat(this.getRemappedName(uniforms.frames), this._frames.value > 0 ? this._frames.value : this._rows.value * this._cols.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A block that animates a sprite sheet texture.
|
|
42
|
+
*/
|
|
43
|
+
export class SpritesheetBlock extends DisableableShaderBlock {
|
|
44
|
+
/**
|
|
45
|
+
* Instantiates a new Block.
|
|
46
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
47
|
+
* @param name - The friendly name of the block
|
|
48
|
+
*/
|
|
49
|
+
constructor(smartFilter, name) {
|
|
50
|
+
super(smartFilter, name, false, BlockDisableStrategy.Manual);
|
|
51
|
+
/**
|
|
52
|
+
* The input texture connection point
|
|
53
|
+
*/
|
|
54
|
+
this.input = this._registerInput("input", ConnectionPointType.Texture);
|
|
55
|
+
/**
|
|
56
|
+
* The time connection point to animate the effect.
|
|
57
|
+
*/
|
|
58
|
+
this.time = this._registerOptionalInput("time", ConnectionPointType.Float, createStrongRef(0.0));
|
|
59
|
+
/**
|
|
60
|
+
* The number of rows in the sprite sheet, as a connection point.
|
|
61
|
+
*/
|
|
62
|
+
this.rows = this._registerOptionalInput("rows", ConnectionPointType.Float, createStrongRef(1.0));
|
|
63
|
+
/**
|
|
64
|
+
* The number of columns in the sprite sheet, as a connection point.
|
|
65
|
+
*/
|
|
66
|
+
this.columns = this._registerOptionalInput("columns", ConnectionPointType.Float, createStrongRef(1.0));
|
|
67
|
+
/**
|
|
68
|
+
* The number of frames to animate from the beginning, as a connection point.
|
|
69
|
+
* Defaults to rows * columns at runtime.
|
|
70
|
+
*/
|
|
71
|
+
this.frames = this._registerOptionalInput("frames", ConnectionPointType.Float, createStrongRef(0.0));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
75
|
+
* @returns The class instance that binds the data to the effect
|
|
76
|
+
*/
|
|
77
|
+
getShaderBinding() {
|
|
78
|
+
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
79
|
+
const rows = this.rows.runtimeData;
|
|
80
|
+
const columns = this.columns.runtimeData;
|
|
81
|
+
const time = this.time.runtimeData;
|
|
82
|
+
const frames = this.frames.runtimeData;
|
|
83
|
+
return new SpritesheetShaderBinding(this, input, time, rows, columns, frames);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The class name of the block.
|
|
88
|
+
*/
|
|
89
|
+
SpritesheetBlock.ClassName = spritesheetBlockType;
|
|
90
|
+
/**
|
|
91
|
+
* The namespace of the block.
|
|
92
|
+
*/
|
|
93
|
+
SpritesheetBlock.Namespace = babylonDemoEffectsNamespace;
|
|
94
|
+
/**
|
|
95
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
96
|
+
*/
|
|
97
|
+
SpritesheetBlock.ShaderCode = shaderProgram;
|
|
98
|
+
//# sourceMappingURL=spritesheetBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spritesheetBlock.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/spritesheetBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EAEnB,sBAAsB,EAEtB,eAAe,EACf,oBAAoB,GACvB,8BAAsB;AAEvB;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,wBAAwB;IAOlE;;;;;;;;OAQG;IACH,YACI,WAA8B,EAC9B,YAAsD,EACtD,IAA4C,EAC5C,IAA4C,EAC5C,IAA4C,EAC5C,MAA8C;QAE9C,KAAK,CAAC,WAAW,CAAC,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACa,IAAI,CAAC,MAAc;QAC/B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACn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,CAAC;QAE5G;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;QAE5G;;WAEG;QACa,YAAO,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;QAElH;;;WAGG;QACa,WAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IAchH,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QAEvC,OAAO,IAAI,wBAAwB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAClF,CAAC;;AA9DD;;GAEG;AACoB,0BAAS,GAAG,oBAAoB,AAAvB,CAAwB;AAExD;;GAEG;AACoB,0BAAS,GAAG,2BAA2B,AAA9B,CAA+B;AA4B/D;;GAEG;AACoB,2BAAU,GAAG,aAAa,AAAhB,CAAiB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SerializedShaderBlockDefinition } from "@onerjs/smart-filters";
|
|
2
|
+
/**
|
|
3
|
+
* This is included to show how a serialized block definition can be loaded and used.
|
|
4
|
+
* This object could have been deserialized from a JSON file, for example.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DeserializedTintBlockDefinition: SerializedShaderBlockDefinition;
|
|
7
|
+
//# sourceMappingURL=tintBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tintBlock.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/tintBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,+BAA+B,EAAE,8BAAsB;AAE1F;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,+BA4C7C,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ConnectionPointType } from "@onerjs/smart-filters";
|
|
2
|
+
/**
|
|
3
|
+
* This is included to show how a serialized block definition can be loaded and used.
|
|
4
|
+
* This object could have been deserialized from a JSON file, for example.
|
|
5
|
+
*/
|
|
6
|
+
export const DeserializedTintBlockDefinition = {
|
|
7
|
+
format: "shaderBlockDefinition",
|
|
8
|
+
formatVersion: 1,
|
|
9
|
+
blockType: "TintBlock",
|
|
10
|
+
namespace: "Babylon.Demo.Effects",
|
|
11
|
+
shaderProgram: {
|
|
12
|
+
fragment: {
|
|
13
|
+
uniform: `
|
|
14
|
+
uniform sampler2D _input_; // main
|
|
15
|
+
uniform vec3 _tint_;
|
|
16
|
+
uniform float _amount_;
|
|
17
|
+
`,
|
|
18
|
+
mainInputTexture: "_input_",
|
|
19
|
+
mainFunctionName: "_mainImage_",
|
|
20
|
+
functions: [
|
|
21
|
+
{
|
|
22
|
+
name: "_mainImage_",
|
|
23
|
+
code: `
|
|
24
|
+
vec4 _mainImage_(vec2 vUV) {
|
|
25
|
+
vec4 color = texture2D(_input_, vUV);
|
|
26
|
+
vec3 tinted = mix(color.rgb, _tint_, _amount_);
|
|
27
|
+
return vec4(tinted, color.a);
|
|
28
|
+
}`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
inputConnectionPoints: [
|
|
34
|
+
{
|
|
35
|
+
name: "input",
|
|
36
|
+
type: ConnectionPointType.Texture,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "tint",
|
|
40
|
+
type: ConnectionPointType.Color3,
|
|
41
|
+
defaultValue: { r: 1, g: 0, b: 0 },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "amount",
|
|
45
|
+
type: ConnectionPointType.Float,
|
|
46
|
+
defaultValue: 0.25,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
disableOptimization: false,
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=tintBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tintBlock.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/tintBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAwC,8BAAsB;AAE1F;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAoC;IAC5E,MAAM,EAAE,uBAAuB;IAC/B,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,sBAAsB;IACjC,aAAa,EAAE;QACX,QAAQ,EAAE;YACN,OAAO,EAAE;;;;iBAIJ;YACL,gBAAgB,EAAE,SAAS;YAC3B,gBAAgB,EAAE,aAAa;YAC/B,SAAS,EAAE;gBACP;oBACI,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE;;;;;0BAKA;iBACT;aACJ;SACJ;KACJ;IACD,qBAAqB,EAAE;QACnB;YACI,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,mBAAmB,CAAC,OAAO;SACpC;QACD;YACI,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,mBAAmB,CAAC,MAAM;YAChC,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;SACrC;QACD;YACI,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,mBAAmB,CAAC,KAAK;YAC/B,YAAY,EAAE,IAAI;SACrB;KACJ;IACD,mBAAmB,EAAE,KAAK;CAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|