@babylonjs/smart-filters-blocks 0.8.1

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.
Files changed (190) hide show
  1. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.d.ts +34 -0
  2. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.d.ts.map +1 -0
  3. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js +101 -0
  4. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js.map +1 -0
  5. package/dist/blocks/babylon/demo/effects/blurBlock.d.ts +53 -0
  6. package/dist/blocks/babylon/demo/effects/blurBlock.d.ts.map +1 -0
  7. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts +28 -0
  8. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts.map +1 -0
  9. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js +17 -0
  10. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js.map +1 -0
  11. package/dist/blocks/babylon/demo/effects/blurBlock.js +98 -0
  12. package/dist/blocks/babylon/demo/effects/blurBlock.js.map +1 -0
  13. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts +8 -0
  14. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts.map +1 -0
  15. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js +28 -0
  16. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js.map +1 -0
  17. package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts +116 -0
  18. package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +1 -0
  19. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts +24 -0
  20. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts.map +1 -0
  21. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js +15 -0
  22. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js.map +1 -0
  23. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts +18 -0
  24. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts.map +1 -0
  25. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js +69 -0
  26. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js.map +1 -0
  27. package/dist/blocks/babylon/demo/effects/compositionBlock.js +167 -0
  28. package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +1 -0
  29. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts +6 -0
  30. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts.map +1 -0
  31. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js +25 -0
  32. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js.map +1 -0
  33. package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts +39 -0
  34. package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts.map +1 -0
  35. package/dist/blocks/babylon/demo/effects/contrastBlock.block.js +140 -0
  36. package/dist/blocks/babylon/demo/effects/contrastBlock.block.js.map +1 -0
  37. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts +39 -0
  38. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts.map +1 -0
  39. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js +115 -0
  40. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js.map +1 -0
  41. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts +74 -0
  42. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts.map +1 -0
  43. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts +32 -0
  44. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts.map +1 -0
  45. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js +17 -0
  46. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js.map +1 -0
  47. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js +167 -0
  48. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js.map +1 -0
  49. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts +6 -0
  50. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts.map +1 -0
  51. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js +27 -0
  52. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js.map +1 -0
  53. package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts +38 -0
  54. package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts.map +1 -0
  55. package/dist/blocks/babylon/demo/effects/exposureBlock.block.js +107 -0
  56. package/dist/blocks/babylon/demo/effects/exposureBlock.block.js.map +1 -0
  57. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts +46 -0
  58. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts.map +1 -0
  59. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js +133 -0
  60. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js.map +1 -0
  61. package/dist/blocks/babylon/demo/effects/index.d.ts +15 -0
  62. package/dist/blocks/babylon/demo/effects/index.d.ts.map +1 -0
  63. package/dist/blocks/babylon/demo/effects/index.js +15 -0
  64. package/dist/blocks/babylon/demo/effects/index.js.map +1 -0
  65. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts +58 -0
  66. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts.map +1 -0
  67. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js +158 -0
  68. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js.map +1 -0
  69. package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts +38 -0
  70. package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts.map +1 -0
  71. package/dist/blocks/babylon/demo/effects/maskBlock.block.js +110 -0
  72. package/dist/blocks/babylon/demo/effects/maskBlock.block.js.map +1 -0
  73. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts +44 -0
  74. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts.map +1 -0
  75. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js +125 -0
  76. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js.map +1 -0
  77. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts +39 -0
  78. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts.map +1 -0
  79. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js +116 -0
  80. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js.map +1 -0
  81. package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts +77 -0
  82. package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts.map +1 -0
  83. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts +18 -0
  84. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts.map +1 -0
  85. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js +58 -0
  86. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js.map +1 -0
  87. package/dist/blocks/babylon/demo/effects/spritesheetBlock.js +98 -0
  88. package/dist/blocks/babylon/demo/effects/spritesheetBlock.js.map +1 -0
  89. package/dist/blocks/babylon/demo/effects/tintBlock.d.ts +7 -0
  90. package/dist/blocks/babylon/demo/effects/tintBlock.d.ts.map +1 -0
  91. package/dist/blocks/babylon/demo/effects/tintBlock.js +51 -0
  92. package/dist/blocks/babylon/demo/effects/tintBlock.js.map +1 -0
  93. package/dist/blocks/babylon/demo/transitions/index.d.ts +2 -0
  94. package/dist/blocks/babylon/demo/transitions/index.d.ts.map +1 -0
  95. package/dist/blocks/babylon/demo/transitions/index.js +2 -0
  96. package/dist/blocks/babylon/demo/transitions/index.js.map +1 -0
  97. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts +42 -0
  98. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts.map +1 -0
  99. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js +116 -0
  100. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js.map +1 -0
  101. package/dist/blocks/babylon/demo/utilities/index.d.ts +2 -0
  102. package/dist/blocks/babylon/demo/utilities/index.d.ts.map +1 -0
  103. package/dist/blocks/babylon/demo/utilities/index.js +2 -0
  104. package/dist/blocks/babylon/demo/utilities/index.js.map +1 -0
  105. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts +34 -0
  106. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts.map +1 -0
  107. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js +97 -0
  108. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js.map +1 -0
  109. package/dist/blocks/blockNamespaces.d.ts +5 -0
  110. package/dist/blocks/blockNamespaces.d.ts.map +1 -0
  111. package/dist/blocks/blockNamespaces.js +5 -0
  112. package/dist/blocks/blockNamespaces.js.map +1 -0
  113. package/dist/blocks/blockTypes.d.ts +22 -0
  114. package/dist/blocks/blockTypes.d.ts.map +1 -0
  115. package/dist/blocks/blockTypes.js +22 -0
  116. package/dist/blocks/blockTypes.js.map +1 -0
  117. package/dist/blocks/index.d.ts +6 -0
  118. package/dist/blocks/index.d.ts.map +1 -0
  119. package/dist/blocks/index.js +6 -0
  120. package/dist/blocks/index.js.map +1 -0
  121. package/dist/index.d.ts +3 -0
  122. package/dist/index.d.ts.map +1 -0
  123. package/dist/index.js +3 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/registration/IBlockRegistration.d.ts +34 -0
  126. package/dist/registration/IBlockRegistration.d.ts.map +1 -0
  127. package/dist/registration/IBlockRegistration.js +2 -0
  128. package/dist/registration/IBlockRegistration.js.map +1 -0
  129. package/dist/registration/blockSerializers.d.ts +13 -0
  130. package/dist/registration/blockSerializers.d.ts.map +1 -0
  131. package/dist/registration/blockSerializers.js +35 -0
  132. package/dist/registration/blockSerializers.js.map +1 -0
  133. package/dist/registration/builtInBlockRegistrations.d.ts +13 -0
  134. package/dist/registration/builtInBlockRegistrations.d.ts.map +1 -0
  135. package/dist/registration/builtInBlockRegistrations.js +269 -0
  136. package/dist/registration/builtInBlockRegistrations.js.map +1 -0
  137. package/dist/registration/index.d.ts +3 -0
  138. package/dist/registration/index.d.ts.map +1 -0
  139. package/dist/registration/index.js +3 -0
  140. package/dist/registration/index.js.map +1 -0
  141. package/license.md +21 -0
  142. package/package.json +52 -0
  143. package/readme.md +7 -0
  144. package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.glsl +18 -0
  145. package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.ts +133 -0
  146. package/src/blocks/babylon/demo/effects/blurBlock.deserializer.ts +37 -0
  147. package/src/blocks/babylon/demo/effects/blurBlock.serializer.ts +31 -0
  148. package/src/blocks/babylon/demo/effects/blurBlock.ts +122 -0
  149. package/src/blocks/babylon/demo/effects/compositionBlock.deserializer.ts +31 -0
  150. package/src/blocks/babylon/demo/effects/compositionBlock.fragment.glsl +38 -0
  151. package/src/blocks/babylon/demo/effects/compositionBlock.fragment.ts +71 -0
  152. package/src/blocks/babylon/demo/effects/compositionBlock.serializer.ts +28 -0
  153. package/src/blocks/babylon/demo/effects/compositionBlock.ts +243 -0
  154. package/src/blocks/babylon/demo/effects/contrastBlock.block.glsl +36 -0
  155. package/src/blocks/babylon/demo/effects/contrastBlock.block.ts +180 -0
  156. package/src/blocks/babylon/demo/effects/desaturateBlock.block.glsl +24 -0
  157. package/src/blocks/babylon/demo/effects/desaturateBlock.block.ts +155 -0
  158. package/src/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.ts +46 -0
  159. package/src/blocks/babylon/demo/effects/directionalBlurBlock.serializer.ts +30 -0
  160. package/src/blocks/babylon/demo/effects/directionalBlurBlock.ts +196 -0
  161. package/src/blocks/babylon/demo/effects/exposureBlock.block.glsl +15 -0
  162. package/src/blocks/babylon/demo/effects/exposureBlock.block.ts +142 -0
  163. package/src/blocks/babylon/demo/effects/greenScreenBlock.block.glsl +23 -0
  164. package/src/blocks/babylon/demo/effects/greenScreenBlock.block.ts +174 -0
  165. package/src/blocks/babylon/demo/effects/index.ts +14 -0
  166. package/src/blocks/babylon/demo/effects/kaleidoscopeBlock.ts +192 -0
  167. package/src/blocks/babylon/demo/effects/maskBlock.block.glsl +18 -0
  168. package/src/blocks/babylon/demo/effects/maskBlock.block.ts +145 -0
  169. package/src/blocks/babylon/demo/effects/pixelateBlock.block.glsl +28 -0
  170. package/src/blocks/babylon/demo/effects/pixelateBlock.block.ts +169 -0
  171. package/src/blocks/babylon/demo/effects/posterizeBlock.block.glsl +25 -0
  172. package/src/blocks/babylon/demo/effects/posterizeBlock.block.ts +156 -0
  173. package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.glsl +26 -0
  174. package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts +60 -0
  175. package/src/blocks/babylon/demo/effects/spritesheetBlock.ts +138 -0
  176. package/src/blocks/babylon/demo/effects/tintBlock.ts +51 -0
  177. package/src/blocks/babylon/demo/transitions/index.ts +1 -0
  178. package/src/blocks/babylon/demo/transitions/wipeBlock.block.glsl +11 -0
  179. package/src/blocks/babylon/demo/transitions/wipeBlock.block.ts +152 -0
  180. package/src/blocks/babylon/demo/utilities/index.ts +1 -0
  181. package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.glsl +14 -0
  182. package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.ts +129 -0
  183. package/src/blocks/blockNamespaces.ts +4 -0
  184. package/src/blocks/blockTypes.ts +21 -0
  185. package/src/blocks/index.ts +5 -0
  186. package/src/index.ts +2 -0
  187. package/src/registration/IBlockRegistration.ts +43 -0
  188. package/src/registration/blockSerializers.ts +52 -0
  189. package/src/registration/builtInBlockRegistrations.ts +397 -0
  190. package/src/registration/index.ts +2 -0
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The shader program for the block.
3
+ */
4
+ export const shaderProgram = {
5
+ vertex: undefined,
6
+ fragment: {
7
+ uniform: `
8
+ uniform sampler2D _background_; // main
9
+ uniform sampler2D _foreground_;
10
+ uniform vec2 _scaleUV_;
11
+ uniform vec2 _translateUV_;
12
+ uniform float _alphaMode_;
13
+ uniform float _foregroundAlphaScale_;`,
14
+ mainInputTexture: "_background_",
15
+ mainFunctionName: "_composition_",
16
+ functions: [
17
+ {
18
+ name: "_composition_",
19
+ code: `
20
+ vec4 _composition_(vec2 vUV) {
21
+ vec4 _background_ = texture2D(_background_, vUV);
22
+
23
+ vec2 transformedUV = vUV * (1.0 / _scaleUV_) + _translateUV_;
24
+ if (transformedUV.x < 0.0 || transformedUV.x > 1.0 || transformedUV.y < 0.0 || transformedUV.y > 1.0) {
25
+ return _background_;
26
+ }
27
+
28
+ vec4 _foreground_ = texture2D(_foreground_, transformedUV);
29
+ _foreground_.a *= _foregroundAlphaScale_;
30
+
31
+ // SRC is _foreground_, DEST is _background_
32
+ if (_alphaMode_ == 0.) {
33
+ return _foreground_;
34
+ }
35
+ else if (_alphaMode_ == 1.) {
36
+ return _foreground_.a * _foreground_ + _background_;
37
+ }
38
+ else if (_alphaMode_ == 2.) {
39
+ return mix(_background_, _foreground_, _foreground_.a);
40
+ }
41
+ else if (_alphaMode_ == 3.) {
42
+ return _background_ - _foreground_ * _background_;
43
+ }
44
+ else if (_alphaMode_ == 4.) {
45
+ return _foreground_ * _background_;
46
+ }
47
+
48
+ return _background_;
49
+ }
50
+
51
+ `,
52
+ params: "vec2 vUV",
53
+ },
54
+ ],
55
+ },
56
+ };
57
+ /**
58
+ * The uniform names for this shader, to be used in the shader binding so
59
+ * that the names are always in sync.
60
+ */
61
+ export const uniforms = {
62
+ background: "background",
63
+ foreground: "foreground",
64
+ scaleUV: "scaleUV",
65
+ translateUV: "translateUV",
66
+ alphaMode: "alphaMode",
67
+ foregroundAlphaScale: "foregroundAlphaScale",
68
+ };
69
+ //# sourceMappingURL=compositionBlock.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compositionBlock.fragment.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.fragment.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IACxC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;;;;;kDAMiC;QAC1C,gBAAgB,EAAE,cAAc;QAChC,gBAAgB,EAAE,eAAe;QACjC,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCD;gBACL,MAAM,EAAE,UAAU;aACrB;SACJ;KACJ;CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,oBAAoB,EAAE,sBAAsB;CAC/C,CAAC"}
@@ -0,0 +1,167 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { DisableableShaderBinding, ConnectionPointType, DisableableShaderBlock, createStrongRef, PropertyTypeForEdition, editableInPropertyPage, } from "@babylonjs/smart-filters";
8
+ import { compositionBlockType } from "../../../blockTypes.js";
9
+ import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
10
+ import { uniforms, shaderProgram } from "./compositionBlock.fragment.js";
11
+ /** Defines that alpha blending is disabled */
12
+ export const ALPHA_DISABLE = 0;
13
+ /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
14
+ export const ALPHA_ADD = 1;
15
+ /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
16
+ export const ALPHA_COMBINE = 2;
17
+ /** Defines that alpha blending is DEST - SRC * DEST */
18
+ export const ALPHA_SUBTRACT = 3;
19
+ /** Defines that alpha blending is SRC * DEST */
20
+ export const ALPHA_MULTIPLY = 4;
21
+ /**
22
+ * The shader bindings for the Composition block.
23
+ * This demonstrates how multiple input connection point values can be packed into a single
24
+ * uniform.
25
+ */
26
+ export class CompositionShaderBinding extends DisableableShaderBinding {
27
+ /**
28
+ * Creates a new shader binding instance for the Composition block.
29
+ * @param parentBlock - The parent block
30
+ * @param backgroundTexture - the background texture
31
+ * @param foregroundTexture - the foreground texture
32
+ * @param foregroundTop - the top position of the foreground texture
33
+ * @param foregroundLeft - the left position of the foreground texture
34
+ * @param foregroundWidth - the width of the foreground texture
35
+ * @param foregroundHeight - the height of the foreground texture
36
+ * @param foregroundAlphaScale - the alpha scale of the foreground texture
37
+ * @param alphaMode - the alpha mode to use
38
+ */
39
+ constructor(parentBlock, backgroundTexture, foregroundTexture, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale, alphaMode) {
40
+ super(parentBlock);
41
+ this._backgroundTexture = backgroundTexture;
42
+ this._foregroundTexture = foregroundTexture;
43
+ this._foregroundTop = foregroundTop;
44
+ this._foregroundLeft = foregroundLeft;
45
+ this._foregroundWidth = foregroundWidth;
46
+ this._foregroundHeight = foregroundHeight;
47
+ this._foregroundAlphaScale = foregroundAlphaScale;
48
+ this._alphaMode = alphaMode;
49
+ }
50
+ /**
51
+ * Binds all the required data to the shader when rendering.
52
+ * @param effect - defines the effect to bind the data to
53
+ * @param width - defines the width of the output
54
+ * @param height - defines the height of the output
55
+ */
56
+ bind(effect, width, height) {
57
+ super.bind(effect, width, height);
58
+ const background = this._backgroundTexture.value;
59
+ const foreground = this._foregroundTexture.value;
60
+ const foregroundTop = this._foregroundTop.value;
61
+ const foregroundLeft = this._foregroundLeft.value;
62
+ const foregroundWidth = this._foregroundWidth.value;
63
+ const foregroundHeight = this._foregroundHeight.value;
64
+ const foregroundAlphaScale = this._foregroundAlphaScale.value;
65
+ const alphaMode = this._alphaMode;
66
+ effect.setFloat(this.getRemappedName(uniforms.alphaMode), alphaMode);
67
+ effect.setTexture(this.getRemappedName(uniforms.background), background);
68
+ effect.setTexture(this.getRemappedName(uniforms.foreground), foreground);
69
+ // NOTE: textures may always be undefined if connected to another shader block when the graph is optimized
70
+ effect.setFloat2(this.getRemappedName(uniforms.scaleUV), foregroundWidth, foregroundHeight);
71
+ effect.setFloat2(this.getRemappedName(uniforms.translateUV), -1 * foregroundLeft, foregroundTop);
72
+ effect.setFloat(this.getRemappedName(uniforms.foregroundAlphaScale), foregroundAlphaScale);
73
+ }
74
+ }
75
+ /**
76
+ * A simple compositing Block letting the filter "blend" 2 different layers.
77
+ * It demonstrates how a block can use properties for values which will not change at runtime (alphaMode)
78
+ *
79
+ * The alpha mode of the block can be set to one of the following:
80
+ * - ALPHA_DISABLE: alpha blending is disabled
81
+ * - ALPHA_ADD: alpha blending is SRC ALPHA * SRC + DEST
82
+ * - ALPHA_COMBINE: alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST
83
+ * - ALPHA_SUBTRACT: alpha blending is DEST - SRC * DEST
84
+ * - ALPHA_MULTIPLY: alpha blending is SRC * DEST
85
+ */
86
+ export class CompositionBlock extends DisableableShaderBlock {
87
+ /**
88
+ * Instantiates a new Block.
89
+ * @param smartFilter - The smart filter this block belongs to
90
+ * @param name - The friendly name of the block
91
+ */
92
+ constructor(smartFilter, name) {
93
+ super(smartFilter, name, true);
94
+ /**
95
+ * The background texture to composite on to.
96
+ */
97
+ this.background = this._registerInput(uniforms.background, ConnectionPointType.Texture);
98
+ /**
99
+ * The foreground texture to composite in.
100
+ */
101
+ this.foreground = this._registerOptionalInput(uniforms.foreground, ConnectionPointType.Texture, createStrongRef(null));
102
+ /**
103
+ * Defines where the top of the texture to composite in should be displayed. (between 0 and 1).
104
+ */
105
+ this.foregroundTop = this._registerOptionalInput("foregroundTop", ConnectionPointType.Float, createStrongRef(0.0));
106
+ /**
107
+ * Defines where the left of the texture to composite in should be displayed. (between 0 and 1).
108
+ */
109
+ this.foregroundLeft = this._registerOptionalInput("foregroundLeft", ConnectionPointType.Float, createStrongRef(0.0));
110
+ /**
111
+ * Defines the width of the texture in the composition.
112
+ */
113
+ this.foregroundWidth = this._registerOptionalInput("foregroundWidth", ConnectionPointType.Float, createStrongRef(1.0));
114
+ /**
115
+ * Defines the height of the texture in the composition.
116
+ */
117
+ this.foregroundHeight = this._registerOptionalInput("foregroundHeight", ConnectionPointType.Float, createStrongRef(1.0));
118
+ /**
119
+ * Defines a multiplier applied to the foreground's alpha channel.
120
+ */
121
+ this.foregroundAlphaScale = this._registerOptionalInput(uniforms.foregroundAlphaScale, ConnectionPointType.Float, createStrongRef(1.0));
122
+ /**
123
+ * Defines blend mode of the composition.
124
+ */
125
+ this.alphaMode = ALPHA_COMBINE;
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
+ getShaderBinding() {
132
+ const background = this._confirmRuntimeDataSupplied(this.background);
133
+ const foreground = this._confirmRuntimeDataSupplied(this.foreground);
134
+ const foregroundWidth = this.foregroundWidth.runtimeData;
135
+ const foregroundLeft = this.foregroundLeft.runtimeData;
136
+ const foregroundHeight = this.foregroundHeight.runtimeData;
137
+ const foregroundTop = this.foregroundTop.runtimeData;
138
+ const foregroundAlphaScale = this.foregroundAlphaScale.runtimeData;
139
+ const alphaMode = this.alphaMode;
140
+ return new CompositionShaderBinding(this, background, foreground, foregroundTop, foregroundLeft, foregroundWidth, foregroundHeight, foregroundAlphaScale, alphaMode);
141
+ }
142
+ }
143
+ /**
144
+ * The class name of the block.
145
+ */
146
+ CompositionBlock.ClassName = compositionBlockType;
147
+ /**
148
+ * The namespace of the block.
149
+ */
150
+ CompositionBlock.Namespace = babylonDemoEffectsNamespace;
151
+ /**
152
+ * The shader program (vertex and fragment code) to use to render the block
153
+ */
154
+ CompositionBlock.ShaderCode = shaderProgram;
155
+ __decorate([
156
+ editableInPropertyPage("Alpha Mode", PropertyTypeForEdition.List, "PROPERTIES", {
157
+ notifiers: { rebuild: true },
158
+ options: [
159
+ { label: "Disable", value: ALPHA_DISABLE },
160
+ { label: "Add", value: ALPHA_ADD },
161
+ { label: "Combine", value: ALPHA_COMBINE },
162
+ { label: "Subtract", value: ALPHA_SUBTRACT },
163
+ { label: "Multiply", value: ALPHA_MULTIPLY },
164
+ ],
165
+ })
166
+ ], CompositionBlock.prototype, "alphaMode", void 0);
167
+ //# sourceMappingURL=compositionBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compositionBlock.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EAEnB,sBAAsB,EAEtB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEzE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG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C,WAAW,CAAC;QACrD,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC;QACnE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEjC,OAAO,IAAI,wBAAwB,CAC/B,IAAI,EACJ,UAAU,EACV,UAAU,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,CACZ,CAAC;IACN,CAAC;;AA3HD;;GAEG;AACoB,0BAAS,GAAG,oBAAoB,AAAvB,CAAwB;AAExD;;GAEG;AACoB,0BAAS,GAAG,2BAA2B,AAA9B,CAA+B;AA4E/D;;GAEG;AACoB,2BAAU,GAAG,aAAa,AAAhB,CAAiB;AAL3C;IAVN,sBAAsB,CAAC,YAAY,EAAE,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE;QAC7E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE;YAC1C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;YAClC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE;YAC1C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;YAC5C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;SAC/C;KACJ,CAAC;mDACuC"}
@@ -0,0 +1,6 @@
1
+ import type { IBlockSerializerV1 } from "@babylonjs/smart-filters";
2
+ /**
3
+ * The V1 serializer for a Composition Block
4
+ */
5
+ export declare const compositionBlockSerializer: IBlockSerializerV1;
6
+ //# sourceMappingURL=compositionBlock.serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compositionBlock.serializer.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.serializer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,0BAA0B,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,kBAmBxC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { compositionBlockType } from "../../../blockTypes.js";
2
+ import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
3
+ /**
4
+ * The V1 serializer for a Composition Block
5
+ */
6
+ export const compositionBlockSerializer = {
7
+ blockType: compositionBlockType,
8
+ serialize: (block) => {
9
+ if (block.getClassName() !== compositionBlockType) {
10
+ throw new Error("Was asked to serialize an unrecognized block type");
11
+ }
12
+ const compositionBlock = block;
13
+ return {
14
+ name: block.name,
15
+ uniqueId: block.uniqueId,
16
+ blockType: compositionBlockType,
17
+ namespace: babylonDemoEffectsNamespace,
18
+ comments: block.comments,
19
+ data: {
20
+ alphaMode: compositionBlock.alphaMode,
21
+ },
22
+ };
23
+ },
24
+ };
25
+ //# sourceMappingURL=compositionBlock.serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compositionBlock.serializer.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/compositionBlock.serializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAG1E;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAuB;IAC1D,SAAS,EAAE,oBAAoB;IAC/B,SAAS,EAAE,CAAC,KAAgB,EAAE,EAAE;QAC5B,IAAI,KAAK,CAAC,YAAY,EAAE,KAAK,oBAAoB,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,gBAAgB,GAAG,KAAoC,CAAC;QAC9D,OAAO;YACH,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,oBAAoB;YAC/B,SAAS,EAAE,2BAA2B;YACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE;gBACF,SAAS,EAAE,gBAAgB,CAAC,SAAS;aACxC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { DisableableShaderBinding, ConnectionPointType, type SmartFilter, DisableableShaderBlock, type ShaderProgram } from "@babylonjs/smart-filters";
2
+ /**
3
+ * The implementation of the ContrastBlock
4
+ */
5
+ export declare class ContrastBlock 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("@babylonjs/smart-filters").ConnectionPoint<ConnectionPointType.Texture>;
18
+ /**
19
+ /**
20
+ * The intensity connection point.
21
+ */
22
+ readonly intensity: import("@babylonjs/smart-filters/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 ContrastBlock.
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=contrastBlock.block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrastBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/contrastBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EACnB,KAAK,WAAW,EAChB,sBAAsB,EACtB,KAAK,aAAa,EAGG,MAAM,0BAA0B,CAAC;AAwG1D;;GAEG;AACH,qBAAa,aAAc,SAAQ,sBAAsB;IACrD;;OAEG;IACH,OAAuB,SAAS,SAAmB;IAEnD;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D;;OAEG;IACH,SAAgB,KAAK,kFAAoE;IAEzF;;;OAGG;IACH,SAAgB,SAAS,sIAIvB;IAEF;;OAEG;IACH,OAAuB,UAAU,gBAAiB;IAElD;;;;OAIG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAIlD;;;OAGG;IACI,gBAAgB,IAAI,wBAAwB;CAMtD"}
@@ -0,0 +1,140 @@
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 "@babylonjs/smart-filters";
6
+ /**
7
+ * The shader program for the block.
8
+ */
9
+ const shaderProgram = {
10
+ vertex: undefined,
11
+ fragment: {
12
+ uniform: `
13
+ uniform sampler2D _input_; // main
14
+ uniform float _intensity_;`,
15
+ mainInputTexture: "_input_",
16
+ mainFunctionName: "_contrast_",
17
+ functions: [
18
+ {
19
+ name: "_contrast_",
20
+ code: `
21
+ vec4 _contrast_(vec2 vUV) {
22
+ vec4 color = texture2D(_input_, vUV);
23
+
24
+ float contrastLMin = mix(-2., 0., _intensity_ * 2.0);
25
+ float contrastLMax = mix(3., 1., _intensity_ * 2.0);
26
+
27
+ vec3 contrastMin = _remap_(color.rgb, contrastLMin, contrastLMax, 0., 1.);
28
+
29
+ float intensityMapped = _remap_(_intensity_, 0.5, 1., 0., 1.0);
30
+ float contrastHMin = mix(0., 0.45, intensityMapped);
31
+ float contrastHMax = mix(1., 0.5, intensityMapped);
32
+
33
+ vec3 contrastMax = _remap_(color.rgb, contrastHMin, contrastHMax, 0., 1.);
34
+
35
+ return vec4(mix(contrastMin, contrastMax, step(_intensity_, 0.5)), color.a);
36
+ }
37
+
38
+ `,
39
+ params: "vec2 vUV",
40
+ },
41
+ {
42
+ name: "_remap_",
43
+ code: `
44
+ float _remap_(float i, float smin, float smax, float dmin, float dmax) {
45
+ return dmin + (i - smin) * (dmax - dmin) / (smax - smin);
46
+ }
47
+
48
+ `,
49
+ params: "float i, float smin, float smax, float dmin, float dmax",
50
+ },
51
+ {
52
+ name: "_remap_",
53
+ code: `
54
+ vec3 _remap_(vec3 i, float smin, float smax, float dmin, float dmax) {
55
+ return dmin + (i - smin) * (dmax - dmin) / (smax - smin);
56
+ }
57
+
58
+ `,
59
+ params: "vec3 i, float smin, float smax, float dmin, float dmax",
60
+ },
61
+ ],
62
+ },
63
+ };
64
+ /**
65
+ * The uniform names for this shader, to be used in the shader binding so
66
+ * that the names are always in sync.
67
+ */
68
+ const uniforms = {
69
+ input: "input",
70
+ intensity: "intensity",
71
+ };
72
+ /**
73
+ * The shader binding for the ContrastBlock, used by the runtime
74
+ */
75
+ class ContrastBlockShaderBinding extends DisableableShaderBinding {
76
+ /**
77
+ * Creates a new shader binding instance for the block.
78
+ * @param parentBlock - IDisableableBlock
79
+ * @param input - The input runtime value
80
+ * @param intensity - The intensity runtime value
81
+ */
82
+ constructor(parentBlock, input, intensity) {
83
+ super(parentBlock);
84
+ this._input = input;
85
+ this._intensity = intensity;
86
+ }
87
+ /**
88
+ * Binds all the required data to the shader when rendering.
89
+ * @param effect - defines the effect to bind the data to
90
+ */
91
+ bind(effect) {
92
+ super.bind(effect);
93
+ effect.setTexture(this.getRemappedName(uniforms.input), this._input.value);
94
+ effect.setFloat(this.getRemappedName(uniforms.intensity), this._intensity.value);
95
+ }
96
+ }
97
+ /**
98
+ * The implementation of the ContrastBlock
99
+ */
100
+ export class ContrastBlock extends DisableableShaderBlock {
101
+ /**
102
+ * Instantiates a new ContrastBlock.
103
+ * @param smartFilter - The smart filter this block belongs to
104
+ * @param name - The friendly name of the block
105
+ */
106
+ constructor(smartFilter, name) {
107
+ super(smartFilter, name, false, BlockDisableStrategy.AutoSample);
108
+ /**
109
+ * The input connection point.
110
+ */
111
+ this.input = this._registerInput(uniforms.input, ConnectionPointType.Texture);
112
+ /**
113
+ /**
114
+ * The intensity connection point.
115
+ */
116
+ this.intensity = this._registerOptionalInput("intensity", ConnectionPointType.Float, createStrongRef(0.5));
117
+ }
118
+ /**
119
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
120
+ * @returns The class instance that binds the data to the effect
121
+ */
122
+ getShaderBinding() {
123
+ const input = this._confirmRuntimeDataSupplied(this.input);
124
+ const intensity = this._confirmRuntimeDataSupplied(this.intensity);
125
+ return new ContrastBlockShaderBinding(this, input, intensity);
126
+ }
127
+ }
128
+ /**
129
+ * The class name of the block.
130
+ */
131
+ ContrastBlock.ClassName = "ContrastBlock";
132
+ /**
133
+ * The namespace of the block.
134
+ */
135
+ ContrastBlock.Namespace = "Babylon.Demo.Effects";
136
+ /**
137
+ * The shader program (vertex and fragment code) to use to render the block
138
+ */
139
+ ContrastBlock.ShaderCode = shaderProgram;
140
+ //# sourceMappingURL=contrastBlock.block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrastBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/contrastBlock.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,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,aAAa,GAAkB;IACjC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;uCAEsB;QAC/B,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,YAAY;QAC9B,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE;;;;;;;;;;;;;;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AC,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,0BAA0B,CAAC,IAAI,EAAC,KAAK,EAAC,SAAS,CAAC,CAAC;IAChE,CAAC;;AAhDD;;GAEG;AACoB,uBAAS,GAAG,eAAe,AAAlB,CAAmB;AAEnD;;GAEG;AACoB,uBAAS,GAAG,sBAAsB,AAAzB,CAA0B;AAiB1D;;GAEG;AACoB,wBAAU,GAAG,aAAa,AAAhB,CAAiB"}
@@ -0,0 +1,39 @@
1
+ import { DisableableShaderBinding, ConnectionPointType, type SmartFilter, DisableableShaderBlock, type ShaderProgram } from "@babylonjs/smart-filters";
2
+ /**
3
+ * The implementation of the DesaturateBlock
4
+ */
5
+ export declare class DesaturateBlock 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("@babylonjs/smart-filters").ConnectionPoint<ConnectionPointType.Texture>;
18
+ /**
19
+ /**
20
+ * The intensity connection point.
21
+ */
22
+ readonly intensity: import("@babylonjs/smart-filters/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 DesaturateBlock.
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=desaturateBlock.block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"desaturateBlock.block.d.ts","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/desaturateBlock.block.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,wBAAwB,EAExB,mBAAmB,EACnB,KAAK,WAAW,EAChB,sBAAsB,EACtB,KAAK,aAAa,EAGG,MAAM,0BAA0B,CAAC;AA+E1D;;GAEG;AACH,qBAAa,eAAgB,SAAQ,sBAAsB;IACvD;;OAEG;IACH,OAAuB,SAAS,SAAqB;IAErD;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D;;OAEG;IACH,SAAgB,KAAK,kFAAoE;IAEzF;;;OAGG;IACH,SAAgB,SAAS,sIAIvB;IAEF;;OAEG;IACH,OAAuB,UAAU,gBAAiB;IAElD;;;;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 "@babylonjs/smart-filters";
6
+ /**
7
+ * The shader program for the block.
8
+ */
9
+ const shaderProgram = {
10
+ vertex: undefined,
11
+ fragment: {
12
+ uniform: `
13
+ uniform sampler2D _input_; // main
14
+ uniform float _intensity_;`,
15
+ mainInputTexture: "_input_",
16
+ mainFunctionName: "_desaturate_",
17
+ functions: [
18
+ {
19
+ name: "_desaturate_",
20
+ code: `
21
+ vec4 _desaturate_(vec2 vUV) {
22
+ float saturationStrength = 1. - _intensity_;
23
+
24
+ vec4 color = texture2D(_input_, vUV);
25
+
26
+ float tempMin = min(min(color.x, color.y), color.z);
27
+ float tempMax = max(max(color.x, color.y), color.z);
28
+ float tempMerge = 0.5 * (tempMin + tempMax);
29
+
30
+ return vec4(mix(color.rgb, vec3(tempMerge, tempMerge, tempMerge), saturationStrength), color.a);
31
+ }
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 DesaturateBlock, used by the runtime
49
+ */
50
+ class DesaturateBlockShaderBinding 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 DesaturateBlock
74
+ */
75
+ export class DesaturateBlock extends DisableableShaderBlock {
76
+ /**
77
+ * Instantiates a new DesaturateBlock.
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 DesaturateBlockShaderBinding(this, input, intensity);
101
+ }
102
+ }
103
+ /**
104
+ * The class name of the block.
105
+ */
106
+ DesaturateBlock.ClassName = "DesaturateBlock";
107
+ /**
108
+ * The namespace of the block.
109
+ */
110
+ DesaturateBlock.Namespace = "Babylon.Demo.Effects";
111
+ /**
112
+ * The shader program (vertex and fragment code) to use to render the block
113
+ */
114
+ DesaturateBlock.ShaderCode = shaderProgram;
115
+ //# sourceMappingURL=desaturateBlock.block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"desaturateBlock.block.js","sourceRoot":"","sources":["../../../../../src/blocks/babylon/demo/effects/desaturateBlock.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,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,aAAa,GAAkB;IACjC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;;uCAEsB;QAC/B,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,cAAc;QAChC,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE;;;;;;;;;;;;;qBAaD;gBACL,MAAM,EAAE,UAAU;aACrB;SACJ;KACJ;CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG;IAC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