@babylonjs/smart-filters 0.5.0-alpha → 0.6.1-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/blocks/baseBlock.d.ts +6 -0
- package/dist/blocks/baseBlock.d.ts.map +1 -1
- package/dist/blocks/baseBlock.js +8 -0
- package/dist/blocks/baseBlock.js.map +1 -1
- package/dist/blocks/customShaderBlock.d.ts +55 -0
- package/dist/blocks/customShaderBlock.d.ts.map +1 -0
- package/dist/blocks/customShaderBlock.js +139 -0
- package/dist/blocks/customShaderBlock.js.map +1 -0
- package/dist/blocks/inputBlock.deserializer.d.ts +1 -1
- package/dist/blocks/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blocks/inputBlock.serializer.d.ts +1 -1
- package/dist/blocks/inputBlock.serializer.d.ts.map +1 -1
- package/dist/blocks/inputBlock.serializer.js +3 -3
- package/dist/blocks/inputBlock.serializer.js.map +1 -1
- package/dist/blocks/shaderBlock.js +2 -2
- package/dist/blocks/shaderBlock.js.map +1 -1
- package/dist/command/command.d.ts +2 -3
- package/dist/command/command.d.ts.map +1 -1
- package/dist/command/command.js.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/connection/connectionPointType.d.ts +4 -0
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +3 -3
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/serialization/importCustomShaderBlockDefinition.d.ts +11 -0
- package/dist/serialization/importCustomShaderBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/importCustomShaderBlockDefinition.js +80 -0
- package/dist/serialization/importCustomShaderBlockDefinition.js.map +1 -0
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +1 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +7 -0
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/serializedBlockDefinition.js +2 -0
- package/dist/serialization/serializedBlockDefinition.js.map +1 -0
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +12 -4
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +63 -34
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/serialization/smartFilterSerializer.d.ts +2 -2
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterSerializer.js +9 -6
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/blockSerialization.types.d.ts +55 -0
- package/dist/serialization/v1/blockSerialization.types.d.ts.map +1 -0
- package/dist/serialization/v1/blockSerialization.types.js +7 -0
- package/dist/serialization/v1/blockSerialization.types.js.map +1 -0
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -1
- package/dist/serialization/v1/index.d.ts +1 -1
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +1 -1
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/{serialization.types.d.ts → smartFilterSerialization.types.d.ts} +12 -11
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -0
- package/dist/serialization/v1/smartFilterSerialization.types.js +2 -0
- package/dist/serialization/v1/smartFilterSerialization.types.js.map +1 -0
- package/dist/utils/buildTools/buildShaders.js +1 -1
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.d.ts +13 -0
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.d.ts.map +1 -0
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.js +116 -0
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.js.map +1 -0
- package/dist/utils/buildTools/shaderCode.types.d.ts +43 -0
- package/dist/utils/buildTools/shaderCode.types.d.ts.map +1 -0
- package/dist/utils/buildTools/shaderCode.types.js +2 -0
- package/dist/utils/buildTools/shaderCode.types.js.map +1 -0
- package/dist/utils/buildTools/shaderConverter.d.ts +56 -8
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +87 -137
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +2 -2
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/renderTargetUtils.js +3 -3
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +1 -42
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +19 -15
- package/src/blocks/baseBlock.ts +9 -0
- package/src/blocks/customShaderBlock.ts +217 -0
- package/src/blocks/inputBlock.deserializer.ts +1 -1
- package/src/blocks/inputBlock.serializer.ts +4 -4
- package/src/blocks/shaderBlock.ts +2 -2
- package/src/command/command.ts +2 -3
- package/src/command/commandBufferDebugger.ts +1 -1
- package/src/connection/connectionPointType.ts +11 -0
- package/src/index.ts +2 -0
- package/src/optimization/smartFilterOptimizer.ts +3 -3
- package/src/serialization/importCustomShaderBlockDefinition.ts +85 -0
- package/src/serialization/index.ts +1 -0
- package/src/serialization/serializedBlockDefinition.ts +7 -0
- package/src/serialization/serializedSmartFilter.ts +1 -1
- package/src/serialization/smartFilterDeserializer.ts +106 -52
- package/src/serialization/smartFilterSerializer.ts +11 -7
- package/src/serialization/v1/blockSerialization.types.ts +63 -0
- package/src/serialization/v1/defaultBlockSerializer.ts +2 -2
- package/src/serialization/v1/index.ts +1 -1
- package/src/serialization/v1/{serialization.types.ts → smartFilterSerialization.types.ts} +11 -10
- package/src/utils/buildTools/buildShaders.ts +1 -1
- package/src/utils/buildTools/convertShaderForHardcodedBlock.ts +149 -0
- package/src/utils/buildTools/shaderCode.types.ts +49 -0
- package/src/utils/buildTools/shaderConverter.ts +158 -178
- package/src/utils/buildTools/watchShaders.ts +2 -2
- package/src/utils/renderTargetUtils.ts +3 -3
- package/src/utils/shaderCodeUtils.ts +1 -50
- package/dist/serialization/v1/serialization.types.d.ts.map +0 -1
- package/dist/serialization/v1/serialization.types.js +0 -2
- package/dist/serialization/v1/serialization.types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderConverter.js","sourceRoot":"","sources":["../../../src/utils/buildTools/shaderConverter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shaderConverter.js","sourceRoot":"","sources":["../../../src/utils/buildTools/shaderConverter.ts"],"names":[],"mappings":"AAGA,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAyDrD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,cAAsB;IACtD,MAAM,EAAE,MAAM,EAAE,2BAA2B,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3E,cAAc,GAAG,2BAA2B,CAAC;IAC7C,MAAM,SAAS,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,uBAAuB,CAAC,KAAI,SAAS,CAAC;IAEjE,oBAAoB;IACpB,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,kDAAkD,CAAC,CAAC;IACrF,MAAM,aAAa,GAAG,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC7D,KAAK,MAAM,OAAO,IAAI,aAAa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xF,IAAI,oBAAoB,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO;YACH,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClD,2BAA2B,EAAE,cAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SACnF,CAAC;IACN,CAAC;IAED,OAAO;QACH,MAAM,EAAE,IAAI;QACZ,2BAA2B,EAAE,cAAc;KAC9C,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,cAAsB;IAChD,OAAO,cAAc,CAAC,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param importPath - The path to import the converted shaders
|
|
6
6
|
* @example node watchShaders.js <shaderPath> <importPath>
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { convertShaderForHardcodedBlock } from "./convertShaderForHardcodedBlock.js";
|
|
9
9
|
import { watch } from "chokidar";
|
|
10
10
|
import { extname } from "path";
|
|
11
11
|
const externalArguments = process.argv.slice(2);
|
|
@@ -24,7 +24,7 @@ if (externalArguments.length >= 2 && externalArguments[0] && externalArguments[1
|
|
|
24
24
|
// Wrap in try-catch to prevent the watcher from crashing
|
|
25
25
|
// if the new shader changes are invalid
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
convertShaderForHardcodedBlock(file, importPath);
|
|
28
28
|
console.log(`Successfully updated shader ${file}`);
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchShaders.js","sourceRoot":"","sources":["../../../src/utils/buildTools/watchShaders.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file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CAAC;AAChE,CAAC"}
|
|
@@ -22,14 +22,14 @@ export function getRenderTargetWrapper(renderTargetTexture, callerName) {
|
|
|
22
22
|
* @param shaderBlockRuntime - The shader block runtime to use.
|
|
23
23
|
*/
|
|
24
24
|
export function registerFinalRenderCommand(renderTargetWrapper, runtime, commandOwner, shaderBlockRuntime) {
|
|
25
|
-
const
|
|
25
|
+
const commandOwnerBlockType = commandOwner.blockType;
|
|
26
26
|
if (renderTargetWrapper) {
|
|
27
|
-
runtime.registerCommand(createCommand(`${
|
|
27
|
+
runtime.registerCommand(createCommand(`${commandOwnerBlockType}.renderToFinalTexture`, commandOwner, () => {
|
|
28
28
|
shaderBlockRuntime.renderToTexture(renderTargetWrapper);
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
runtime.registerCommand(createCommand(`${
|
|
32
|
+
runtime.registerCommand(createCommand(`${commandOwnerBlockType}.renderToCanvas`, commandOwner, () => {
|
|
33
33
|
shaderBlockRuntime.renderToCanvas();
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTargetUtils.js","sourceRoot":"","sources":["../../src/utils/renderTargetUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMtD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAClC,mBAAsD,EACtD,UAAkB;IAElB,MAAM,YAAY,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,YAAY,CAAC;IACvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,0CAA0C,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,YAAY,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACtC,mBAAkD,EAClD,OAAmC,EACnC,YAAuB,EACvB,kBAAiC;IAEjC,MAAM,qBAAqB,GAAG,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"renderTargetUtils.js","sourceRoot":"","sources":["../../src/utils/renderTargetUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMtD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAClC,mBAAsD,EACtD,UAAkB;IAElB,MAAM,YAAY,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,YAAY,CAAC;IACvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,0CAA0C,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,YAAY,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACtC,mBAAkD,EAClD,OAAmC,EACnC,YAAuB,EACvB,kBAAiC;IAEjC,MAAM,qBAAqB,GAAG,YAAY,CAAC,SAAS,CAAC;IACrD,IAAI,mBAAmB,EAAE,CAAC;QACtB,OAAO,CAAC,eAAe,CACnB,aAAa,CAAC,GAAG,qBAAqB,uBAAuB,EAAE,YAAY,EAAE,GAAG,EAAE;YAC9E,kBAAkB,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QAC5D,CAAC,CAAC,CACL,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,eAAe,CACnB,aAAa,CAAC,GAAG,qBAAqB,iBAAiB,EAAE,YAAY,EAAE,GAAG,EAAE;YACxE,kBAAkB,CAAC,cAAc,EAAE,CAAC;QACxC,CAAC,CAAC,CACL,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -1,51 +1,10 @@
|
|
|
1
1
|
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
+
import type { ShaderCode } from "./buildTools/shaderCode.types";
|
|
2
3
|
/**
|
|
3
4
|
* The shader code decorator.
|
|
4
5
|
* Used to decorate the names of uniform, function and const variables for easier parsing.
|
|
5
6
|
*/
|
|
6
7
|
export declare const decorateChar = "_";
|
|
7
|
-
/**
|
|
8
|
-
* Describes a shader function.
|
|
9
|
-
*/
|
|
10
|
-
export type ShaderFunction = {
|
|
11
|
-
/**
|
|
12
|
-
* The name of the function.
|
|
13
|
-
*/
|
|
14
|
-
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* The code of the function.
|
|
17
|
-
*/
|
|
18
|
-
code: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Describes a shader code.
|
|
22
|
-
*/
|
|
23
|
-
export type ShaderCode = {
|
|
24
|
-
/**
|
|
25
|
-
* The declaration of the const variables.
|
|
26
|
-
*/
|
|
27
|
-
const?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The declaration of the uniform variables.
|
|
30
|
-
*/
|
|
31
|
-
uniform?: string;
|
|
32
|
-
/**
|
|
33
|
-
* The declaration of the uniform variables that should be common for all ShaderBlock instances using this shader code.
|
|
34
|
-
*/
|
|
35
|
-
uniformSingle?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The name of the main function.
|
|
38
|
-
*/
|
|
39
|
-
mainFunctionName: string;
|
|
40
|
-
/**
|
|
41
|
-
* The name of the input texture which is passed through if the block is disabled.
|
|
42
|
-
*/
|
|
43
|
-
mainInputTexture?: string;
|
|
44
|
-
/**
|
|
45
|
-
* The list of functions used in the shader.
|
|
46
|
-
*/
|
|
47
|
-
functions: ShaderFunction[];
|
|
48
|
-
};
|
|
49
8
|
/**
|
|
50
9
|
* Describes a shader program.
|
|
51
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderCodeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/shaderCodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"shaderCodeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/shaderCodeUtils.ts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B,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderCodeUtils.js","sourceRoot":"","sources":["../../src/utils/shaderCodeUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shaderCodeUtils.js","sourceRoot":"","sources":["../../src/utils/shaderCodeUtils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAwDhC,MAAM,CAAC,MAAM,6BAA6B,GAAG,oBAAoB,CAAC;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,aAA4B;IACpE,MAAM,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC;IAE9C,6BAA6B;IAC7B,cAAc,CAAC,OAAO,IAAI,kBAAkB,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC;IAE9E,yBAAyB;IACzB,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACtG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACX,mEAAmE,cAAc,CAAC,gBAAgB,EAAE,CACvG,CAAC;IACN,CAAC;IAED,6CAA6C;IAC7C,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACX,wEAAwE,cAAc,CAAC,gBAAgB,EAAE,CAC5G,CAAC;IACN,CAAC;IAED,kBAAkB;IAClB,MAAM,uBAAuB,GAAG,cAAc,CAAC,6BAA6B,CAAC,CAAC;IAC9E,YAAY,CAAC,IA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CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IACzC,OAAO,YAAY,GAAG,MAAM,GAAG,YAAY,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC3C,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC;QACzF,MAAM,IAAI,KAAK,CAAC,0CAA0C,MAAM,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -16,7 +16,7 @@ This can be installed with `npm install @babylonjs/smart-filters`.
|
|
|
16
16
|
|
|
17
17
|
It requires the following peer dependencies:
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- @babylonjs/core
|
|
20
20
|
|
|
21
21
|
## How to use
|
|
22
22
|
|
|
@@ -48,23 +48,23 @@ The notion of a `SmartFilter` is a graph of blocks (all inheriting from `BaseBlo
|
|
|
48
48
|
|
|
49
49
|
During the initialization phase, the `SmartFilter` examines the graph and builds a list of commands to execute during each frame and stores them in a `CommandBuffer`:
|
|
50
50
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
51
|
+
- This keeps each frame render very fast by ensuring the work is branchless.
|
|
52
|
+
- Basically, every `BaseBlock` during its `initialize` step will register in the `CommandBuffer` only the work it has to execute according to its options.
|
|
53
|
+
- In the end the render loop it only needs to run and execute each command in the list.
|
|
54
|
+
- This also allows for easy injection of debug tools or logging in between each command without growing the minimum required code to run a filter.
|
|
55
|
+
- As discussed, the `Blocks` are responsible for "injecting" their command in the filter `CommandBuffer`.
|
|
56
|
+
- For example: the `ShaderBlock` highlights how convenient it can be to only switch once at init time between rendering to the main frame buffer (if linked to the output) or to an intermediate texture if in the middle of the chain.
|
|
57
57
|
|
|
58
58
|
Each block is responsible for exposing their inputs and outputs through `registerInput` and `registerOutput`:
|
|
59
59
|
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
60
|
+
- This creates and stores the related `ConnectionPoint`.
|
|
61
|
+
- All property values of a block must be updated only before `initialize` is called as the runtime won't reference it at render time.
|
|
62
|
+
- All values that need to be dynamically updated after `initialize` must be defined as connection points or 'StrongRef'.
|
|
63
63
|
|
|
64
64
|
The `ConnectionPoints` are:
|
|
65
65
|
|
|
66
|
-
-
|
|
67
|
-
-
|
|
66
|
+
- Strongly typed, allowing more type safety while creating `SmartFilter` by code, yet keeping enough flexibility to be understood efficiently at runtime.
|
|
67
|
+
- They are also responsible for their compatibility when linked to each other.
|
|
68
68
|
|
|
69
69
|
The Smart Filter is fully abstracted away from the runtime notion and does not even require a Babylon Engine to work with. It is only responsible to hold the "graph" of the filter or the "map" of all its blocks. A Filter only needs a name to be created:
|
|
70
70
|
|
|
@@ -160,14 +160,15 @@ _Note_ The runtime should be disposed once it is not used anymore to free the GP
|
|
|
160
160
|
|
|
161
161
|
The overall system is trying at best to follow 3 simple rules:
|
|
162
162
|
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
163
|
+
- Be CPU efficient: for instance, we are trying to be branchless in most of our commands and we try to keep the number of commands as low as possible.
|
|
164
|
+
- Be memory efficient: no commands should allocate memory as it could trigger some garbage collection at the expense of frame loss.
|
|
165
|
+
- Be GPU efficient: the graph and texture optimizers minimize the number of "passes" required to render an image and the GPU resources used by the graph.
|
|
166
166
|
|
|
167
167
|
## Requirements for GLSL code
|
|
168
168
|
|
|
169
169
|
To be imported into blocks, the following requirements must be met by .glsl files:
|
|
170
170
|
|
|
171
|
+
1. The file must start with a multiline comment that contains a JSON encoded GlslHeader object
|
|
171
172
|
1. There must be a sampler2D uniform designed as the main input texture (the one to be passed along) if this block is disabled. It must have a comment on its line like this:
|
|
172
173
|
`// main`
|
|
173
174
|
1. There must be a single main function which takes in a vec2 named vUV and returns a vec4, and it must have a comment on its line like this:
|
|
@@ -175,3 +176,6 @@ To be imported into blocks, the following requirements must be met by .glsl file
|
|
|
175
176
|
1. Any uniforms which should have the same value across all instances of the same block should have a comment on its line like this:
|
|
176
177
|
`// single`
|
|
177
178
|
1. Functions must be declared with the open { on the same line as the function name
|
|
179
|
+
1. Uniforms can have metadata, such as a default value if no connection is made to their corresponding connection point
|
|
180
|
+
- In the line immediately above the uniform declaration, start with a // comment followed by a JSON object
|
|
181
|
+
- The supported metadata is described in the UniformMetadataProperties type
|
package/src/blocks/baseBlock.ts
CHANGED
|
@@ -44,6 +44,15 @@ export abstract class BaseBlock implements ICommandOwner {
|
|
|
44
44
|
*/
|
|
45
45
|
public readonly name: string;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
49
|
+
* For programmatically created blocks, this should be the class name of the block.
|
|
50
|
+
* For custom blocks, this is specified in the block definition.
|
|
51
|
+
*/
|
|
52
|
+
public get blockType(): string {
|
|
53
|
+
return this.getClassName();
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* User provided comments about the block. It can be used to document the block.
|
|
49
58
|
*/
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { Effect } from "@babylonjs/core/Materials/effect";
|
|
2
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
import { ShaderBinding } from "../runtime/shaderRuntime.js";
|
|
4
|
+
import { createStrongRef } from "../runtime/strongRef.js";
|
|
5
|
+
import type { SerializedBlockDefinition } from "../serialization/serializedBlockDefinition";
|
|
6
|
+
import type { SerializedInputConnectionPointV1 } from "../serialization/v1/blockSerialization.types";
|
|
7
|
+
import type { SmartFilter } from "../smartFilter";
|
|
8
|
+
import type { ShaderProgram } from "../utils/shaderCodeUtils";
|
|
9
|
+
import { ShaderBlock } from "./shaderBlock.js";
|
|
10
|
+
import type { RuntimeData } from "../connection/connectionPoint";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The binding for a CustomShaderBlock
|
|
14
|
+
*/
|
|
15
|
+
class CustomShaderBlockBinding extends ShaderBinding {
|
|
16
|
+
private readonly _bindSteps: ((effect: Effect) => void)[] = [];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new shader binding instance for the CustomShaderBlock block.
|
|
20
|
+
* @param inputsWithRuntimeData - The input connection points of the block
|
|
21
|
+
*/
|
|
22
|
+
public constructor(inputsWithRuntimeData: AnyInputWithRuntimeData[]) {
|
|
23
|
+
super();
|
|
24
|
+
|
|
25
|
+
for (const input of inputsWithRuntimeData) {
|
|
26
|
+
switch (input.type) {
|
|
27
|
+
case ConnectionPointType.Float:
|
|
28
|
+
this._bindSteps.push((effect) => {
|
|
29
|
+
effect.setFloat(this.getRemappedName(input.name), input.runtimeData.value);
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
case ConnectionPointType.Texture:
|
|
33
|
+
this._bindSteps.push((effect) => {
|
|
34
|
+
effect.setTexture(this.getRemappedName(input.name), input.runtimeData.value);
|
|
35
|
+
});
|
|
36
|
+
break;
|
|
37
|
+
case ConnectionPointType.Color3:
|
|
38
|
+
this._bindSteps.push((effect) => {
|
|
39
|
+
effect.setColor3(this.getRemappedName(input.name), input.runtimeData.value);
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
case ConnectionPointType.Color4:
|
|
43
|
+
this._bindSteps.push((effect) => {
|
|
44
|
+
effect.setDirectColor4(this.getRemappedName(input.name), input.runtimeData.value);
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case ConnectionPointType.Boolean:
|
|
48
|
+
this._bindSteps.push((effect) => {
|
|
49
|
+
effect.setBool(this.getRemappedName(input.name), input.runtimeData.value);
|
|
50
|
+
});
|
|
51
|
+
break;
|
|
52
|
+
case ConnectionPointType.Vector2:
|
|
53
|
+
this._bindSteps.push((effect) => {
|
|
54
|
+
effect.setVector2(this.getRemappedName(input.name), input.runtimeData.value);
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Binds all the required data to the shader when rendering.
|
|
63
|
+
* @param effect - The effect to bind the data to
|
|
64
|
+
*/
|
|
65
|
+
public override bind(effect: Effect): void {
|
|
66
|
+
for (let i = 0; i < this._bindSteps.length; i++) {
|
|
67
|
+
this._bindSteps[i]!(effect);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A block which loads a SerializedBlockDefinition for use in a SmartFilter.
|
|
74
|
+
*/
|
|
75
|
+
export class CustomShaderBlock extends ShaderBlock {
|
|
76
|
+
/**
|
|
77
|
+
* Deserializes a CustomShaderBlock from a serialized block definition.
|
|
78
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
79
|
+
* @param name - Defines the name of the block
|
|
80
|
+
* @param blockDefinition - The serialized block definition
|
|
81
|
+
* @returns The deserialized CustomShaderBlock instance
|
|
82
|
+
*/
|
|
83
|
+
public static Create(
|
|
84
|
+
smartFilter: SmartFilter,
|
|
85
|
+
name: string,
|
|
86
|
+
blockDefinition: SerializedBlockDefinition
|
|
87
|
+
): CustomShaderBlock {
|
|
88
|
+
// When a new version of SerializedBlockDefinition is created, this function should be updated to handle the new properties.
|
|
89
|
+
|
|
90
|
+
return new CustomShaderBlock(
|
|
91
|
+
smartFilter,
|
|
92
|
+
name,
|
|
93
|
+
blockDefinition.disableOptimization,
|
|
94
|
+
blockDefinition.blockType,
|
|
95
|
+
blockDefinition.inputConnectionPoints,
|
|
96
|
+
blockDefinition.shaderProgram
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The class name of the block.
|
|
102
|
+
*/
|
|
103
|
+
public static override ClassName = "CustomShaderBlock";
|
|
104
|
+
|
|
105
|
+
private readonly _shaderProgram: ShaderProgram;
|
|
106
|
+
private readonly _blockType: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
110
|
+
*/
|
|
111
|
+
public override get blockType(): string {
|
|
112
|
+
return this._blockType;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Instantiates a new custom shader block.
|
|
117
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
118
|
+
* @param name - The name of the block
|
|
119
|
+
* @param disableOptimization - If true, this optimizer will not attempt to optimize this block
|
|
120
|
+
* @param blockType - The type of the block
|
|
121
|
+
* @param inputConnectionPoints - The input connection points of the
|
|
122
|
+
* @param shaderProgram - The shader program for the block
|
|
123
|
+
*/
|
|
124
|
+
private constructor(
|
|
125
|
+
smartFilter: SmartFilter,
|
|
126
|
+
name: string,
|
|
127
|
+
disableOptimization: boolean,
|
|
128
|
+
blockType: string,
|
|
129
|
+
inputConnectionPoints: SerializedInputConnectionPointV1[],
|
|
130
|
+
shaderProgram: ShaderProgram
|
|
131
|
+
) {
|
|
132
|
+
super(smartFilter, name, disableOptimization);
|
|
133
|
+
this._blockType = blockType;
|
|
134
|
+
|
|
135
|
+
for (const input of inputConnectionPoints) {
|
|
136
|
+
this._registerSerializedInputConnectionPointV1(input);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this._shaderProgram = shaderProgram;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Gets the shader program to use to render the block.
|
|
144
|
+
* @returns The shader program to use to render the block
|
|
145
|
+
*/
|
|
146
|
+
public override getShaderProgram() {
|
|
147
|
+
return this._shaderProgram;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Checks a specific input connection point type to see if it has a default value, and registers the input
|
|
152
|
+
* connection point accordingly.
|
|
153
|
+
* @param connectionPoint - The input connection point to register
|
|
154
|
+
*/
|
|
155
|
+
private _registerSerializedInputConnectionPointV1<U extends ConnectionPointType>(
|
|
156
|
+
connectionPoint: SerializedInputConnectionPointV1<U>
|
|
157
|
+
): void {
|
|
158
|
+
if (connectionPoint.defaultValue !== undefined) {
|
|
159
|
+
this._registerOptionalInput(
|
|
160
|
+
connectionPoint.name,
|
|
161
|
+
connectionPoint.type,
|
|
162
|
+
createStrongRef(connectionPoint.defaultValue)
|
|
163
|
+
);
|
|
164
|
+
} else {
|
|
165
|
+
this._registerInput(connectionPoint.name, connectionPoint.type);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Gets the shader binding for the custom shader block.
|
|
171
|
+
* @returns The shader binding for the custom shader block
|
|
172
|
+
*/
|
|
173
|
+
public override getShaderBinding(): ShaderBinding {
|
|
174
|
+
const inputs = this.inputs;
|
|
175
|
+
|
|
176
|
+
const inputsWithRuntimeData = inputs.map((input) => {
|
|
177
|
+
return {
|
|
178
|
+
name: input.name,
|
|
179
|
+
type: input.type,
|
|
180
|
+
runtimeData: this._confirmRuntimeDataSupplied(input),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return new CustomShaderBlockBinding(inputsWithRuntimeData);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Represents an input with its runtime data, enforcing type safety.
|
|
190
|
+
*/
|
|
191
|
+
type InputWithRuntimeData<U extends ConnectionPointType> = {
|
|
192
|
+
/**
|
|
193
|
+
* The name of the input connection point
|
|
194
|
+
*/
|
|
195
|
+
name: string;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The type of the input connection point
|
|
199
|
+
*/
|
|
200
|
+
type: U;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The runtime data for the input connection point
|
|
204
|
+
*/
|
|
205
|
+
runtimeData: RuntimeData<U>;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* All possible input types with runtime data.
|
|
210
|
+
*/
|
|
211
|
+
type AnyInputWithRuntimeData =
|
|
212
|
+
| InputWithRuntimeData<ConnectionPointType.Boolean>
|
|
213
|
+
| InputWithRuntimeData<ConnectionPointType.Color3>
|
|
214
|
+
| InputWithRuntimeData<ConnectionPointType.Color4>
|
|
215
|
+
| InputWithRuntimeData<ConnectionPointType.Float>
|
|
216
|
+
| InputWithRuntimeData<ConnectionPointType.Texture>
|
|
217
|
+
| InputWithRuntimeData<ConnectionPointType.Vector2>;
|
|
@@ -2,7 +2,7 @@ import { InputBlock } from "./inputBlock.js";
|
|
|
2
2
|
import type { SerializedInputBlockData } from "./inputBlock.serialization.types.js";
|
|
3
3
|
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
4
4
|
import type { SmartFilter } from "../smartFilter.js";
|
|
5
|
-
import type { ISerializedBlockV1 } from "../serialization/v1/
|
|
5
|
+
import type { ISerializedBlockV1 } from "../serialization/v1/smartFilterSerialization.types.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* V1 Input Block Deserializer
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
TextureInputBlockData,
|
|
11
11
|
Vector2InputBlockData,
|
|
12
12
|
} from "./inputBlock.serialization.types";
|
|
13
|
-
import type { IBlockSerializerV1 } from "../serialization/v1/
|
|
13
|
+
import type { IBlockSerializerV1 } from "../serialization/v1/smartFilterSerialization.types.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Determines which generic type of InputBlock we are trying to serialize and calls the appropriate function
|
|
@@ -127,15 +127,15 @@ function serializeVector2InputBlock(inputBlock: InputBlock<ConnectionPointType.V
|
|
|
127
127
|
* The V1 serializer for an InputBlock
|
|
128
128
|
*/
|
|
129
129
|
export const inputBlockSerializer: IBlockSerializerV1 = {
|
|
130
|
-
|
|
130
|
+
blockType: InputBlockBase.ClassName,
|
|
131
131
|
serialize: (block: BaseBlock) => {
|
|
132
|
-
if (block.
|
|
132
|
+
if (block.blockType !== InputBlockBase.ClassName) {
|
|
133
133
|
throw new Error("Was asked to serialize an unrecognized block type");
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
136
136
|
name: block.name,
|
|
137
137
|
uniqueId: block.uniqueId,
|
|
138
|
-
|
|
138
|
+
blockType: InputBlockBase.ClassName,
|
|
139
139
|
comments: block.comments,
|
|
140
140
|
data: serializeInputBlockData(block as unknown as InputBlockBase),
|
|
141
141
|
};
|
|
@@ -152,11 +152,11 @@ export abstract class ShaderBlock extends BaseBlock {
|
|
|
152
152
|
} else {
|
|
153
153
|
const renderTarget = getRenderTargetWrapper(
|
|
154
154
|
this.output.runtimeData?.value as ThinRenderTargetTexture,
|
|
155
|
-
this.
|
|
155
|
+
this.blockType
|
|
156
156
|
);
|
|
157
157
|
|
|
158
158
|
runtime.registerCommand(
|
|
159
|
-
createCommand(`${this.
|
|
159
|
+
createCommand(`${this.blockType}.render`, this, () => {
|
|
160
160
|
shaderBlockRuntime.renderToTexture(renderTarget);
|
|
161
161
|
})
|
|
162
162
|
);
|
package/src/command/command.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Represents the owner of a command.
|
|
3
|
-
* In practice, it will mostly be a block, the smart filter or a tool injecting commands.
|
|
4
3
|
*/
|
|
5
4
|
export interface ICommandOwner {
|
|
6
5
|
/**
|
|
@@ -9,9 +8,9 @@ export interface ICommandOwner {
|
|
|
9
8
|
readonly name: string;
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* The blockType of the owner;
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
readonly blockType: string;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -7,7 +7,7 @@ import type { CommandBuffer } from "./commandBuffer";
|
|
|
7
7
|
export function logCommands(commandBuffer: Readonly<CommandBuffer>) {
|
|
8
8
|
console.log("----- Command buffer commands -----");
|
|
9
9
|
commandBuffer.visitCommands((command) => {
|
|
10
|
-
console.log(` Owner: ${command.owner.
|
|
10
|
+
console.log(` Owner: ${command.owner.blockType} (${command.owner.name}) - Command: ${command.name}`);
|
|
11
11
|
});
|
|
12
12
|
console.log("-----------------------------------");
|
|
13
13
|
}
|
|
@@ -20,6 +20,17 @@ export enum ConnectionPointType {
|
|
|
20
20
|
Vector2 = 6,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* A union of all supported connection point types
|
|
25
|
+
*/
|
|
26
|
+
export type AllConnectionPointTypes =
|
|
27
|
+
| ConnectionPointType.Float
|
|
28
|
+
| ConnectionPointType.Texture
|
|
29
|
+
| ConnectionPointType.Color3
|
|
30
|
+
| ConnectionPointType.Color4
|
|
31
|
+
| ConnectionPointType.Boolean
|
|
32
|
+
| ConnectionPointType.Vector2;
|
|
33
|
+
|
|
23
34
|
/**
|
|
24
35
|
* Retrieves the type of the value from the Connection point type.
|
|
25
36
|
*/
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { BaseBlock } from "./blocks/baseBlock.js";
|
|
|
20
20
|
export { InputBlock, type InputBlockEditorData } from "./blocks/inputBlock.js";
|
|
21
21
|
export { type AnyInputBlock } from "./blocks/inputBlock.js";
|
|
22
22
|
export { ShaderBlock } from "./blocks/shaderBlock.js";
|
|
23
|
+
export { CustomShaderBlock } from "./blocks/customShaderBlock.js";
|
|
23
24
|
export { DisableableShaderBlock, BlockDisableStrategy as DisableStrategy } from "./blocks/disableableShaderBlock.js";
|
|
24
25
|
export { AggregateBlock } from "./blocks/aggregateBlock.js";
|
|
25
26
|
export { DisableableShaderBinding, ShaderBinding, ShaderRuntime } from "./runtime/shaderRuntime.js";
|
|
@@ -36,3 +37,4 @@ export { SmartFilterOptimizer } from "./optimization/smartFilterOptimizer.js";
|
|
|
36
37
|
export * from "./utils/textureLoaders.js";
|
|
37
38
|
export * from "./serialization/index.js";
|
|
38
39
|
export * from "./editorUtils/editableInPropertyPage.js";
|
|
40
|
+
export * from "./serialization/importCustomShaderBlockDefinition.js";
|