@babylonjs/core 8.9.1 → 8.10.0
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/Engines/WebGPU/webgpuCacheBindGroups.js +4 -4
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +16 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -4
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.d.ts +8 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js +23 -3
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.d.ts +13 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +44 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +3 -0
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +6 -3
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialDefault.js +6 -1
- package/Materials/Node/nodeMaterialDefault.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +3 -2
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +4 -4
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +2 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FlowGraphPathConverterComponent } from "../../../flowGraphPathConverterComponent.js";
|
|
2
2
|
import { RichTypeAny } from "../../../flowGraphRichTypes.js";
|
|
3
3
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
4
|
+
import { Vector3, Vector4 } from "../../../../Maths/math.vector.js";
|
|
4
5
|
import { Color3, Color4 } from "../../../../Maths/math.color.js";
|
|
5
6
|
import { FlowGraphCachedOperationBlock } from "../flowGraphCachedOperationBlock.js";
|
|
6
7
|
/**
|
|
@@ -49,7 +50,12 @@ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlo
|
|
|
49
50
|
}
|
|
50
51
|
_getPropertyValue(_target, _propertyName, context) {
|
|
51
52
|
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
|
|
52
|
-
|
|
53
|
+
const type = accessorContainer.info.type;
|
|
54
|
+
const value = accessorContainer.info.get(accessorContainer.object);
|
|
55
|
+
if (type.startsWith("Color")) {
|
|
56
|
+
return FromColor(value);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
53
59
|
}
|
|
54
60
|
_getInterpolationAnimationPropertyInfo(_target, _propertyName, context) {
|
|
55
61
|
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
|
|
@@ -109,5 +115,14 @@ function ToColor(value, expectedValue) {
|
|
|
109
115
|
}
|
|
110
116
|
return value;
|
|
111
117
|
}
|
|
118
|
+
function FromColor(value) {
|
|
119
|
+
if (value instanceof Color3) {
|
|
120
|
+
return new Vector3(value.r, value.g, value.b);
|
|
121
|
+
}
|
|
122
|
+
else if (value instanceof Color4) {
|
|
123
|
+
return new Vector4(value.r, value.g, value.b, value.a);
|
|
124
|
+
}
|
|
125
|
+
throw new Error("Invalid color type");
|
|
126
|
+
}
|
|
112
127
|
RegisterClass("FlowGraphJsonPointerParserBlock" /* FlowGraphBlockNames.JsonPointerParser */, FlowGraphJsonPointerParserBlock);
|
|
113
128
|
//# sourceMappingURL=flowGraphJsonPointerParserBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphJsonPointerParserBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,+BAA+B,EAAE,oDAAuD;AACjG,OAAO,EAAE,WAAW,EAAE,uCAA0C;AAIhE,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAIpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,wCAA8B;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAqBjF;;;;GAIG;AACH,MAAM,OAAO,+BAA6E,SAAQ,6BAAgC;IA+B9H;IACI;;OAEG;IACa,MAAqD;QAErE,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAFX,WAAM,GAAN,MAAM,CAA+C;QAGrE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,I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;IAED;;;OAGG;IACa,YAAY;QACxB,qFAA6C;IACjD,CAAC;CACJ;AAED,SAAS,OAAO,CAAC,KAAU,EAAE,aAAqB;IAC9C,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,KAAmC,CAAC;IAC/C,CAAC;IACD,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,aAAa,gFAAwC,+BAA+B,CAAC,CAAC","sourcesContent":["import type { FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphPathConverterComponent } from \"core/FlowGraph/flowGraphPathConverterComponent\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\nimport type { IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport type { Animation } from \"core/Animations/animation\";\nimport type { EasingFunction } from \"core/Animations/easing\";\nimport type { Vector4 } from \"core/Maths/math.vector\";\nimport { Color3, Color4 } from \"core/Maths/math.color\";\nimport { FlowGraphCachedOperationBlock } from \"../flowGraphCachedOperationBlock\";\n\n/**\n * Configuration for the JSON pointer parser block.\n */\nexport interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The JSON pointer to parse.\n */\n jsonPointer: string;\n /**\n * The path converter to use to convert the path to an object accessor.\n */\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\n\n /**\n * Whether to output the value of the property.\n */\n outputValue?: boolean;\n}\n\n/**\n * This block will take a JSON pointer and parse it to get the value from the JSON object.\n * The output is an object and a property name.\n * Optionally, the block can also output the value of the property. This is configurable.\n */\nexport class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Output connection: The object that contains the property.\n */\n public readonly object: FlowGraphDataConnection<O>;\n\n /**\n * Output connection: The property name.\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Output connection: A function that can be used to update the value of the property.\n */\n public readonly setterFunction: FlowGraphDataConnection<(target: O, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n /**\n * Output connection: A function that can be used to get the value of the property.\n */\n public readonly getterFunction: FlowGraphDataConnection<(target: O, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Output connection: A function that can be used to get the interpolation animation property info.\n */\n public readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;\n\n /**\n * The component with the templated inputs for the provided path.\n */\n public readonly templateComponent: FlowGraphPathConverterComponent;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphJsonPointerParserBlockConfiguration\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataOutput(\"object\", RichTypeAny);\n this.propertyName = this.registerDataOutput(\"propertyName\", RichTypeAny);\n this.setterFunction = this.registerDataOutput(\"setFunction\", RichTypeAny, this._setPropertyValue.bind(this));\n this.getterFunction = this.registerDataOutput(\"getFunction\", RichTypeAny, this._getPropertyValue.bind(this));\n this.generateAnimationsFunction = this.registerDataOutput(\"generateAnimationsFunction\", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));\n this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);\n }\n\n public override _doOperation(context: FlowGraphContext): P {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const value = accessorContainer.info.get(accessorContainer.object) as P;\n const object = accessorContainer.info.getTarget?.(accessorContainer.object);\n const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);\n if (!object) {\n throw new Error(\"Object is undefined\");\n } else {\n this.object.setValue(object, context);\n if (propertyName) {\n this.propertyName.setValue(propertyName, context);\n }\n }\n return value;\n }\n\n private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n value = ToColor(value as Vector4, type) as unknown as P;\n }\n accessorContainer.info.set?.(value, accessorContainer.object);\n }\n\n private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return accessorContainer.info.get(accessorContainer.object);\n }\n\n private _getInterpolationAnimationPropertyInfo(\n _target: O,\n _propertyName: string,\n context: FlowGraphContext\n ): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => {\n const animations: Animation[] = [];\n // make sure keys are of the right type (in case of float3 color/vector)\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n keys = keys.map((key) => {\n return {\n frame: key.frame,\n value: ToColor(key.value, type),\n };\n });\n }\n accessorContainer.info.interpolation?.forEach((info, index) => {\n const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || \"Animation-interpolation-\" + index;\n // generate the keys based on interpolation info\n let newKeys: any[] = keys;\n if (animationType !== info.type) {\n // convert the keys to the right type\n newKeys = keys.map((key) => {\n return {\n frame: key.frame,\n value: info.getValue(undefined, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),\n };\n });\n }\n const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);\n for (const animation of animationData) {\n if (easingFunction) {\n animation.babylonAnimation.setEasingFunction(easingFunction);\n }\n animations.push(animation.babylonAnimation);\n }\n });\n\n return animations;\n };\n }\n\n /**\n * Gets the class name of this block\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.JsonPointerParser;\n }\n}\n\nfunction ToColor(value: any, expectedValue: string) {\n if (value.getClassName().startsWith(\"Color\")) {\n return value as unknown as Color3 | Color4;\n }\n if (expectedValue === \"Color3\") {\n return new Color3(value.x, value.y, value.z);\n } else if (expectedValue === \"Color4\") {\n return new Color4(value.x, value.y, value.z, value.w);\n }\n return value;\n}\n\nRegisterClass(FlowGraphBlockNames.JsonPointerParser, FlowGraphJsonPointerParserBlock);\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphJsonPointerParserBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,+BAA+B,EAAE,oDAAuD;AACjG,OAAO,EAAE,WAAW,EAAE,uCAA0C;AAIhE,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAGpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,wCAA8B;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAqBjF;;;;GAIG;AACH,MAAM,OAAO,+BAA6E,SAAQ,6BAAgC;IA+B9H;IACI;;OAEG;IACa,MAAqD;QAErE,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAA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,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,SAAS,CAAC,KAAsB;IACrC,IAAI,KAAK,YAAY,MAAM,EAAE,CAAC;QAC1B,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,KAAK,YAAY,MAAM,EAAE,CAAC;QACjC,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC;AAED,aAAa,gFAAwC,+BAA+B,CAAC,CAAC","sourcesContent":["import type { FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphPathConverterComponent } from \"core/FlowGraph/flowGraphPathConverterComponent\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\nimport type { IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport type { Animation } from \"core/Animations/animation\";\nimport type { EasingFunction } from \"core/Animations/easing\";\nimport { Vector3, Vector4 } from \"core/Maths/math.vector\";\nimport { Color3, Color4 } from \"core/Maths/math.color\";\nimport { FlowGraphCachedOperationBlock } from \"../flowGraphCachedOperationBlock\";\n\n/**\n * Configuration for the JSON pointer parser block.\n */\nexport interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The JSON pointer to parse.\n */\n jsonPointer: string;\n /**\n * The path converter to use to convert the path to an object accessor.\n */\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\n\n /**\n * Whether to output the value of the property.\n */\n outputValue?: boolean;\n}\n\n/**\n * This block will take a JSON pointer and parse it to get the value from the JSON object.\n * The output is an object and a property name.\n * Optionally, the block can also output the value of the property. This is configurable.\n */\nexport class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Output connection: The object that contains the property.\n */\n public readonly object: FlowGraphDataConnection<O>;\n\n /**\n * Output connection: The property name.\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Output connection: A function that can be used to update the value of the property.\n */\n public readonly setterFunction: FlowGraphDataConnection<(target: O, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n /**\n * Output connection: A function that can be used to get the value of the property.\n */\n public readonly getterFunction: FlowGraphDataConnection<(target: O, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Output connection: A function that can be used to get the interpolation animation property info.\n */\n public readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;\n\n /**\n * The component with the templated inputs for the provided path.\n */\n public readonly templateComponent: FlowGraphPathConverterComponent;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphJsonPointerParserBlockConfiguration\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataOutput(\"object\", RichTypeAny);\n this.propertyName = this.registerDataOutput(\"propertyName\", RichTypeAny);\n this.setterFunction = this.registerDataOutput(\"setFunction\", RichTypeAny, this._setPropertyValue.bind(this));\n this.getterFunction = this.registerDataOutput(\"getFunction\", RichTypeAny, this._getPropertyValue.bind(this));\n this.generateAnimationsFunction = this.registerDataOutput(\"generateAnimationsFunction\", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));\n this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);\n }\n\n public override _doOperation(context: FlowGraphContext): P {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const value = accessorContainer.info.get(accessorContainer.object) as P;\n const object = accessorContainer.info.getTarget?.(accessorContainer.object);\n const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);\n if (!object) {\n throw new Error(\"Object is undefined\");\n } else {\n this.object.setValue(object, context);\n if (propertyName) {\n this.propertyName.setValue(propertyName, context);\n }\n }\n return value;\n }\n\n private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n value = ToColor(value as Vector4, type) as unknown as P;\n }\n accessorContainer.info.set?.(value, accessorContainer.object);\n }\n\n private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n const value = accessorContainer.info.get(accessorContainer.object);\n if (type.startsWith(\"Color\")) {\n return FromColor(value as Color3 | Color4) as unknown as P;\n }\n return value as P | undefined;\n }\n\n private _getInterpolationAnimationPropertyInfo(\n _target: O,\n _propertyName: string,\n context: FlowGraphContext\n ): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => {\n const animations: Animation[] = [];\n // make sure keys are of the right type (in case of float3 color/vector)\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n keys = keys.map((key) => {\n return {\n frame: key.frame,\n value: ToColor(key.value, type),\n };\n });\n }\n accessorContainer.info.interpolation?.forEach((info, index) => {\n const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || \"Animation-interpolation-\" + index;\n // generate the keys based on interpolation info\n let newKeys: any[] = keys;\n if (animationType !== info.type) {\n // convert the keys to the right type\n newKeys = keys.map((key) => {\n return {\n frame: key.frame,\n value: info.getValue(undefined, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),\n };\n });\n }\n const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);\n for (const animation of animationData) {\n if (easingFunction) {\n animation.babylonAnimation.setEasingFunction(easingFunction);\n }\n animations.push(animation.babylonAnimation);\n }\n });\n\n return animations;\n };\n }\n\n /**\n * Gets the class name of this block\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.JsonPointerParser;\n }\n}\n\nfunction ToColor(value: any, expectedValue: string) {\n if (value.getClassName().startsWith(\"Color\")) {\n return value as unknown as Color3 | Color4;\n }\n if (expectedValue === \"Color3\") {\n return new Color3(value.x, value.y, value.z);\n } else if (expectedValue === \"Color4\") {\n return new Color4(value.x, value.y, value.z, value.w);\n }\n return value;\n}\n\nfunction FromColor(value: Color3 | Color4): Vector3 | Vector4 {\n if (value instanceof Color3) {\n return new Vector3(value.r, value.g, value.b);\n } else if (value instanceof Color4) {\n return new Vector4(value.r, value.g, value.b, value.a);\n }\n throw new Error(\"Invalid color type\");\n}\n\nRegisterClass(FlowGraphBlockNames.JsonPointerParser, FlowGraphJsonPointerParserBlock);\n"]}
|
|
@@ -144,7 +144,7 @@ export class GaussianSplattingMaterial extends PushMaterial {
|
|
|
144
144
|
"invViewport",
|
|
145
145
|
"dataTextureSize",
|
|
146
146
|
"focal",
|
|
147
|
-
"
|
|
147
|
+
"eyePosition",
|
|
148
148
|
"kernelSize",
|
|
149
149
|
];
|
|
150
150
|
const samplers = ["covariancesATexture", "covariancesBTexture", "centersTexture", "colorsTexture", "shTexture0", "shTexture1", "shTexture2"];
|
|
@@ -222,9 +222,7 @@ export class GaussianSplattingMaterial extends PushMaterial {
|
|
|
222
222
|
}
|
|
223
223
|
effect.setFloat2("focal", focal, focal);
|
|
224
224
|
effect.setFloat("kernelSize", gsMaterial && gsMaterial.kernelSize ? gsMaterial.kernelSize : GaussianSplattingMaterial.KernelSize);
|
|
225
|
-
|
|
226
|
-
// Binding it manually here instead. Remove next line when SH rendering is fine on that platform.
|
|
227
|
-
scene.bindEyePosition(effect);
|
|
225
|
+
scene.bindEyePosition(effect, "eyePosition", true);
|
|
228
226
|
if (gsMesh.covariancesATexture) {
|
|
229
227
|
const textureSize = gsMesh.covariancesATexture.getSize();
|
|
230
228
|
effect.setFloat2("dataTextureSize", textureSize.width, textureSize.height);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplattingMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GaussianSplatting/gaussianSplattingMaterial.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,gCAA4B;AAE7C,OAAO,0CAA0C,CAAC;AAClD,OAAO,wCAAwC,CAAC;AAChD,OAAO,8CAA8C,CAAC;AACtD,OAAO,4CAA4C,CAAC;AACpD,OAAO,EACH,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,EAC7B,2BAA2B,EAC3B,iCAAiC,EACjC,qBAAqB,EACrB,8BAA8B,GACjC,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,MAAM,gCAAiC,SAAQ,eAAe;IAa1D;;OAEG;IACH;QACI,KAAK,EAAE,CAAC;QAhBL,QAAG,GAAG,KAAK,CAAC;QACZ,mBAAc,GAAG,IAAI,CAA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AAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAC9C,mBAAmB,CAAC,UAAU,GAAG,mCAAmC,CAAC;QACrE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,2BAA2B,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAU,KAAK,CAAC,MAAW,EAAE,KAAY,EAAE,OAAe;QACnE,OAAO,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,yBAAyB,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACtH,CAAC;;AA1UD;;GAEG;AACW,oCAAU,GAAW,GAAG,AAAd,CAAe;AAEvC;;GAEG;AACW,sCAAY,GAAY,KAAK,AAAjB,CAAkB;AAqUhD,aAAa,CAAC,mCAAmC,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import type { SubMesh } from \"../../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Effect, IEffectCreationOptions } from \"../../Materials/effect\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport type { GaussianSplattingMesh } from \"core/Meshes\";\r\nimport { SerializationHelper } from \"../../Misc/decorators.serialization\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { MaterialDefines } from \"../../Materials/materialDefines\";\r\nimport { PushMaterial } from \"../../Materials/pushMaterial\";\r\nimport { RegisterClass } from \"../../Misc/typeStore\";\r\nimport { AddClipPlaneUniforms, BindClipPlane } from \"../clipPlaneMaterialHelper\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\n\r\nimport \"../../Shaders/gaussianSplatting.fragment\";\r\nimport \"../../Shaders/gaussianSplatting.vertex\";\r\nimport \"../../ShadersWGSL/gaussianSplatting.fragment\";\r\nimport \"../../ShadersWGSL/gaussianSplatting.vertex\";\r\nimport {\r\n BindFogParameters,\r\n BindLogDepth,\r\n PrepareAttributesForInstances,\r\n PrepareDefinesForAttributes,\r\n PrepareDefinesForFrameBoundValues,\r\n PrepareDefinesForMisc,\r\n PrepareUniformsAndSamplersList,\r\n} from \"../materialHelper.functions\";\r\nimport { ShaderLanguage } from \"../shaderLanguage\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass GaussianSplattingMaterialDefines extends MaterialDefines {\r\n public FOG = false;\r\n public THIN_INSTANCES = true;\r\n public LOGARITHMICDEPTH = false;\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public SH_DEGREE = 0;\r\n public COMPENSATION = false;\r\n\r\n /**\r\n * Constructor of the defines.\r\n */\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\n/**\r\n * GaussianSplattingMaterial material used to render Gaussian Splatting\r\n * @experimental\r\n */\r\nexport class GaussianSplattingMaterial extends PushMaterial {\r\n /**\r\n * Instantiates a Gaussian Splatting Material in the given scene\r\n * @param name The friendly name of the material\r\n * @param scene The scene to add the material to\r\n */\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n\r\n this.backFaceCulling = false;\r\n }\r\n\r\n /**\r\n * Point spread function (default 0.3). Can be overriden per GS material\r\n */\r\n public static KernelSize: number = 0.3;\r\n\r\n /**\r\n * Compensation\r\n */\r\n public static Compensation: boolean = false;\r\n\r\n /**\r\n * Point spread function (default 0.3). Can be overriden per GS material, otherwise, using default static `KernelSize` value\r\n */\r\n public kernelSize = GaussianSplattingMaterial.KernelSize;\r\n private _compensation = GaussianSplattingMaterial.Compensation;\r\n\r\n // set to true when material defines are dirty\r\n private _isDirty = false;\r\n\r\n /**\r\n * Set compensation default value is `GaussianSplattingMaterial.Compensation`\r\n */\r\n public set compensation(value: boolean) {\r\n this._isDirty = this._isDirty != value;\r\n this._compensation = value;\r\n }\r\n\r\n /**\r\n * Get compensation\r\n */\r\n public get compensation(): boolean {\r\n return this._compensation;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that current material needs to register RTT\r\n */\r\n public override get hasRenderTargetTextures(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Specifies whether or not this material should be rendered in alpha test mode.\r\n * @returns false\r\n */\r\n public override needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Specifies whether or not this material should be rendered in alpha blend mode.\r\n * @returns true\r\n */\r\n public override needAlphaBlending(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks whether the material is ready to be rendered for a given mesh.\r\n * @param mesh The mesh to render\r\n * @param subMesh The submesh to check against\r\n * @returns true if all the dependencies are ready (Textures, Effects...)\r\n */\r\n public override isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh): boolean {\r\n const useInstances = true;\r\n\r\n const drawWrapper = subMesh._drawWrapper;\r\n let defines = <GaussianSplattingMaterialDefines>subMesh.materialDefines;\r\n\r\n if (defines && this._isDirty) {\r\n defines.markAsUnprocessed();\r\n }\r\n\r\n if (drawWrapper.effect && this.isFrozen) {\r\n if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n defines = subMesh.materialDefines = new GaussianSplattingMaterialDefines();\r\n }\r\n\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n const engine = scene.getEngine();\r\n const gsMesh = mesh as GaussianSplattingMesh;\r\n\r\n // Misc.\r\n PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, false, defines);\r\n\r\n // Values that need to be evaluated on every frame\r\n PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances, null, true);\r\n\r\n // Attribs\r\n PrepareDefinesForAttributes(mesh, defines, false, false);\r\n\r\n // SH is disabled for webGL1\r\n if (engine.version > 1 || engine.isWebGPU) {\r\n defines[\"SH_DEGREE\"] = gsMesh.shDegree;\r\n }\r\n\r\n // Compensation\r\n const splatMaterial = gsMesh.material as GaussianSplattingMaterial;\r\n defines[\"COMPENSATION\"] = splatMaterial && splatMaterial.compensation ? splatMaterial.compensation : GaussianSplattingMaterial.Compensation;\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n scene.resetCachedMaterial();\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind, \"splatIndex\"];\r\n\r\n PrepareAttributesForInstances(attribs, defines);\r\n\r\n const uniforms = [\r\n \"world\",\r\n \"view\",\r\n \"projection\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"logarithmicDepthConstant\",\r\n \"invViewport\",\r\n \"dataTextureSize\",\r\n \"focal\",\r\n \"vEyePosition\",\r\n \"kernelSize\",\r\n ];\r\n const samplers = [\"covariancesATexture\", \"covariancesBTexture\", \"centersTexture\", \"colorsTexture\", \"shTexture0\", \"shTexture1\", \"shTexture2\"];\r\n const uniformBuffers = [\"Scene\", \"Mesh\"];\r\n\r\n PrepareUniformsAndSamplersList(<IEffectCreationOptions>{\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: defines,\r\n });\r\n\r\n AddClipPlaneUniforms(uniforms);\r\n\r\n const join = defines.toString();\r\n const effect = scene.getEngine().createEffect(\r\n \"gaussianSplatting\",\r\n <IEffectCreationOptions>{\r\n attributes: attribs,\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: join,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n indexParameters: {},\r\n shaderLanguage: this._shaderLanguage,\r\n extraInitializationsAsync: async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../../ShadersWGSL/gaussianSplatting.fragment\"), import(\"../../ShadersWGSL/gaussianSplatting.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/gaussianSplatting.fragment\"), import(\"../../Shaders/gaussianSplatting.vertex\")]);\r\n }\r\n },\r\n },\r\n engine\r\n );\r\n subMesh.setEffect(effect, defines, this._materialContext);\r\n }\r\n\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n drawWrapper._wasPreviouslyUsingInstances = useInstances;\r\n this._isDirty = false;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Bind material effect for a specific Gaussian Splatting mesh\r\n * @param mesh Gaussian splatting mesh\r\n * @param effect Splatting material or node material\r\n * @param scene scene that contains mesh and camera used for rendering\r\n */\r\n public static BindEffect(mesh: Mesh, effect: Effect, scene: Scene): void {\r\n const engine = scene.getEngine();\r\n const camera = scene.activeCamera;\r\n\r\n const renderWidth = engine.getRenderWidth();\r\n const renderHeight = engine.getRenderHeight();\r\n\r\n const gsMesh = mesh as GaussianSplattingMesh;\r\n const gsMaterial = gsMesh.material as GaussianSplattingMaterial;\r\n\r\n // check if rigcamera, get number of rigs\r\n const numberOfRigs = camera?.rigParent?.rigCameras.length || 1;\r\n\r\n effect.setFloat2(\"invViewport\", 1 / (renderWidth / numberOfRigs), 1 / renderHeight);\r\n\r\n let focal = 1000;\r\n\r\n if (camera) {\r\n /*\r\n more explicit version:\r\n const t = camera.getProjectionMatrix().m[5];\r\n const FovY = Math.atan(1.0 / t) * 2.0;\r\n focal = renderHeight / 2.0 / Math.tan(FovY / 2.0);\r\n Using a shorter version here to not have tan(atan) and 2.0 factor\r\n */\r\n const t = camera.getProjectionMatrix().m[5];\r\n if (camera.fovMode == Camera.FOVMODE_VERTICAL_FIXED) {\r\n focal = (renderHeight * t) / 2.0;\r\n } else {\r\n focal = (renderWidth * t) / 2.0;\r\n }\r\n }\r\n\r\n effect.setFloat2(\"focal\", focal, focal);\r\n effect.setFloat(\"kernelSize\", gsMaterial && gsMaterial.kernelSize ? gsMaterial.kernelSize : GaussianSplattingMaterial.KernelSize);\r\n\r\n // vEyePosition doesn't get automatially bound on MacOS with Chromium for no apparent reason.\r\n // Binding it manually here instead. Remove next line when SH rendering is fine on that platform.\r\n scene.bindEyePosition(effect);\r\n\r\n if (gsMesh.covariancesATexture) {\r\n const textureSize = gsMesh.covariancesATexture.getSize();\r\n\r\n effect.setFloat2(\"dataTextureSize\", textureSize.width, textureSize.height);\r\n\r\n effect.setTexture(\"covariancesATexture\", gsMesh.covariancesATexture);\r\n effect.setTexture(\"covariancesBTexture\", gsMesh.covariancesBTexture);\r\n effect.setTexture(\"centersTexture\", gsMesh.centersTexture);\r\n effect.setTexture(\"colorsTexture\", gsMesh.colorsTexture);\r\n\r\n if (gsMesh.shTextures) {\r\n for (let i = 0; i < gsMesh.shTextures?.length; i++) {\r\n effect.setTexture(`shTexture${i}`, gsMesh.shTextures[i]);\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * Binds the submesh to this material by preparing the effect and shader to draw\r\n * @param world defines the world transformation matrix\r\n * @param mesh defines the mesh containing the submesh\r\n * @param subMesh defines the submesh to bind the material to\r\n */\r\n public override bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <GaussianSplattingMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices Mesh.\r\n mesh.getMeshUniformBuffer().bindToEffect(effect, \"Mesh\");\r\n mesh.transferToEffect(world);\r\n\r\n // Bind data\r\n const mustRebind = this._mustRebind(scene, effect, subMesh, mesh.visibility);\r\n\r\n if (mustRebind) {\r\n this.bindView(effect);\r\n this.bindViewProjection(effect);\r\n GaussianSplattingMaterial.BindEffect(mesh, this._activeEffect, scene);\r\n // Clip plane\r\n BindClipPlane(effect, this, scene);\r\n } else if (scene.getEngine()._features.needToAlwaysBindUniformBuffers) {\r\n this._needToBindSceneUbo = true;\r\n }\r\n\r\n // Fog\r\n BindFogParameters(scene, mesh, effect);\r\n\r\n // Log. depth\r\n if (this.useLogarithmicDepth) {\r\n BindLogDepth(defines, effect, scene);\r\n }\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n /**\r\n * Clones the material.\r\n * @param name The cloned name.\r\n * @returns The cloned material.\r\n */\r\n public override clone(name: string): GaussianSplattingMaterial {\r\n return SerializationHelper.Clone(() => new GaussianSplattingMaterial(name, this.getScene()), this);\r\n }\r\n\r\n /**\r\n * Serializes the current material to its JSON representation.\r\n * @returns The JSON representation.\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.GaussianSplattingMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Gets the class name of the material\r\n * @returns \"GaussianSplattingMaterial\"\r\n */\r\n public override getClassName(): string {\r\n return \"GaussianSplattingMaterial\";\r\n }\r\n\r\n /**\r\n * Parse a JSON input to create back a Gaussian Splatting material.\r\n * @param source The JSON data to parse\r\n * @param scene The scene to create the parsed material in\r\n * @param rootUrl The root url of the assets the material depends upon\r\n * @returns the instantiated GaussianSplattingMaterial.\r\n */\r\n public static override Parse(source: any, scene: Scene, rootUrl: string): GaussianSplattingMaterial {\r\n return SerializationHelper.Parse(() => new GaussianSplattingMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GaussianSplattingMaterial\", GaussianSplattingMaterial);\r\n"]}
|
|
1
|
+
{"version":3,"file":"gaussianSplattingMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GaussianSplatting/gaussianSplattingMaterial.ts"],"names":[],"mappings":"AAOA,OAAO,EAA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G;AACW,sCAAY,GAAY,KAAK,AAAjB,CAAkB;AAkUhD,aAAa,CAAC,mCAAmC,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import type { SubMesh } from \"../../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Effect, IEffectCreationOptions } from \"../../Materials/effect\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport type { GaussianSplattingMesh } from \"core/Meshes\";\r\nimport { SerializationHelper } from \"../../Misc/decorators.serialization\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { MaterialDefines } from \"../../Materials/materialDefines\";\r\nimport { PushMaterial } from \"../../Materials/pushMaterial\";\r\nimport { RegisterClass } from \"../../Misc/typeStore\";\r\nimport { AddClipPlaneUniforms, BindClipPlane } from \"../clipPlaneMaterialHelper\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\n\r\nimport \"../../Shaders/gaussianSplatting.fragment\";\r\nimport \"../../Shaders/gaussianSplatting.vertex\";\r\nimport \"../../ShadersWGSL/gaussianSplatting.fragment\";\r\nimport \"../../ShadersWGSL/gaussianSplatting.vertex\";\r\nimport {\r\n BindFogParameters,\r\n BindLogDepth,\r\n PrepareAttributesForInstances,\r\n PrepareDefinesForAttributes,\r\n PrepareDefinesForFrameBoundValues,\r\n PrepareDefinesForMisc,\r\n PrepareUniformsAndSamplersList,\r\n} from \"../materialHelper.functions\";\r\nimport { ShaderLanguage } from \"../shaderLanguage\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass GaussianSplattingMaterialDefines extends MaterialDefines {\r\n public FOG = false;\r\n public THIN_INSTANCES = true;\r\n public LOGARITHMICDEPTH = false;\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public SH_DEGREE = 0;\r\n public COMPENSATION = false;\r\n\r\n /**\r\n * Constructor of the defines.\r\n */\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\n/**\r\n * GaussianSplattingMaterial material used to render Gaussian Splatting\r\n * @experimental\r\n */\r\nexport class GaussianSplattingMaterial extends PushMaterial {\r\n /**\r\n * Instantiates a Gaussian Splatting Material in the given scene\r\n * @param name The friendly name of the material\r\n * @param scene The scene to add the material to\r\n */\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n\r\n this.backFaceCulling = false;\r\n }\r\n\r\n /**\r\n * Point spread function (default 0.3). Can be overriden per GS material\r\n */\r\n public static KernelSize: number = 0.3;\r\n\r\n /**\r\n * Compensation\r\n */\r\n public static Compensation: boolean = false;\r\n\r\n /**\r\n * Point spread function (default 0.3). Can be overriden per GS material, otherwise, using default static `KernelSize` value\r\n */\r\n public kernelSize = GaussianSplattingMaterial.KernelSize;\r\n private _compensation = GaussianSplattingMaterial.Compensation;\r\n\r\n // set to true when material defines are dirty\r\n private _isDirty = false;\r\n\r\n /**\r\n * Set compensation default value is `GaussianSplattingMaterial.Compensation`\r\n */\r\n public set compensation(value: boolean) {\r\n this._isDirty = this._isDirty != value;\r\n this._compensation = value;\r\n }\r\n\r\n /**\r\n * Get compensation\r\n */\r\n public get compensation(): boolean {\r\n return this._compensation;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that current material needs to register RTT\r\n */\r\n public override get hasRenderTargetTextures(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Specifies whether or not this material should be rendered in alpha test mode.\r\n * @returns false\r\n */\r\n public override needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Specifies whether or not this material should be rendered in alpha blend mode.\r\n * @returns true\r\n */\r\n public override needAlphaBlending(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks whether the material is ready to be rendered for a given mesh.\r\n * @param mesh The mesh to render\r\n * @param subMesh The submesh to check against\r\n * @returns true if all the dependencies are ready (Textures, Effects...)\r\n */\r\n public override isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh): boolean {\r\n const useInstances = true;\r\n\r\n const drawWrapper = subMesh._drawWrapper;\r\n let defines = <GaussianSplattingMaterialDefines>subMesh.materialDefines;\r\n\r\n if (defines && this._isDirty) {\r\n defines.markAsUnprocessed();\r\n }\r\n\r\n if (drawWrapper.effect && this.isFrozen) {\r\n if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n defines = subMesh.materialDefines = new GaussianSplattingMaterialDefines();\r\n }\r\n\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n const engine = scene.getEngine();\r\n const gsMesh = mesh as GaussianSplattingMesh;\r\n\r\n // Misc.\r\n PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, false, defines);\r\n\r\n // Values that need to be evaluated on every frame\r\n PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances, null, true);\r\n\r\n // Attribs\r\n PrepareDefinesForAttributes(mesh, defines, false, false);\r\n\r\n // SH is disabled for webGL1\r\n if (engine.version > 1 || engine.isWebGPU) {\r\n defines[\"SH_DEGREE\"] = gsMesh.shDegree;\r\n }\r\n\r\n // Compensation\r\n const splatMaterial = gsMesh.material as GaussianSplattingMaterial;\r\n defines[\"COMPENSATION\"] = splatMaterial && splatMaterial.compensation ? splatMaterial.compensation : GaussianSplattingMaterial.Compensation;\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n scene.resetCachedMaterial();\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind, \"splatIndex\"];\r\n\r\n PrepareAttributesForInstances(attribs, defines);\r\n\r\n const uniforms = [\r\n \"world\",\r\n \"view\",\r\n \"projection\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"logarithmicDepthConstant\",\r\n \"invViewport\",\r\n \"dataTextureSize\",\r\n \"focal\",\r\n \"eyePosition\",\r\n \"kernelSize\",\r\n ];\r\n const samplers = [\"covariancesATexture\", \"covariancesBTexture\", \"centersTexture\", \"colorsTexture\", \"shTexture0\", \"shTexture1\", \"shTexture2\"];\r\n const uniformBuffers = [\"Scene\", \"Mesh\"];\r\n\r\n PrepareUniformsAndSamplersList(<IEffectCreationOptions>{\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: defines,\r\n });\r\n\r\n AddClipPlaneUniforms(uniforms);\r\n\r\n const join = defines.toString();\r\n const effect = scene.getEngine().createEffect(\r\n \"gaussianSplatting\",\r\n <IEffectCreationOptions>{\r\n attributes: attribs,\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: join,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n indexParameters: {},\r\n shaderLanguage: this._shaderLanguage,\r\n extraInitializationsAsync: async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../../ShadersWGSL/gaussianSplatting.fragment\"), import(\"../../ShadersWGSL/gaussianSplatting.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/gaussianSplatting.fragment\"), import(\"../../Shaders/gaussianSplatting.vertex\")]);\r\n }\r\n },\r\n },\r\n engine\r\n );\r\n subMesh.setEffect(effect, defines, this._materialContext);\r\n }\r\n\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n drawWrapper._wasPreviouslyUsingInstances = useInstances;\r\n this._isDirty = false;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Bind material effect for a specific Gaussian Splatting mesh\r\n * @param mesh Gaussian splatting mesh\r\n * @param effect Splatting material or node material\r\n * @param scene scene that contains mesh and camera used for rendering\r\n */\r\n public static BindEffect(mesh: Mesh, effect: Effect, scene: Scene): void {\r\n const engine = scene.getEngine();\r\n const camera = scene.activeCamera;\r\n\r\n const renderWidth = engine.getRenderWidth();\r\n const renderHeight = engine.getRenderHeight();\r\n\r\n const gsMesh = mesh as GaussianSplattingMesh;\r\n const gsMaterial = gsMesh.material as GaussianSplattingMaterial;\r\n\r\n // check if rigcamera, get number of rigs\r\n const numberOfRigs = camera?.rigParent?.rigCameras.length || 1;\r\n\r\n effect.setFloat2(\"invViewport\", 1 / (renderWidth / numberOfRigs), 1 / renderHeight);\r\n\r\n let focal = 1000;\r\n\r\n if (camera) {\r\n /*\r\n more explicit version:\r\n const t = camera.getProjectionMatrix().m[5];\r\n const FovY = Math.atan(1.0 / t) * 2.0;\r\n focal = renderHeight / 2.0 / Math.tan(FovY / 2.0);\r\n Using a shorter version here to not have tan(atan) and 2.0 factor\r\n */\r\n const t = camera.getProjectionMatrix().m[5];\r\n if (camera.fovMode == Camera.FOVMODE_VERTICAL_FIXED) {\r\n focal = (renderHeight * t) / 2.0;\r\n } else {\r\n focal = (renderWidth * t) / 2.0;\r\n }\r\n }\r\n\r\n effect.setFloat2(\"focal\", focal, focal);\r\n effect.setFloat(\"kernelSize\", gsMaterial && gsMaterial.kernelSize ? gsMaterial.kernelSize : GaussianSplattingMaterial.KernelSize);\r\n scene.bindEyePosition(effect, \"eyePosition\", true);\r\n\r\n if (gsMesh.covariancesATexture) {\r\n const textureSize = gsMesh.covariancesATexture.getSize();\r\n\r\n effect.setFloat2(\"dataTextureSize\", textureSize.width, textureSize.height);\r\n\r\n effect.setTexture(\"covariancesATexture\", gsMesh.covariancesATexture);\r\n effect.setTexture(\"covariancesBTexture\", gsMesh.covariancesBTexture);\r\n effect.setTexture(\"centersTexture\", gsMesh.centersTexture);\r\n effect.setTexture(\"colorsTexture\", gsMesh.colorsTexture);\r\n\r\n if (gsMesh.shTextures) {\r\n for (let i = 0; i < gsMesh.shTextures?.length; i++) {\r\n effect.setTexture(`shTexture${i}`, gsMesh.shTextures[i]);\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * Binds the submesh to this material by preparing the effect and shader to draw\r\n * @param world defines the world transformation matrix\r\n * @param mesh defines the mesh containing the submesh\r\n * @param subMesh defines the submesh to bind the material to\r\n */\r\n public override bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <GaussianSplattingMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices Mesh.\r\n mesh.getMeshUniformBuffer().bindToEffect(effect, \"Mesh\");\r\n mesh.transferToEffect(world);\r\n\r\n // Bind data\r\n const mustRebind = this._mustRebind(scene, effect, subMesh, mesh.visibility);\r\n\r\n if (mustRebind) {\r\n this.bindView(effect);\r\n this.bindViewProjection(effect);\r\n GaussianSplattingMaterial.BindEffect(mesh, this._activeEffect, scene);\r\n // Clip plane\r\n BindClipPlane(effect, this, scene);\r\n } else if (scene.getEngine()._features.needToAlwaysBindUniformBuffers) {\r\n this._needToBindSceneUbo = true;\r\n }\r\n\r\n // Fog\r\n BindFogParameters(scene, mesh, effect);\r\n\r\n // Log. depth\r\n if (this.useLogarithmicDepth) {\r\n BindLogDepth(defines, effect, scene);\r\n }\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n /**\r\n * Clones the material.\r\n * @param name The cloned name.\r\n * @returns The cloned material.\r\n */\r\n public override clone(name: string): GaussianSplattingMaterial {\r\n return SerializationHelper.Clone(() => new GaussianSplattingMaterial(name, this.getScene()), this);\r\n }\r\n\r\n /**\r\n * Serializes the current material to its JSON representation.\r\n * @returns The JSON representation.\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.GaussianSplattingMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Gets the class name of the material\r\n * @returns \"GaussianSplattingMaterial\"\r\n */\r\n public override getClassName(): string {\r\n return \"GaussianSplattingMaterial\";\r\n }\r\n\r\n /**\r\n * Parse a JSON input to create back a Gaussian Splatting material.\r\n * @param source The JSON data to parse\r\n * @param scene The scene to create the parsed material in\r\n * @param rootUrl The root url of the assets the material depends upon\r\n * @returns the instantiated GaussianSplattingMaterial.\r\n */\r\n public static override Parse(source: any, scene: Scene, rootUrl: string): GaussianSplattingMaterial {\r\n return SerializationHelper.Parse(() => new GaussianSplattingMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GaussianSplattingMaterial\", GaussianSplattingMaterial);\r\n"]}
|
|
@@ -23,6 +23,14 @@ export declare class GaussianBlock extends NodeMaterialBlock {
|
|
|
23
23
|
* Gets the rgba output component
|
|
24
24
|
*/
|
|
25
25
|
get rgba(): NodeMaterialConnectionPoint;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the rgb output component
|
|
28
|
+
*/
|
|
29
|
+
get rgb(): NodeMaterialConnectionPoint;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the alpha output component
|
|
32
|
+
*/
|
|
33
|
+
get alpha(): NodeMaterialConnectionPoint;
|
|
26
34
|
/**
|
|
27
35
|
* Initialize the block and prepare the context for build
|
|
28
36
|
* @param state defines the state that will be used for the build
|
|
@@ -15,6 +15,8 @@ export class GaussianBlock extends NodeMaterialBlock {
|
|
|
15
15
|
this._isUnique = false;
|
|
16
16
|
this.registerInput("splatColor", NodeMaterialBlockConnectionPointTypes.Color4, false, NodeMaterialBlockTargets.Fragment);
|
|
17
17
|
this.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment);
|
|
18
|
+
this.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
|
|
19
|
+
this.registerOutput("alpha", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Gets the current class name
|
|
@@ -35,6 +37,18 @@ export class GaussianBlock extends NodeMaterialBlock {
|
|
|
35
37
|
get rgba() {
|
|
36
38
|
return this._outputs[0];
|
|
37
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the rgb output component
|
|
42
|
+
*/
|
|
43
|
+
get rgb() {
|
|
44
|
+
return this._outputs[1];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets the alpha output component
|
|
48
|
+
*/
|
|
49
|
+
get alpha() {
|
|
50
|
+
return this._outputs[2];
|
|
51
|
+
}
|
|
38
52
|
/**
|
|
39
53
|
* Initialize the block and prepare the context for build
|
|
40
54
|
* @param state defines the state that will be used for the build
|
|
@@ -54,14 +68,20 @@ export class GaussianBlock extends NodeMaterialBlock {
|
|
|
54
68
|
state._emitFunctionFromInclude("fogFragmentDeclaration", comments);
|
|
55
69
|
state._emitFunctionFromInclude("gaussianSplattingFragmentDeclaration", comments);
|
|
56
70
|
state._emitVaryingFromString("vPosition", NodeMaterialBlockConnectionPointTypes.Vector2);
|
|
71
|
+
const tempSplatColor = state._getFreeVariableName("tempSplatColor");
|
|
57
72
|
const color = this.splatColor;
|
|
58
|
-
const
|
|
73
|
+
const rgba = this._outputs[0];
|
|
74
|
+
const rgb = this._outputs[1];
|
|
75
|
+
const alpha = this._outputs[2];
|
|
59
76
|
if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
60
|
-
state.compilationString +=
|
|
77
|
+
state.compilationString += `let ${tempSplatColor}:vec4f = gaussianColor(${color.associatedVariableName}, input.vPosition);\n`;
|
|
61
78
|
}
|
|
62
79
|
else {
|
|
63
|
-
state.compilationString +=
|
|
80
|
+
state.compilationString += `vec4 ${tempSplatColor} = gaussianColor(${color.associatedVariableName});\n`;
|
|
64
81
|
}
|
|
82
|
+
state.compilationString += `${state._declareOutput(rgba)} = ${tempSplatColor}.rgba;`;
|
|
83
|
+
state.compilationString += `${state._declareOutput(rgb)} = ${tempSplatColor}.rgb;`;
|
|
84
|
+
state.compilationString += `${state._declareOutput(alpha)} = ${tempSplatColor}.a;`;
|
|
65
85
|
return this;
|
|
66
86
|
}
|
|
67
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,MAAM,EAAE,KAAK,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAEzH,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,qCAAqC,CAAC,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IACjH,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,Q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,KAAK,CAAC;QAEnF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used for the Gaussian Splatting Fragment part\r\n */\r\nexport class GaussianBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new GaussianBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._isUnique = false;\r\n\r\n this.registerInput(\"splatColor\", NodeMaterialBlockConnectionPointTypes.Color4, false, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerOutput(\"rgba\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"alpha\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GaussianBlock\";\r\n }\r\n\r\n /**\r\n * Gets the color input component\r\n */\r\n public get splatColor(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgba output component\r\n */\r\n public get rgba(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb output component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the alpha output component\r\n */\r\n public get alpha(): NodeMaterialConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"vPosition\");\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (state.target === NodeMaterialBlockTargets.Vertex) {\r\n return;\r\n }\r\n\r\n // Emit code\r\n const comments = `//${this.name}`;\r\n state._emitFunctionFromInclude(\"clipPlaneFragmentDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"logDepthDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"fogFragmentDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"gaussianSplattingFragmentDeclaration\", comments);\r\n state._emitVaryingFromString(\"vPosition\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n\r\n const tempSplatColor = state._getFreeVariableName(\"tempSplatColor\");\r\n const color = this.splatColor;\r\n const rgba = this._outputs[0];\r\n const rgb = this._outputs[1];\r\n const alpha = this._outputs[2];\r\n\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `let ${tempSplatColor}:vec4f = gaussianColor(${color.associatedVariableName}, input.vPosition);\\n`;\r\n } else {\r\n state.compilationString += `vec4 ${tempSplatColor} = gaussianColor(${color.associatedVariableName});\\n`;\r\n }\r\n\r\n state.compilationString += `${state._declareOutput(rgba)} = ${tempSplatColor}.rgba;`;\r\n state.compilationString += `${state._declareOutput(rgb)} = ${tempSplatColor}.rgb;`;\r\n state.compilationString += `${state._declareOutput(alpha)} = ${tempSplatColor}.a;`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GaussianBlock\", GaussianBlock);\r\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NodeMaterialBlock } from "../../nodeMaterialBlock.js";
|
|
2
2
|
import type { NodeMaterialBuildState } from "../../nodeMaterialBuildState.js";
|
|
3
3
|
import type { NodeMaterialConnectionPoint } from "../../nodeMaterialBlockConnectionPoint.js";
|
|
4
|
+
import type { AbstractMesh } from "../../../../Meshes/abstractMesh.js";
|
|
5
|
+
import type { NodeMaterial, NodeMaterialDefines } from "../../nodeMaterial.js";
|
|
4
6
|
/**
|
|
5
7
|
* Block used for the Gaussian Splatting
|
|
6
8
|
*/
|
|
@@ -39,10 +41,21 @@ export declare class GaussianSplattingBlock extends NodeMaterialBlock {
|
|
|
39
41
|
* Gets the splatVertex output component
|
|
40
42
|
*/
|
|
41
43
|
get splatVertex(): NodeMaterialConnectionPoint;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the SH output contribution
|
|
46
|
+
*/
|
|
47
|
+
get SH(): NodeMaterialConnectionPoint;
|
|
42
48
|
/**
|
|
43
49
|
* Initialize the block and prepare the context for build
|
|
44
50
|
* @param state defines the state that will be used for the build
|
|
45
51
|
*/
|
|
46
52
|
initialize(state: NodeMaterialBuildState): void;
|
|
53
|
+
/**
|
|
54
|
+
* Update defines for shader compilation
|
|
55
|
+
* @param mesh defines the mesh to be rendered
|
|
56
|
+
* @param nodeMaterial defines the node material requesting the update
|
|
57
|
+
* @param defines defines the material defines to update
|
|
58
|
+
*/
|
|
59
|
+
prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
|
|
47
60
|
protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
|
|
48
61
|
}
|
|
@@ -20,6 +20,7 @@ export class GaussianSplattingBlock extends NodeMaterialBlock {
|
|
|
20
20
|
this.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);
|
|
21
21
|
this.registerInput("projection", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);
|
|
22
22
|
this.registerOutput("splatVertex", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Vertex);
|
|
23
|
+
this.registerOutput("SH", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Vertex);
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Gets the current class name
|
|
@@ -64,6 +65,12 @@ export class GaussianSplattingBlock extends NodeMaterialBlock {
|
|
|
64
65
|
get splatVertex() {
|
|
65
66
|
return this._outputs[0];
|
|
66
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the SH output contribution
|
|
70
|
+
*/
|
|
71
|
+
get SH() {
|
|
72
|
+
return this._outputs[1];
|
|
73
|
+
}
|
|
67
74
|
/**
|
|
68
75
|
* Initialize the block and prepare the context for build
|
|
69
76
|
* @param state defines the state that will be used for the build
|
|
@@ -72,18 +79,33 @@ export class GaussianSplattingBlock extends NodeMaterialBlock {
|
|
|
72
79
|
state._excludeVariableName("focal");
|
|
73
80
|
state._excludeVariableName("invViewport");
|
|
74
81
|
state._excludeVariableName("kernelSize");
|
|
82
|
+
state._excludeVariableName("eyePosition");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Update defines for shader compilation
|
|
86
|
+
* @param mesh defines the mesh to be rendered
|
|
87
|
+
* @param nodeMaterial defines the node material requesting the update
|
|
88
|
+
* @param defines defines the material defines to update
|
|
89
|
+
*/
|
|
90
|
+
prepareDefines(mesh, nodeMaterial, defines) {
|
|
91
|
+
if (mesh.getClassName() == "GaussianSplattingMesh") {
|
|
92
|
+
defines.setValue("SH_DEGREE", mesh.shDegree, true);
|
|
93
|
+
}
|
|
75
94
|
}
|
|
76
95
|
_buildBlock(state) {
|
|
77
96
|
super._buildBlock(state);
|
|
78
97
|
if (state.target === NodeMaterialBlockTargets.Fragment) {
|
|
79
98
|
return;
|
|
80
99
|
}
|
|
100
|
+
state.sharedData.blocksWithDefines.push(this);
|
|
81
101
|
const comments = `//${this.name}`;
|
|
82
102
|
state._emitFunctionFromInclude("gaussianSplattingVertexDeclaration", comments);
|
|
83
103
|
state._emitFunctionFromInclude("gaussianSplatting", comments);
|
|
104
|
+
state._emitFunctionFromInclude("helperFunctions", comments);
|
|
84
105
|
state._emitUniformFromString("focal", NodeMaterialBlockConnectionPointTypes.Vector2);
|
|
85
106
|
state._emitUniformFromString("invViewport", NodeMaterialBlockConnectionPointTypes.Vector2);
|
|
86
107
|
state._emitUniformFromString("kernelSize", NodeMaterialBlockConnectionPointTypes.Float);
|
|
108
|
+
state._emitUniformFromString("eyePosition", NodeMaterialBlockConnectionPointTypes.Vector3);
|
|
87
109
|
state.attributes.push(VertexBuffer.PositionKind);
|
|
88
110
|
state.sharedData.nodeMaterial.backFaceCulling = false;
|
|
89
111
|
const splatPosition = this.splatPosition;
|
|
@@ -92,6 +114,7 @@ export class GaussianSplattingBlock extends NodeMaterialBlock {
|
|
|
92
114
|
const view = this.view;
|
|
93
115
|
const projection = this.projection;
|
|
94
116
|
const output = this.splatVertex;
|
|
117
|
+
const sh = this.SH;
|
|
95
118
|
const addF = state.fSuffix;
|
|
96
119
|
let splatScaleParameter = `vec2${addF}(1.,1.)`;
|
|
97
120
|
if (splatScale.isConnected) {
|
|
@@ -103,6 +126,27 @@ export class GaussianSplattingBlock extends NodeMaterialBlock {
|
|
|
103
126
|
input = "input.position";
|
|
104
127
|
uniforms = ", uniforms.focal, uniforms.invViewport, uniforms.kernelSize";
|
|
105
128
|
}
|
|
129
|
+
if (this.SH.isConnected) {
|
|
130
|
+
state.compilationString += `#if SH_DEGREE > 0\n`;
|
|
131
|
+
if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
132
|
+
state.compilationString += `let worldRot: mat3x3f = mat3x3f(${world.associatedVariableName}[0].xyz, ${world.associatedVariableName}[1].xyz, ${world.associatedVariableName}[2].xyz);`;
|
|
133
|
+
state.compilationString += `let normWorldRot: mat3x3f = inverseMat3(worldRot);`;
|
|
134
|
+
state.compilationString += `var dir: vec3f = normalize(normWorldRot * (${splatPosition.associatedVariableName}.xyz - uniforms.eyePosition));\n`;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
state.compilationString += `mat3 worldRot = mat3(${world.associatedVariableName});`;
|
|
138
|
+
state.compilationString += `mat3 normWorldRot = inverseMat3(worldRot);`;
|
|
139
|
+
state.compilationString += `vec3 dir = normalize(normWorldRot * (${splatPosition.associatedVariableName}.xyz - eyePosition));\n`;
|
|
140
|
+
}
|
|
141
|
+
state.compilationString += `dir *= vec3${addF}(1.,1.,-1.);\n`;
|
|
142
|
+
state.compilationString += `${state._declareOutput(sh)} = computeSH(splat, dir);\n`;
|
|
143
|
+
state.compilationString += `#else\n`;
|
|
144
|
+
state.compilationString += `${state._declareOutput(sh)} = vec3${addF}(0.,0.,0.);\n`;
|
|
145
|
+
state.compilationString += `#endif;\n`;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
state.compilationString += `${state._declareOutput(sh)} = vec3${addF}(0.,0.,0.);`;
|
|
149
|
+
}
|
|
106
150
|
state.compilationString += `${state._declareOutput(output)} = gaussianSplatting(${input}, ${splatPosition.associatedVariableName}, ${splatScaleParameter}, covA, covB, ${world.associatedVariableName}, ${view.associatedVariableName}, ${projection.associatedVariableName}${uniforms});\n`;
|
|
107
151
|
return this;
|
|
108
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplattingBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC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,CAAC,eAAe,GAAG,KAAK,CAAC;QAEtD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAEhC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;QAC3B,IAAI,mBAAmB,GAAG,OAAO,IAAI,SAAS,CAAC;QAC/C,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;YACzB,mBAAmB,GAAG,UAAU,CAAC,sBAAsB,CAAC;QAC5D,CAAC;QAED,IAAI,KAAK,GAAG,UAAU,CAAC;QACvB,IAAI,QAAQ,GAAG,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,cAAc,gCAAwB,EAAE,CAAC;YAC/C,KAAK,GAAG,gBAAgB,CAAC;YACzB,QAAQ,GAAG,6DAA6D,CAAC;QAC7E,CAAC;QACD,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,wBAAwB,KAAK,KAAK,aAAa,CAAC,sBAAsB,KAAK,mBAAmB,iBAAiB,KAAK,CAAC,sBAAsB,KAAK,IAAI,CAAC,sBAAsB,KAAK,UAAU,CAAC,sBAAsB,GAAG,QAAQ,MAAM,CAAC;QAC7R,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { VertexBuffer } from \"core/Meshes/buffer\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used for the Gaussian Splatting\r\n */\r\nexport class GaussianSplattingBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new GaussianSplattingBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Vertex);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"splatScale\", NodeMaterialBlockConnectionPointTypes.Vector2, true, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"world\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"view\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"projection\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerOutput(\"splatVertex\", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Vertex);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GaussianSplattingBlock\";\r\n }\r\n\r\n /**\r\n * Gets the position input component\r\n */\r\n public get splatPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get splatScale(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the View matrix input component\r\n */\r\n public get world(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the View matrix input component\r\n */\r\n public get view(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the projection matrix input component\r\n */\r\n public get projection(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the splatVertex output component\r\n */\r\n public get splatVertex(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"focal\");\r\n state._excludeVariableName(\"invViewport\");\r\n state._excludeVariableName(\"kernelSize\");\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n return;\r\n }\r\n\r\n const comments = `//${this.name}`;\r\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\r\n state._emitUniformFromString(\"focal\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n state._emitUniformFromString(\"invViewport\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n state._emitUniformFromString(\"kernelSize\", NodeMaterialBlockConnectionPointTypes.Float);\r\n state.attributes.push(VertexBuffer.PositionKind);\r\n state.sharedData.nodeMaterial.backFaceCulling = false;\r\n\r\n const splatPosition = this.splatPosition;\r\n const splatScale = this.splatScale;\r\n const world = this.world;\r\n const view = this.view;\r\n const projection = this.projection;\r\n const output = this.splatVertex;\r\n\r\n const addF = state.fSuffix;\r\n let splatScaleParameter = `vec2${addF}(1.,1.)`;\r\n if (splatScale.isConnected) {\r\n splatScaleParameter = splatScale.associatedVariableName;\r\n }\r\n\r\n let input = \"position\";\r\n let uniforms = \"\";\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n input = \"input.position\";\r\n uniforms = \", uniforms.focal, uniforms.invViewport, uniforms.kernelSize\";\r\n }\r\n state.compilationString += `${state._declareOutput(output)} = gaussianSplatting(${input}, ${splatPosition.associatedVariableName}, ${splatScaleParameter}, covA, covB, ${world.associatedVariableName}, ${view.associatedVariableName}, ${projection.associatedVariableName}${uniforms});\\n`;\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GaussianSplattingBlock\", GaussianSplattingBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"gaussianSplattingBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,qCAA2B;AAMlD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IACzD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAE7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,qCAAqC,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAC3H,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACvH,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,MAAM,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAClH,IAAI,CAAC,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,CAAC,iBAAiB,IAAI,8CAA8C,aAAa,CAAC,sBAAsB,kCAAkC,CAAC;YACpJ,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,iBAAiB,IAAI,wBAAwB,KAAK,CAAC,sBAAsB,IAAI,CAAC;gBACpF,KAAK,CAAC,iBAAiB,IAAI,4CAA4C,CAAC;gBACxE,KAAK,CAAC,iBAAiB,IAAI,wCAAwC,aAAa,CAAC,sBAAsB,yBAAyB,CAAC;YACrI,CAAC;YAED,KAAK,CAAC,iBAAiB,IAAI,cAAc,IAAI,gBAAgB,CAAC;YAC9D,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,6BAA6B,CAAC;YACpF,KAAK,CAAC,iBAAiB,IAAI,SAAS,CAAC;YACrC,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,IAAI,eAAe,CAAC;YACpF,KAAK,CAAC,iBAAiB,IAAI,WAAW,CAAC;QAC3C,CAAC;aAAM,CAAC;YACJ,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,IAAI,aAAa,CAAC;QACtF,CAAC;QAED,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,wBAAwB,KAAK,KAAK,aAAa,CAAC,sBAAsB,KAAK,mBAAmB,iBAAiB,KAAK,CAAC,sBAAsB,KAAK,IAAI,CAAC,sBAAsB,KAAK,UAAU,CAAC,sBAAsB,GAAG,QAAQ,MAAM,CAAC;QAC7R,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { VertexBuffer } from \"core/Meshes/buffer\";\r\nimport type { GaussianSplattingMesh } from \"core/Meshes/GaussianSplatting/gaussianSplattingMesh\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\n\r\n/**\r\n * Block used for the Gaussian Splatting\r\n */\r\nexport class GaussianSplattingBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new GaussianSplattingBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Vertex);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"splatScale\", NodeMaterialBlockConnectionPointTypes.Vector2, true, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"world\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"view\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"projection\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerOutput(\"splatVertex\", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Vertex);\r\n this.registerOutput(\"SH\", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Vertex);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GaussianSplattingBlock\";\r\n }\r\n\r\n /**\r\n * Gets the position input component\r\n */\r\n public get splatPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get splatScale(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the View matrix input component\r\n */\r\n public get world(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the View matrix input component\r\n */\r\n public get view(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the projection matrix input component\r\n */\r\n public get projection(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the splatVertex output component\r\n */\r\n public get splatVertex(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the SH output contribution\r\n */\r\n public get SH(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"focal\");\r\n state._excludeVariableName(\"invViewport\");\r\n state._excludeVariableName(\"kernelSize\");\r\n state._excludeVariableName(\"eyePosition\");\r\n }\r\n /**\r\n * Update defines for shader compilation\r\n * @param mesh defines the mesh to be rendered\r\n * @param nodeMaterial defines the node material requesting the update\r\n * @param defines defines the material defines to update\r\n */\r\n public override prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n if (mesh.getClassName() == \"GaussianSplattingMesh\") {\r\n defines.setValue(\"SH_DEGREE\", (<GaussianSplattingMesh>mesh).shDegree, true);\r\n }\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n return;\r\n }\r\n\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n const comments = `//${this.name}`;\r\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\r\n state._emitFunctionFromInclude(\"helperFunctions\", comments);\r\n state._emitUniformFromString(\"focal\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n state._emitUniformFromString(\"invViewport\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n state._emitUniformFromString(\"kernelSize\", NodeMaterialBlockConnectionPointTypes.Float);\r\n state._emitUniformFromString(\"eyePosition\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n state.attributes.push(VertexBuffer.PositionKind);\r\n state.sharedData.nodeMaterial.backFaceCulling = false;\r\n\r\n const splatPosition = this.splatPosition;\r\n const splatScale = this.splatScale;\r\n const world = this.world;\r\n const view = this.view;\r\n const projection = this.projection;\r\n const output = this.splatVertex;\r\n const sh = this.SH;\r\n\r\n const addF = state.fSuffix;\r\n let splatScaleParameter = `vec2${addF}(1.,1.)`;\r\n if (splatScale.isConnected) {\r\n splatScaleParameter = splatScale.associatedVariableName;\r\n }\r\n\r\n let input = \"position\";\r\n let uniforms = \"\";\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n input = \"input.position\";\r\n uniforms = \", uniforms.focal, uniforms.invViewport, uniforms.kernelSize\";\r\n }\r\n if (this.SH.isConnected) {\r\n state.compilationString += `#if SH_DEGREE > 0\\n`;\r\n\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `let worldRot: mat3x3f = mat3x3f(${world.associatedVariableName}[0].xyz, ${world.associatedVariableName}[1].xyz, ${world.associatedVariableName}[2].xyz);`;\r\n state.compilationString += `let normWorldRot: mat3x3f = inverseMat3(worldRot);`;\r\n state.compilationString += `var dir: vec3f = normalize(normWorldRot * (${splatPosition.associatedVariableName}.xyz - uniforms.eyePosition));\\n`;\r\n } else {\r\n state.compilationString += `mat3 worldRot = mat3(${world.associatedVariableName});`;\r\n state.compilationString += `mat3 normWorldRot = inverseMat3(worldRot);`;\r\n state.compilationString += `vec3 dir = normalize(normWorldRot * (${splatPosition.associatedVariableName}.xyz - eyePosition));\\n`;\r\n }\r\n\r\n state.compilationString += `dir *= vec3${addF}(1.,1.,-1.);\\n`;\r\n state.compilationString += `${state._declareOutput(sh)} = computeSH(splat, dir);\\n`;\r\n state.compilationString += `#else\\n`;\r\n state.compilationString += `${state._declareOutput(sh)} = vec3${addF}(0.,0.,0.);\\n`;\r\n state.compilationString += `#endif;\\n`;\r\n } else {\r\n state.compilationString += `${state._declareOutput(sh)} = vec3${addF}(0.,0.,0.);`;\r\n }\r\n\r\n state.compilationString += `${state._declareOutput(output)} = gaussianSplatting(${input}, ${splatPosition.associatedVariableName}, ${splatScaleParameter}, covA, covB, ${world.associatedVariableName}, ${view.associatedVariableName}, ${projection.associatedVariableName}${uniforms});\\n`;\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GaussianSplattingBlock\", GaussianSplattingBlock);\r\n"]}
|
|
@@ -76,6 +76,9 @@ export class SplatReaderBlock extends NodeMaterialBlock {
|
|
|
76
76
|
state._emit2DSampler("covariancesBTexture");
|
|
77
77
|
state._emit2DSampler("centersTexture");
|
|
78
78
|
state._emit2DSampler("colorsTexture");
|
|
79
|
+
state._emit2DSampler("shTexture0", "SH_DEGREE > 0", undefined, undefined, true, "highp");
|
|
80
|
+
state._emit2DSampler("shTexture1", "SH_DEGREE > 0", undefined, undefined, true, "highp");
|
|
81
|
+
state._emit2DSampler("shTexture2", "SH_DEGREE > 0", undefined, undefined, true, "highp");
|
|
79
82
|
state._emitFunctionFromInclude("gaussianSplattingVertexDeclaration", comments);
|
|
80
83
|
state._emitFunctionFromInclude("gaussianSplatting", comments);
|
|
81
84
|
state._emitVaryingFromString("vPosition", NodeMaterialBlockConnectionPointTypes.Vector2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splatReaderBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,gEAAmE;AAMvG;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAE7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,KAAK,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAEtH,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,qCAAqC,CAAC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACrH,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,qCAAqC,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACrH,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5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C,CAAC;
|
|
1
|
+
{"version":3,"file":"splatReaderBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,gEAAmE;AAMvG;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAE7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,KAAK,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAEtH,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,qCAAqC,CAAC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACrH,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,qCAAqC,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACrH,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,QAAQ,C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AK,CAAC,iBAAiB,IAAI,8EAA8E,CAAC;YAC1G,KAAK,CAAC,iBAAiB,IAAI,yBAAyB,CAAC;QACzD,CAAC;QACD,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,iBAAiB,gBAAgB,CAAC;QACzG,KAAK,CAAC,iBAAiB,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,iBAAiB,WAAW,CAAC;QAEjG,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport type { NodeMaterial } from \"../../nodeMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used for Reading components of the Gaussian Splatting\r\n */\r\nexport class SplatReaderBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new SplatReaderBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Vertex);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"splatIndex\", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerOutput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockTargets.Vertex);\r\n this.registerOutput(\"splatColor\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Vertex);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SplatReaderBlock\";\r\n }\r\n\r\n /**\r\n * Gets the splat index input component\r\n */\r\n public get splatIndex(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the splatPosition output component\r\n */\r\n public get splatPosition(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the splatColor output component\r\n */\r\n public get splatColor(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"covA\");\r\n state._excludeVariableName(\"covB\");\r\n state._excludeVariableName(\"vPosition\");\r\n state._excludeVariableName(\"covariancesATexture\");\r\n state._excludeVariableName(\"covariancesBTexture\");\r\n state._excludeVariableName(\"centersTexture\");\r\n state._excludeVariableName(\"colorsTexture\");\r\n state._excludeVariableName(\"dataTextureSize\");\r\n }\r\n\r\n public override bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if (!mesh) {\r\n return;\r\n }\r\n const scene = mesh.getScene();\r\n GaussianSplattingMaterial.BindEffect(mesh, effect, scene);\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n return;\r\n }\r\n\r\n state.sharedData.bindableBlocks.push(this);\r\n\r\n // Emit code\r\n const comments = `//${this.name}`;\r\n state._emit2DSampler(\"covariancesATexture\");\r\n state._emit2DSampler(\"covariancesBTexture\");\r\n state._emit2DSampler(\"centersTexture\");\r\n state._emit2DSampler(\"colorsTexture\");\r\n state._emit2DSampler(\"shTexture0\", \"SH_DEGREE > 0\", undefined, undefined, true, \"highp\");\r\n state._emit2DSampler(\"shTexture1\", \"SH_DEGREE > 0\", undefined, undefined, true, \"highp\");\r\n state._emit2DSampler(\"shTexture2\", \"SH_DEGREE > 0\", undefined, undefined, true, \"highp\");\r\n\r\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\r\n state._emitVaryingFromString(\"vPosition\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n state._emitUniformFromString(\"dataTextureSize\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n const splatIndex = this.splatIndex;\r\n const splatPosition = this.splatPosition;\r\n const splatColor = this.splatColor;\r\n\r\n const splatVariablename = state._getFreeVariableName(\"splat\");\r\n\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `var ${splatVariablename}: Splat = readSplat(${splatIndex.associatedVariableName}, uniforms.dataTextureSize);\\n`;\r\n state.compilationString += `var covA: vec3f = splat.covA.xyz; var covB: vec3f = vec3f(splat.covA.w, splat.covB.xy);\\n`;\r\n state.compilationString += \"vertexOutputs.vPosition = input.position;\\n\";\r\n } else {\r\n state.compilationString += `Splat ${splatVariablename} = readSplat(${splatIndex.associatedVariableName});\\n`;\r\n state.compilationString += `vec3 covA = splat.covA.xyz; vec3 covB = vec3(splat.covA.w, splat.covB.xy);\\n`;\r\n state.compilationString += \"vPosition = position;\\n\";\r\n }\r\n state.compilationString += `${state._declareOutput(splatPosition)} = ${splatVariablename}.center.xyz;\\n`;\r\n state.compilationString += `${state._declareOutput(splatColor)} = ${splatVariablename}.color;\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SplatReaderBlock\", SplatReaderBlock);\r\n"]}
|
|
@@ -120,7 +120,7 @@ export declare class NodeMaterialBuildState {
|
|
|
120
120
|
/**
|
|
121
121
|
* @internal
|
|
122
122
|
*/
|
|
123
|
-
_emit2DSampler(name: string, define?: string, force?: boolean, annotation?: string): void;
|
|
123
|
+
_emit2DSampler(name: string, define?: string, force?: boolean, annotation?: string, unsignedSampler?: boolean, precision?: string): void;
|
|
124
124
|
/**
|
|
125
125
|
* @internal
|
|
126
126
|
*/
|