@babylonjs/core 8.40.1 → 8.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engines/Extensions/engine.computeShader.d.ts +2 -3
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/ICanvas.d.ts +3 -3
- package/Engines/ICanvas.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -2
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +29 -14
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +12 -41
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +106 -184
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +4 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +3 -1
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.d.ts +1 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.d.ts +1 -2
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js +10 -2
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +1 -4
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +7 -4
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +17 -58
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +112 -122
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +11 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +62 -26
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +18 -8
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +1 -2
- package/FrameGraph/frameGraph.js +2 -2
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.js +2 -2
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.js +3 -3
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +1 -1
- package/FrameGraph/frameGraphTask.js +2 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphUtils.d.ts +2 -2
- package/FrameGraph/frameGraphUtils.js +6 -6
- package/FrameGraph/frameGraphUtils.js.map +1 -1
- package/Lights/lightingVolume.d.ts +1 -0
- package/Lights/lightingVolume.js +14 -13
- package/Lights/lightingVolume.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +1 -0
- package/Materials/Node/Blocks/triPlanarBlock.js +33 -4
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.d.ts +5 -1
- package/Materials/materialHelper.geometryrendering.js +11 -2
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +6 -2
- package/Rendering/objectRenderer.js +69 -63
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +2 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,10 +2,6 @@ import type { Camera, DirectionalLight, FrameGraph, FrameGraphObjectList, FrameG
|
|
|
2
2
|
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
3
3
|
import { Color3 } from "../../../Maths/math.color.js";
|
|
4
4
|
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
5
|
-
import "../../../Shaders/volumetricLightingRenderVolume.vertex.js";
|
|
6
|
-
import "../../../Shaders/volumetricLightingRenderVolume.fragment.js";
|
|
7
|
-
import "../../../ShadersWGSL/volumetricLightingRenderVolume.vertex.js";
|
|
8
|
-
import "../../../ShadersWGSL/volumetricLightingRenderVolume.fragment.js";
|
|
9
5
|
/**
|
|
10
6
|
* A frame graph task that performs volumetric lighting.
|
|
11
7
|
*/
|
|
@@ -86,6 +82,7 @@ export declare class FrameGraphVolumetricLightingTask extends FrameGraphTask {
|
|
|
86
82
|
* @param enableExtinction Whether to enable extinction in the volumetric lighting effect (default: false). If you don't plan to set extinction to something different than (0, 0, 0), you can disable this to save some performance.
|
|
87
83
|
*/
|
|
88
84
|
constructor(name: string, frameGraph: FrameGraph, enableExtinction?: boolean);
|
|
85
|
+
initAsync(): Promise<unknown>;
|
|
89
86
|
isReady(): boolean;
|
|
90
87
|
getClassName(): string;
|
|
91
88
|
record(skipCreationOfDisabledPasses?: boolean): void;
|
|
@@ -6,10 +6,6 @@ import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
|
6
6
|
import { FrameGraphClearTextureTask } from "../Texture/clearTextureTask.js";
|
|
7
7
|
import { FrameGraphObjectRendererTask } from "../Rendering/objectRendererTask.js";
|
|
8
8
|
import { ShaderMaterial } from "../../../Materials/shaderMaterial.js";
|
|
9
|
-
import "../../../Shaders/volumetricLightingRenderVolume.vertex.js";
|
|
10
|
-
import "../../../Shaders/volumetricLightingRenderVolume.fragment.js";
|
|
11
|
-
import "../../../ShadersWGSL/volumetricLightingRenderVolume.vertex.js";
|
|
12
|
-
import "../../../ShadersWGSL/volumetricLightingRenderVolume.fragment.js";
|
|
13
9
|
const InvViewProjectionMatrix = new Matrix();
|
|
14
10
|
/**
|
|
15
11
|
* A frame graph task that performs volumetric lighting.
|
|
@@ -113,6 +109,13 @@ export class FrameGraphVolumetricLightingTask extends FrameGraphTask {
|
|
|
113
109
|
this.extinction = new Vector3(this.extinction.x, this.extinction.y, this.extinction.z);
|
|
114
110
|
this.lightPower = this._lightPower;
|
|
115
111
|
}
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
113
|
+
initAsync() {
|
|
114
|
+
if (this._frameGraph.engine.isWebGPU) {
|
|
115
|
+
return Promise.all([import("../../../ShadersWGSL/volumetricLightingRenderVolume.vertex.js"), import("../../../ShadersWGSL/volumetricLightingRenderVolume.fragment.js")]);
|
|
116
|
+
}
|
|
117
|
+
return Promise.all([import("../../../Shaders/volumetricLightingRenderVolume.vertex.js"), import("../../../Shaders/volumetricLightingRenderVolume.fragment.js")]);
|
|
118
|
+
}
|
|
116
119
|
isReady() {
|
|
117
120
|
return (this._renderLightingVolumeMaterial.isReady() &&
|
|
118
121
|
this._clearLightingVolumeTextureTask.isReady() &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"volumetricLightingTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2CAA2C,EAAE,MAAM,qCAAqC,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,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O,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAE7E,YAAY,CAAC,cAAc,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,6BAA6B,EAAE,OAAO,EAAE,CAAC;QAC9C,IAAI,CAAC,+BAA+B,CAAC,OAAO,EAAE,CAAC;QAC/C,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC;QACxC,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { Camera, DirectionalLight, FrameGraph, FrameGraphObjectList, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphVolumetricLightingBlendVolumeTask } from \"./volumetricLightingBlendVolumeTask\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphClearTextureTask } from \"../Texture/clearTextureTask\";\r\nimport { FrameGraphObjectRendererTask } from \"../Rendering/objectRendererTask\";\r\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\nimport \"core/Shaders/volumetricLightingRenderVolume.vertex\";\r\nimport \"core/Shaders/volumetricLightingRenderVolume.fragment\";\r\nimport \"core/ShadersWGSL/volumetricLightingRenderVolume.vertex\";\r\nimport \"core/ShadersWGSL/volumetricLightingRenderVolume.fragment\";\r\n\r\nconst InvViewProjectionMatrix = new Matrix();\r\n\r\n/**\r\n * A frame graph task that performs volumetric lighting.\r\n */\r\nexport class FrameGraphVolumetricLightingTask extends FrameGraphTask {\r\n /**\r\n * The target texture to which the volumetric lighting will be applied.\r\n */\r\n public targetTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use when blending the volumetric lighting texture with targetTexture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The depth texture used for volumetric lighting calculations.\r\n * It must be the depth texture used to generate targetTexture.\r\n */\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The camera used for volumetric lighting calculations.\r\n */\r\n public camera: Camera;\r\n\r\n /**\r\n * The mesh representing the lighting volume.\r\n * This is the mesh that will be rendered to create the volumetric lighting effect.\r\n */\r\n public lightingVolumeMesh: FrameGraphObjectList;\r\n\r\n /**\r\n * The directional light used for volumetric lighting.\r\n */\r\n public light: DirectionalLight;\r\n\r\n /**\r\n * The lighting volume texture (optional).\r\n * If not provided, a new texture will be created, which the same size, format and type as targetTexture.\r\n * This is the texture that will store the volumetric lighting information, before being blended to targetTexture.\r\n */\r\n public lightingVolumeTexture?: FrameGraphTextureHandle;\r\n\r\n private _extinctionPhaseG = new Vector4(0, 0, 0, 0);\r\n\r\n /**\r\n * The phase G parameter for the volumetric lighting effect (default: 0).\r\n * This parameter controls the anisotropy of the scattering.\r\n * A value of 0 means isotropic scattering, while a value of 1 means forward scattering and -1 means backward scattering.\r\n */\r\n public get phaseG() {\r\n return this._extinctionPhaseG.w;\r\n }\r\n\r\n public set phaseG(value: number) {\r\n this._extinctionPhaseG.w = value;\r\n this._renderLightingVolumeMaterial.setVector4(\"extinctionPhaseG\", this._extinctionPhaseG);\r\n }\r\n\r\n /**\r\n * Whether to enable extinction in the volumetric lighting effect (default: false).\r\n * Read-only property set in the constructor.\r\n */\r\n public readonly enableExtinction: boolean;\r\n\r\n /**\r\n * The extinction coefficient for the volumetric lighting effect (default: (0, 0, 0) - no extinction).\r\n * This parameter controls how much light is absorbed and scattered as it travels through the medium.\r\n * Will only have an effect if enableExtinction is set to true in the constructor!\r\n */\r\n public get extinction() {\r\n return this._blendLightingVolumeTask.postProcess.extinction;\r\n }\r\n\r\n public set extinction(value: Vector3) {\r\n this._extinctionPhaseG.x = Math.max(value.x, 1e-6);\r\n this._extinctionPhaseG.y = Math.max(value.y, 1e-6);\r\n this._extinctionPhaseG.z = Math.max(value.z, 1e-6);\r\n this._renderLightingVolumeMaterial.setVector4(\"extinctionPhaseG\", this._extinctionPhaseG);\r\n this._blendLightingVolumeTask.postProcess.extinction.copyFromFloats(this._extinctionPhaseG.x, this._extinctionPhaseG.y, this._extinctionPhaseG.z);\r\n }\r\n\r\n private _lightPower = new Color3(1, 1, 1);\r\n\r\n /**\r\n * The light power/color for the volumetric lighting effect (default: (1, 1, 1)).\r\n * This parameter controls the intensity and color of the light used for volumetric lighting.\r\n */\r\n public get lightPower() {\r\n return this._lightPower;\r\n }\r\n\r\n public set lightPower(value: Color3) {\r\n this._lightPower.copyFrom(value);\r\n this._renderLightingVolumeMaterial.setColor3(\"lightPower\", this._lightPower);\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(name: string) {\r\n this._name = name;\r\n if (this._renderLightingVolumeMaterial) {\r\n this._renderLightingVolumeMaterial.name = `${name} - render lighting volume`;\r\n }\r\n if (this._clearLightingVolumeTextureTask) {\r\n this._clearLightingVolumeTextureTask.name = `${name} - clear lighting volume texture`;\r\n }\r\n if (this._renderLightingVolumeTask) {\r\n this._renderLightingVolumeTask.name = `${name} - render lighting volume`;\r\n }\r\n if (this._blendLightingVolumeTask) {\r\n this._blendLightingVolumeTask.name = `${name} - blend lighting volume`;\r\n }\r\n }\r\n\r\n /**\r\n * The output texture of the task. It will be the same as targetTexture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n private readonly _clearLightingVolumeTextureTask: FrameGraphClearTextureTask;\r\n private readonly _renderLightingVolumeTask: FrameGraphObjectRendererTask;\r\n private readonly _blendLightingVolumeTask: FrameGraphVolumetricLightingBlendVolumeTask;\r\n private _renderLightingVolumeMaterial: ShaderMaterial;\r\n\r\n /**\r\n * Creates a new FrameGraphVolumetricLightingTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph to which the task belongs.\r\n * @param enableExtinction Whether to enable extinction in the volumetric lighting effect (default: false). If you don't plan to set extinction to something different than (0, 0, 0), you can disable this to save some performance.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, enableExtinction = false) {\r\n super(name, frameGraph);\r\n\r\n this.enableExtinction = enableExtinction;\r\n\r\n const isWebGPU = this._frameGraph.engine.isWebGPU;\r\n\r\n this._renderLightingVolumeMaterial = new ShaderMaterial(`${name} - render lighting volume`, this._frameGraph.scene, \"volumetricLightingRenderVolume\", {\r\n attributes: [\"position\"],\r\n uniformBuffers: [\"Scene\", \"Mesh\"],\r\n uniforms: [\"world\", \"viewProjection\", \"vEyePosition\", \"lightDir\", \"invViewProjection\", \"outputTextureSize\", \"extinctionPhaseG\", \"lightPower\", \"textureRatio\"],\r\n samplers: [\"depthTexture\"],\r\n defines: enableExtinction ? [\"USE_EXTINCTION\"] : [],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n needAlphaBlending: true,\r\n });\r\n this._renderLightingVolumeMaterial.backFaceCulling = false;\r\n this._renderLightingVolumeMaterial.alphaMode = Constants.ALPHA_ADD;\r\n this._renderLightingVolumeMaterial.onBindObservable.add(() => {\r\n this._renderLightingVolumeMaterial.bindEyePosition(this._renderLightingVolumeMaterial.getEffect());\r\n });\r\n\r\n this._clearLightingVolumeTextureTask = new FrameGraphClearTextureTask(`clear lighting volume texture`, frameGraph);\r\n this._renderLightingVolumeTask = new FrameGraphObjectRendererTask(`render lighting volume`, frameGraph, frameGraph.scene);\r\n this._blendLightingVolumeTask = new FrameGraphVolumetricLightingBlendVolumeTask(`blend lighting volume texture`, frameGraph, enableExtinction);\r\n\r\n this.onTexturesAllocatedObservable.add(() => {\r\n this._renderLightingVolumeMaterial.setInternalTexture(\"depthTexture\", frameGraph.textureManager.getTextureFromHandle(this.depthTexture)!);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n\r\n // Triggers the setters to set the uniforms\r\n this.phaseG = this._extinctionPhaseG.w;\r\n this.extinction = new Vector3(this.extinction.x, this.extinction.y, this.extinction.z);\r\n this.lightPower = this._lightPower;\r\n }\r\n\r\n public override isReady() {\r\n return (\r\n this._renderLightingVolumeMaterial.isReady() &&\r\n this._clearLightingVolumeTextureTask.isReady() &&\r\n this._renderLightingVolumeMaterial.isReady() &&\r\n this._blendLightingVolumeTask.isReady()\r\n );\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphVolumetricLightingTask\";\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false) {\r\n if (this.targetTexture === undefined || this.depthTexture === undefined || this.camera === undefined || this.lightingVolumeMesh === undefined || this.light === undefined) {\r\n throw new Error(`FrameGraphVolumetricLightingTask \"${this.name}\": targetTexture, depthTexture, camera, lightingVolumeMesh and light are required`);\r\n }\r\n if (!this.lightingVolumeMesh.meshes || this.lightingVolumeMesh.meshes.length === 0) {\r\n throw new Error(`FrameGraphVolumetricLightingTask \"${this.name}\": lightingVolumeMesh is empty`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n\r\n let lightingVolumeTexture = this.lightingVolumeTexture;\r\n if (!lightingVolumeTexture) {\r\n const targetTextureCreationOptions = textureManager.getTextureCreationOptions(this.targetTexture);\r\n\r\n targetTextureCreationOptions.options.labels = [\"InScattering\"];\r\n targetTextureCreationOptions.options.samples = 1;\r\n\r\n lightingVolumeTexture = textureManager.createRenderTargetTexture(`${this.name} - lighting volume texture`, targetTextureCreationOptions);\r\n }\r\n\r\n this.lightingVolumeMesh.meshes[0].material = this._renderLightingVolumeMaterial;\r\n\r\n const targetTextureSize = textureManager.getTextureAbsoluteDimensions(this.targetTexture);\r\n const volumeTextureSize = textureManager.getTextureAbsoluteDimensions(lightingVolumeTexture);\r\n\r\n this._renderLightingVolumeMaterial.setVector2(\r\n \"textureRatio\",\r\n new Vector2(targetTextureSize.width / volumeTextureSize.width, targetTextureSize.height / volumeTextureSize.height)\r\n );\r\n this._renderLightingVolumeMaterial.setVector2(\"outputTextureSize\", new Vector2(volumeTextureSize.width, volumeTextureSize.height));\r\n\r\n const passUpdateMaterial = this._frameGraph.addPass(this.name);\r\n\r\n passUpdateMaterial.setExecuteFunc(() => {\r\n this.camera.getTransformationMatrix().invertToRef(InvViewProjectionMatrix);\r\n\r\n this._renderLightingVolumeMaterial.setMatrix(\"invViewProjection\", InvViewProjectionMatrix);\r\n this._renderLightingVolumeMaterial.setVector3(\"lightDir\", this.light.direction.normalizeToRef(TmpVectors.Vector3[0]));\r\n });\r\n\r\n this._clearLightingVolumeTextureTask.clearColor = true;\r\n this._clearLightingVolumeTextureTask.clearStencil = this.enableExtinction;\r\n this._clearLightingVolumeTextureTask.color = new Color4(0, 0, 0, 1);\r\n this._clearLightingVolumeTextureTask.stencilValue = 0;\r\n this._clearLightingVolumeTextureTask.targetTexture = lightingVolumeTexture;\r\n this._clearLightingVolumeTextureTask.record(true);\r\n\r\n this._renderLightingVolumeTask.targetTexture = this._clearLightingVolumeTextureTask.outputTexture;\r\n this._renderLightingVolumeTask.objectList = this.lightingVolumeMesh;\r\n this._renderLightingVolumeTask.camera = this.camera;\r\n this._renderLightingVolumeTask.disableImageProcessing = true;\r\n this._renderLightingVolumeTask.depthTest = false;\r\n this._renderLightingVolumeTask.record(true);\r\n\r\n this._blendLightingVolumeTask.sourceTexture = this._renderLightingVolumeTask.outputTexture;\r\n this._blendLightingVolumeTask.sourceSamplingMode = this.sourceSamplingMode;\r\n this._blendLightingVolumeTask.targetTexture = this.targetTexture;\r\n this._blendLightingVolumeTask.depthTexture = this.depthTexture;\r\n this._blendLightingVolumeTask.camera = this.camera;\r\n this._blendLightingVolumeTask.record(true);\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const disabledPass = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n disabledPass.setExecuteFunc(() => {});\r\n }\r\n }\r\n\r\n public override dispose() {\r\n this._renderLightingVolumeMaterial?.dispose();\r\n this._clearLightingVolumeTextureTask.dispose();\r\n this._renderLightingVolumeTask.dispose();\r\n this._blendLightingVolumeTask.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"volumetricLightingTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2CAA2C,EAAE,MAAM,qCAAqC,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,qCAA8B;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,6CAAsC;AAG/D,MAAM,uBAAuB,GAAG,IAAI,MAAM,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,gCAAiC,SAAQ,cAAc;IA0ChE;;;;OAIG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,KAAK,CAAC;QACjC,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,kBAAkB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9F,CAAC;IAQD;;;;OAIG;IACH,IAAW,UAAU;QACjB,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GraphObjectList, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphVolumetricLightingBlendVolumeTask } from \"./volumetricLightingBlendVolumeTask\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphClearTextureTask } from \"../Texture/clearTextureTask\";\r\nimport { FrameGraphObjectRendererTask } from \"../Rendering/objectRendererTask\";\r\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\nconst InvViewProjectionMatrix = new Matrix();\r\n\r\n/**\r\n * A frame graph task that performs volumetric lighting.\r\n */\r\nexport class FrameGraphVolumetricLightingTask extends FrameGraphTask {\r\n /**\r\n * The target texture to which the volumetric lighting will be applied.\r\n */\r\n public targetTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use when blending the volumetric lighting texture with targetTexture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The depth texture used for volumetric lighting calculations.\r\n * It must be the depth texture used to generate targetTexture.\r\n */\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The camera used for volumetric lighting calculations.\r\n */\r\n public camera: Camera;\r\n\r\n /**\r\n * The mesh representing the lighting volume.\r\n * This is the mesh that will be rendered to create the volumetric lighting effect.\r\n */\r\n public lightingVolumeMesh: FrameGraphObjectList;\r\n\r\n /**\r\n * The directional light used for volumetric lighting.\r\n */\r\n public light: DirectionalLight;\r\n\r\n /**\r\n * The lighting volume texture (optional).\r\n * If not provided, a new texture will be created, which the same size, format and type as targetTexture.\r\n * This is the texture that will store the volumetric lighting information, before being blended to targetTexture.\r\n */\r\n public lightingVolumeTexture?: FrameGraphTextureHandle;\r\n\r\n private _extinctionPhaseG = new Vector4(0, 0, 0, 0);\r\n\r\n /**\r\n * The phase G parameter for the volumetric lighting effect (default: 0).\r\n * This parameter controls the anisotropy of the scattering.\r\n * A value of 0 means isotropic scattering, while a value of 1 means forward scattering and -1 means backward scattering.\r\n */\r\n public get phaseG() {\r\n return this._extinctionPhaseG.w;\r\n }\r\n\r\n public set phaseG(value: number) {\r\n this._extinctionPhaseG.w = value;\r\n this._renderLightingVolumeMaterial.setVector4(\"extinctionPhaseG\", this._extinctionPhaseG);\r\n }\r\n\r\n /**\r\n * Whether to enable extinction in the volumetric lighting effect (default: false).\r\n * Read-only property set in the constructor.\r\n */\r\n public readonly enableExtinction: boolean;\r\n\r\n /**\r\n * The extinction coefficient for the volumetric lighting effect (default: (0, 0, 0) - no extinction).\r\n * This parameter controls how much light is absorbed and scattered as it travels through the medium.\r\n * Will only have an effect if enableExtinction is set to true in the constructor!\r\n */\r\n public get extinction() {\r\n return this._blendLightingVolumeTask.postProcess.extinction;\r\n }\r\n\r\n public set extinction(value: Vector3) {\r\n this._extinctionPhaseG.x = Math.max(value.x, 1e-6);\r\n this._extinctionPhaseG.y = Math.max(value.y, 1e-6);\r\n this._extinctionPhaseG.z = Math.max(value.z, 1e-6);\r\n this._renderLightingVolumeMaterial.setVector4(\"extinctionPhaseG\", this._extinctionPhaseG);\r\n this._blendLightingVolumeTask.postProcess.extinction.copyFromFloats(this._extinctionPhaseG.x, this._extinctionPhaseG.y, this._extinctionPhaseG.z);\r\n }\r\n\r\n private _lightPower = new Color3(1, 1, 1);\r\n\r\n /**\r\n * The light power/color for the volumetric lighting effect (default: (1, 1, 1)).\r\n * This parameter controls the intensity and color of the light used for volumetric lighting.\r\n */\r\n public get lightPower() {\r\n return this._lightPower;\r\n }\r\n\r\n public set lightPower(value: Color3) {\r\n this._lightPower.copyFrom(value);\r\n this._renderLightingVolumeMaterial.setColor3(\"lightPower\", this._lightPower);\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(name: string) {\r\n this._name = name;\r\n if (this._renderLightingVolumeMaterial) {\r\n this._renderLightingVolumeMaterial.name = `${name} - render lighting volume`;\r\n }\r\n if (this._clearLightingVolumeTextureTask) {\r\n this._clearLightingVolumeTextureTask.name = `${name} - clear lighting volume texture`;\r\n }\r\n if (this._renderLightingVolumeTask) {\r\n this._renderLightingVolumeTask.name = `${name} - render lighting volume`;\r\n }\r\n if (this._blendLightingVolumeTask) {\r\n this._blendLightingVolumeTask.name = `${name} - blend lighting volume`;\r\n }\r\n }\r\n\r\n /**\r\n * The output texture of the task. It will be the same as targetTexture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n private readonly _clearLightingVolumeTextureTask: FrameGraphClearTextureTask;\r\n private readonly _renderLightingVolumeTask: FrameGraphObjectRendererTask;\r\n private readonly _blendLightingVolumeTask: FrameGraphVolumetricLightingBlendVolumeTask;\r\n private _renderLightingVolumeMaterial: ShaderMaterial;\r\n\r\n /**\r\n * Creates a new FrameGraphVolumetricLightingTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph to which the task belongs.\r\n * @param enableExtinction Whether to enable extinction in the volumetric lighting effect (default: false). If you don't plan to set extinction to something different than (0, 0, 0), you can disable this to save some performance.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, enableExtinction = false) {\r\n super(name, frameGraph);\r\n\r\n this.enableExtinction = enableExtinction;\r\n\r\n const isWebGPU = this._frameGraph.engine.isWebGPU;\r\n\r\n this._renderLightingVolumeMaterial = new ShaderMaterial(`${name} - render lighting volume`, this._frameGraph.scene, \"volumetricLightingRenderVolume\", {\r\n attributes: [\"position\"],\r\n uniformBuffers: [\"Scene\", \"Mesh\"],\r\n uniforms: [\"world\", \"viewProjection\", \"vEyePosition\", \"lightDir\", \"invViewProjection\", \"outputTextureSize\", \"extinctionPhaseG\", \"lightPower\", \"textureRatio\"],\r\n samplers: [\"depthTexture\"],\r\n defines: enableExtinction ? [\"USE_EXTINCTION\"] : [],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n needAlphaBlending: true,\r\n });\r\n this._renderLightingVolumeMaterial.backFaceCulling = false;\r\n this._renderLightingVolumeMaterial.alphaMode = Constants.ALPHA_ADD;\r\n this._renderLightingVolumeMaterial.onBindObservable.add(() => {\r\n this._renderLightingVolumeMaterial.bindEyePosition(this._renderLightingVolumeMaterial.getEffect());\r\n });\r\n\r\n this._clearLightingVolumeTextureTask = new FrameGraphClearTextureTask(`clear lighting volume texture`, frameGraph);\r\n this._renderLightingVolumeTask = new FrameGraphObjectRendererTask(`render lighting volume`, frameGraph, frameGraph.scene);\r\n this._blendLightingVolumeTask = new FrameGraphVolumetricLightingBlendVolumeTask(`blend lighting volume texture`, frameGraph, enableExtinction);\r\n\r\n this.onTexturesAllocatedObservable.add(() => {\r\n this._renderLightingVolumeMaterial.setInternalTexture(\"depthTexture\", frameGraph.textureManager.getTextureFromHandle(this.depthTexture)!);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n\r\n // Triggers the setters to set the uniforms\r\n this.phaseG = this._extinctionPhaseG.w;\r\n this.extinction = new Vector3(this.extinction.x, this.extinction.y, this.extinction.z);\r\n this.lightPower = this._lightPower;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public override initAsync(): Promise<unknown> {\r\n if (this._frameGraph.engine.isWebGPU) {\r\n return Promise.all([import(\"../../../ShadersWGSL/volumetricLightingRenderVolume.vertex\"), import(\"../../../ShadersWGSL/volumetricLightingRenderVolume.fragment\")]);\r\n }\r\n\r\n return Promise.all([import(\"../../../Shaders/volumetricLightingRenderVolume.vertex\"), import(\"../../../Shaders/volumetricLightingRenderVolume.fragment\")]);\r\n }\r\n\r\n public override isReady() {\r\n return (\r\n this._renderLightingVolumeMaterial.isReady() &&\r\n this._clearLightingVolumeTextureTask.isReady() &&\r\n this._renderLightingVolumeMaterial.isReady() &&\r\n this._blendLightingVolumeTask.isReady()\r\n );\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphVolumetricLightingTask\";\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false) {\r\n if (this.targetTexture === undefined || this.depthTexture === undefined || this.camera === undefined || this.lightingVolumeMesh === undefined || this.light === undefined) {\r\n throw new Error(`FrameGraphVolumetricLightingTask \"${this.name}\": targetTexture, depthTexture, camera, lightingVolumeMesh and light are required`);\r\n }\r\n if (!this.lightingVolumeMesh.meshes || this.lightingVolumeMesh.meshes.length === 0) {\r\n throw new Error(`FrameGraphVolumetricLightingTask \"${this.name}\": lightingVolumeMesh is empty`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n\r\n let lightingVolumeTexture = this.lightingVolumeTexture;\r\n if (!lightingVolumeTexture) {\r\n const targetTextureCreationOptions = textureManager.getTextureCreationOptions(this.targetTexture);\r\n\r\n targetTextureCreationOptions.options.labels = [\"InScattering\"];\r\n targetTextureCreationOptions.options.samples = 1;\r\n\r\n lightingVolumeTexture = textureManager.createRenderTargetTexture(`${this.name} - lighting volume texture`, targetTextureCreationOptions);\r\n }\r\n\r\n this.lightingVolumeMesh.meshes[0].material = this._renderLightingVolumeMaterial;\r\n\r\n const targetTextureSize = textureManager.getTextureAbsoluteDimensions(this.targetTexture);\r\n const volumeTextureSize = textureManager.getTextureAbsoluteDimensions(lightingVolumeTexture);\r\n\r\n this._renderLightingVolumeMaterial.setVector2(\r\n \"textureRatio\",\r\n new Vector2(targetTextureSize.width / volumeTextureSize.width, targetTextureSize.height / volumeTextureSize.height)\r\n );\r\n this._renderLightingVolumeMaterial.setVector2(\"outputTextureSize\", new Vector2(volumeTextureSize.width, volumeTextureSize.height));\r\n\r\n const passUpdateMaterial = this._frameGraph.addPass(this.name);\r\n\r\n passUpdateMaterial.setExecuteFunc(() => {\r\n this.camera.getTransformationMatrix().invertToRef(InvViewProjectionMatrix);\r\n\r\n this._renderLightingVolumeMaterial.setMatrix(\"invViewProjection\", InvViewProjectionMatrix);\r\n this._renderLightingVolumeMaterial.setVector3(\"lightDir\", this.light.direction.normalizeToRef(TmpVectors.Vector3[0]));\r\n });\r\n\r\n this._clearLightingVolumeTextureTask.clearColor = true;\r\n this._clearLightingVolumeTextureTask.clearStencil = this.enableExtinction;\r\n this._clearLightingVolumeTextureTask.color = new Color4(0, 0, 0, 1);\r\n this._clearLightingVolumeTextureTask.stencilValue = 0;\r\n this._clearLightingVolumeTextureTask.targetTexture = lightingVolumeTexture;\r\n this._clearLightingVolumeTextureTask.record(true);\r\n\r\n this._renderLightingVolumeTask.targetTexture = this._clearLightingVolumeTextureTask.outputTexture;\r\n this._renderLightingVolumeTask.objectList = this.lightingVolumeMesh;\r\n this._renderLightingVolumeTask.camera = this.camera;\r\n this._renderLightingVolumeTask.disableImageProcessing = true;\r\n this._renderLightingVolumeTask.depthTest = false;\r\n this._renderLightingVolumeTask.record(true);\r\n\r\n this._blendLightingVolumeTask.sourceTexture = this._renderLightingVolumeTask.outputTexture;\r\n this._blendLightingVolumeTask.sourceSamplingMode = this.sourceSamplingMode;\r\n this._blendLightingVolumeTask.targetTexture = this.targetTexture;\r\n this._blendLightingVolumeTask.depthTexture = this.depthTexture;\r\n this._blendLightingVolumeTask.camera = this.camera;\r\n this._blendLightingVolumeTask.record(true);\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const disabledPass = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n disabledPass.setExecuteFunc(() => {});\r\n }\r\n }\r\n\r\n public override dispose() {\r\n this._renderLightingVolumeMaterial?.dispose();\r\n this._clearLightingVolumeTextureTask.dispose();\r\n this._renderLightingVolumeTask.dispose();\r\n this._blendLightingVolumeTask.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { FrameGraphTextureHandle, Scene,
|
|
2
|
-
import {
|
|
3
|
-
import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
|
|
1
|
+
import type { FrameGraphTextureHandle, Scene, FrameGraph, AbstractMesh, ObjectRendererOptions, FrameGraphRenderContext, FrameGraphRenderPass, ObjectRenderer } from "../../../index.js";
|
|
2
|
+
import { FrameGraphObjectRendererTask } from "./objectRendererTask.js";
|
|
4
3
|
/**
|
|
5
4
|
* Description of a texture used by the geometry renderer task.
|
|
6
5
|
*/
|
|
@@ -22,29 +21,7 @@ export interface IFrameGraphGeometryRendererTextureDescription {
|
|
|
22
21
|
/**
|
|
23
22
|
* Task used to render geometry to a set of textures.
|
|
24
23
|
*/
|
|
25
|
-
export declare class FrameGraphGeometryRendererTask extends
|
|
26
|
-
/**
|
|
27
|
-
* The depth texture attachment to use for rendering (optional).
|
|
28
|
-
*/
|
|
29
|
-
depthTexture?: FrameGraphTextureHandle;
|
|
30
|
-
private _camera;
|
|
31
|
-
/**
|
|
32
|
-
* Gets or sets the camera used for rendering.
|
|
33
|
-
*/
|
|
34
|
-
get camera(): Camera;
|
|
35
|
-
set camera(camera: Camera);
|
|
36
|
-
/**
|
|
37
|
-
* The object list used for rendering.
|
|
38
|
-
*/
|
|
39
|
-
objectList: FrameGraphObjectList;
|
|
40
|
-
/**
|
|
41
|
-
* Whether depth testing is enabled (default is true).
|
|
42
|
-
*/
|
|
43
|
-
depthTest: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Whether depth writing is enabled (default is true).
|
|
46
|
-
*/
|
|
47
|
-
depthWrite: boolean;
|
|
24
|
+
export declare class FrameGraphGeometryRendererTask extends FrameGraphObjectRendererTask {
|
|
48
25
|
/**
|
|
49
26
|
* The size of the output textures (default is 100% of the back buffer texture size).
|
|
50
27
|
*/
|
|
@@ -70,24 +47,18 @@ export declare class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
70
47
|
* Indicates if a mesh shouldn't be rendered when its material has depth write disabled (default is true).
|
|
71
48
|
*/
|
|
72
49
|
dontRenderWhenMaterialDepthWriteIsDisabled: boolean;
|
|
50
|
+
private _disableDepthPrePass;
|
|
73
51
|
/**
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* If true, depthTexture will be resolved at the end of the render pass, if this texture is provided and samples is greater than 1 (default: true)
|
|
52
|
+
* Indicates whether the depth pre-pass is disabled (default is true).
|
|
53
|
+
* Materials that require depth pre-pass (Material.needDepthPrePass == true) don't work with the geometry renderer, that's why this setting is true by default.
|
|
54
|
+
* However, if the geometry renderer doesn't generate any geometry textures but only renders to the main target texture, then depth pre-pass can be enabled.
|
|
79
55
|
*/
|
|
80
|
-
|
|
56
|
+
get disableDepthPrePass(): boolean;
|
|
57
|
+
set disableDepthPrePass(value: boolean);
|
|
81
58
|
/**
|
|
82
59
|
* The list of texture descriptions used by the geometry renderer task.
|
|
83
60
|
*/
|
|
84
61
|
textureDescriptions: IFrameGraphGeometryRendererTextureDescription[];
|
|
85
|
-
/**
|
|
86
|
-
* The output depth texture attachment texture.
|
|
87
|
-
* This texture will point to the same texture than the depthTexture property if it is set.
|
|
88
|
-
* Note, however, that the handle itself will be different!
|
|
89
|
-
*/
|
|
90
|
-
readonly outputDepthTexture: FrameGraphTextureHandle;
|
|
91
62
|
/**
|
|
92
63
|
* The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!
|
|
93
64
|
*/
|
|
@@ -133,26 +104,11 @@ export declare class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
133
104
|
* The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!
|
|
134
105
|
*/
|
|
135
106
|
readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;
|
|
136
|
-
/**
|
|
137
|
-
* The object renderer used by the geometry renderer task.
|
|
138
|
-
*/
|
|
139
|
-
get objectRenderer(): ObjectRenderer;
|
|
140
107
|
/**
|
|
141
108
|
* Gets or sets the name of the task.
|
|
142
109
|
*/
|
|
143
110
|
get name(): string;
|
|
144
111
|
set name(value: string);
|
|
145
|
-
private _forceLayerMaskCheck;
|
|
146
|
-
/**
|
|
147
|
-
* Force checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
|
|
148
|
-
*/
|
|
149
|
-
get forceLayerMaskCheck(): boolean;
|
|
150
|
-
set forceLayerMaskCheck(value: boolean);
|
|
151
|
-
private readonly _engine;
|
|
152
|
-
private readonly _scene;
|
|
153
|
-
private readonly _renderer;
|
|
154
|
-
private _textureWidth;
|
|
155
|
-
private _textureHeight;
|
|
156
112
|
private _clearAttachmentsLayout;
|
|
157
113
|
private _allAttachmentsLayout;
|
|
158
114
|
/**
|
|
@@ -161,8 +117,9 @@ export declare class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
161
117
|
* @param frameGraph The frame graph the task belongs to.
|
|
162
118
|
* @param scene The scene the frame graph is associated with.
|
|
163
119
|
* @param options The options of the object renderer.
|
|
120
|
+
* @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.
|
|
164
121
|
*/
|
|
165
|
-
constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions);
|
|
122
|
+
constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions, existingObjectRenderer?: ObjectRenderer);
|
|
166
123
|
/**
|
|
167
124
|
* Gets the list of excluded meshes from the velocity texture.
|
|
168
125
|
*/
|
|
@@ -179,12 +136,14 @@ export declare class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
179
136
|
* @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
|
|
180
137
|
*/
|
|
181
138
|
removeExcludedSkinnedMeshFromVelocityTexture(skinnedMesh: AbstractMesh): void;
|
|
182
|
-
isReady(): boolean;
|
|
183
139
|
getClassName(): string;
|
|
184
|
-
record():
|
|
140
|
+
record(skipCreationOfDisabledPasses?: boolean, additionalExecute?: (context: FrameGraphRenderContext) => void): FrameGraphRenderPass;
|
|
185
141
|
dispose(): void;
|
|
186
|
-
|
|
187
|
-
|
|
142
|
+
protected _resolveDanglingHandles(_targetTextures: FrameGraphTextureHandle[]): void;
|
|
143
|
+
protected _checkParameters(): void;
|
|
144
|
+
protected _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean;
|
|
145
|
+
protected _getTargetHandles(): FrameGraphTextureHandle[];
|
|
146
|
+
protected _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean): void;
|
|
188
147
|
private _buildClearAttachmentsLayout;
|
|
189
148
|
private _registerForRenderPassId;
|
|
190
149
|
}
|
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import { backbufferDepthStencilTextureHandle } from "../../frameGraphTypes.js";
|
|
2
1
|
import { Color4 } from "../../../Maths/math.color.js";
|
|
3
2
|
import { MaterialHelperGeometryRendering } from "../../../Materials/materialHelper.geometryrendering.js";
|
|
4
3
|
|
|
5
|
-
import {
|
|
6
|
-
import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
|
|
4
|
+
import { FrameGraphObjectRendererTask } from "./objectRendererTask.js";
|
|
7
5
|
const ClearColors = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(0, 0, 0, 0)];
|
|
8
6
|
/**
|
|
9
7
|
* Task used to render geometry to a set of textures.
|
|
10
8
|
*/
|
|
11
|
-
export class FrameGraphGeometryRendererTask extends
|
|
12
|
-
/**
|
|
13
|
-
* Gets or sets the camera used for rendering.
|
|
14
|
-
*/
|
|
15
|
-
get camera() {
|
|
16
|
-
return this._camera;
|
|
17
|
-
}
|
|
18
|
-
set camera(camera) {
|
|
19
|
-
this._camera = camera;
|
|
20
|
-
this._renderer.activeCamera = this.camera;
|
|
21
|
-
}
|
|
9
|
+
export class FrameGraphGeometryRendererTask extends FrameGraphObjectRendererTask {
|
|
22
10
|
/**
|
|
23
11
|
* Whether to reverse culling (default is false).
|
|
24
12
|
*/
|
|
@@ -33,10 +21,16 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
33
21
|
}
|
|
34
22
|
}
|
|
35
23
|
/**
|
|
36
|
-
*
|
|
24
|
+
* Indicates whether the depth pre-pass is disabled (default is true).
|
|
25
|
+
* Materials that require depth pre-pass (Material.needDepthPrePass == true) don't work with the geometry renderer, that's why this setting is true by default.
|
|
26
|
+
* However, if the geometry renderer doesn't generate any geometry textures but only renders to the main target texture, then depth pre-pass can be enabled.
|
|
37
27
|
*/
|
|
38
|
-
get
|
|
39
|
-
return this.
|
|
28
|
+
get disableDepthPrePass() {
|
|
29
|
+
return this._disableDepthPrePass;
|
|
30
|
+
}
|
|
31
|
+
set disableDepthPrePass(value) {
|
|
32
|
+
this._disableDepthPrePass = value;
|
|
33
|
+
this._renderer.disableDepthPrePass = value;
|
|
40
34
|
}
|
|
41
35
|
/**
|
|
42
36
|
* Gets or sets the name of the task.
|
|
@@ -50,36 +44,16 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
50
44
|
this._renderer.name = value;
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Force checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
|
|
55
|
-
*/
|
|
56
|
-
get forceLayerMaskCheck() {
|
|
57
|
-
return this._forceLayerMaskCheck;
|
|
58
|
-
}
|
|
59
|
-
set forceLayerMaskCheck(value) {
|
|
60
|
-
if (value === this._forceLayerMaskCheck) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this._forceLayerMaskCheck = value;
|
|
64
|
-
this._renderer.forceLayerMaskCheck = value;
|
|
65
|
-
}
|
|
66
47
|
/**
|
|
67
48
|
* Constructs a new geometry renderer task.
|
|
68
49
|
* @param name The name of the task.
|
|
69
50
|
* @param frameGraph The frame graph the task belongs to.
|
|
70
51
|
* @param scene The scene the frame graph is associated with.
|
|
71
52
|
* @param options The options of the object renderer.
|
|
53
|
+
* @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.
|
|
72
54
|
*/
|
|
73
|
-
constructor(name, frameGraph, scene, options) {
|
|
74
|
-
super(name, frameGraph);
|
|
75
|
-
/**
|
|
76
|
-
* Whether depth testing is enabled (default is true).
|
|
77
|
-
*/
|
|
78
|
-
this.depthTest = true;
|
|
79
|
-
/**
|
|
80
|
-
* Whether depth writing is enabled (default is true).
|
|
81
|
-
*/
|
|
82
|
-
this.depthWrite = true;
|
|
55
|
+
constructor(name, frameGraph, scene, options, existingObjectRenderer) {
|
|
56
|
+
super(name, frameGraph, scene, options, existingObjectRenderer);
|
|
83
57
|
/**
|
|
84
58
|
* The size of the output textures (default is 100% of the back buffer texture size).
|
|
85
59
|
*/
|
|
@@ -97,26 +71,15 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
97
71
|
* Indicates if a mesh shouldn't be rendered when its material has depth write disabled (default is true).
|
|
98
72
|
*/
|
|
99
73
|
this.dontRenderWhenMaterialDepthWriteIsDisabled = true;
|
|
100
|
-
|
|
101
|
-
* If true, the output geometry texture(s) will be resolved at the end of the render pass, if samples is greater than 1 (default: true)
|
|
102
|
-
*/
|
|
103
|
-
this.resolveMSAAColors = true;
|
|
104
|
-
/**
|
|
105
|
-
* If true, depthTexture will be resolved at the end of the render pass, if this texture is provided and samples is greater than 1 (default: true)
|
|
106
|
-
*/
|
|
107
|
-
this.resolveMSAADepth = false;
|
|
74
|
+
this._disableDepthPrePass = true;
|
|
108
75
|
/**
|
|
109
76
|
* The list of texture descriptions used by the geometry renderer task.
|
|
110
77
|
*/
|
|
111
78
|
this.textureDescriptions = [];
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
116
|
-
this._renderer.renderSprites = false;
|
|
117
|
-
this._renderer.renderParticles = false;
|
|
118
|
-
this._renderer.enableBoundingBoxRendering = false;
|
|
119
|
-
this._renderer.enableOutlineRendering = false;
|
|
79
|
+
this.renderSprites = false;
|
|
80
|
+
this.renderParticles = false;
|
|
81
|
+
this.enableBoundingBoxRendering = false;
|
|
82
|
+
this.enableOutlineRendering = false;
|
|
120
83
|
this._renderer.disableDepthPrePass = true;
|
|
121
84
|
this._renderer.customIsReadyFunction = (mesh, refreshRate, preWarm) => {
|
|
122
85
|
if (this.dontRenderWhenMaterialDepthWriteIsDisabled && mesh.material && mesh.material.disableDepthWrite) {
|
|
@@ -129,10 +92,8 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
129
92
|
scene.updateTransformMatrix(true);
|
|
130
93
|
}
|
|
131
94
|
});
|
|
132
|
-
this.name = name;
|
|
133
95
|
this._clearAttachmentsLayout = new Map();
|
|
134
96
|
this._allAttachmentsLayout = [];
|
|
135
|
-
this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
136
97
|
this.geometryViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
137
98
|
this.geometryNormViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
138
99
|
this.geometryScreenDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
@@ -176,34 +137,19 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
176
137
|
list.splice(index, 1);
|
|
177
138
|
}
|
|
178
139
|
}
|
|
179
|
-
isReady() {
|
|
180
|
-
return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);
|
|
181
|
-
}
|
|
182
140
|
getClassName() {
|
|
183
141
|
return "FrameGraphGeometryRendererTask";
|
|
184
142
|
}
|
|
185
|
-
record() {
|
|
186
|
-
if (this.objectList === undefined) {
|
|
187
|
-
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list must be provided`);
|
|
188
|
-
}
|
|
189
|
-
// Make sure the renderList / particleSystemList are set when FrameGraphGeometryRendererTask.isReady() is called!
|
|
190
|
-
this._renderer.renderList = this.objectList.meshes;
|
|
191
|
-
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
192
|
-
const outputTextureHandle = this._createMultiRenderTargetTexture();
|
|
193
|
-
const depthEnabled = this._checkDepthTextureCompatibility();
|
|
143
|
+
record(skipCreationOfDisabledPasses = false, additionalExecute) {
|
|
194
144
|
this._buildClearAttachmentsLayout();
|
|
195
145
|
this._registerForRenderPassId(this._renderer.renderPassId);
|
|
196
|
-
const outputTextureDescription = outputTextureHandle.length > 0 ? this._frameGraph.textureManager.getTextureDescription(outputTextureHandle[0]) : null;
|
|
197
|
-
this._textureWidth = outputTextureDescription?.size.width ?? 0;
|
|
198
|
-
this._textureHeight = outputTextureDescription?.size.height ?? 0;
|
|
199
|
-
// Create pass
|
|
200
146
|
MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);
|
|
201
|
-
const pass =
|
|
202
|
-
pass.
|
|
147
|
+
const pass = super.record(skipCreationOfDisabledPasses, additionalExecute);
|
|
148
|
+
const outputTextureHandles = pass.renderTarget;
|
|
203
149
|
let needPreviousWorldMatrices = false;
|
|
204
150
|
for (let i = 0; i < this.textureDescriptions.length; i++) {
|
|
205
151
|
const description = this.textureDescriptions[i];
|
|
206
|
-
const handle =
|
|
152
|
+
const handle = outputTextureHandles[i];
|
|
207
153
|
const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);
|
|
208
154
|
const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];
|
|
209
155
|
switch (geometryDescription.type) {
|
|
@@ -245,30 +191,55 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
245
191
|
}
|
|
246
192
|
}
|
|
247
193
|
this._scene.needsPreviousWorldMatrices = needPreviousWorldMatrices;
|
|
248
|
-
pass
|
|
249
|
-
pass.setExecuteFunc((context) => {
|
|
250
|
-
this._renderer.renderList = this.objectList.meshes;
|
|
251
|
-
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
252
|
-
pass.frameGraphRenderTarget.renderTargetWrapper.resolveMSAAColors = this.resolveMSAAColors;
|
|
253
|
-
pass.frameGraphRenderTarget.renderTargetWrapper.resolveMSAADepth = this.resolveMSAADepth;
|
|
254
|
-
context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
|
|
255
|
-
this._clearAttachmentsLayout.forEach((layout, clearType) => {
|
|
256
|
-
context.clearColorAttachments(ClearColors[clearType], layout);
|
|
257
|
-
});
|
|
258
|
-
context.bindAttachments(this._allAttachmentsLayout);
|
|
259
|
-
context.render(this._renderer, this._textureWidth, this._textureHeight);
|
|
260
|
-
});
|
|
261
|
-
const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
|
|
262
|
-
passDisabled.setRenderTarget(outputTextureHandle);
|
|
263
|
-
passDisabled.setRenderTargetDepth(this.depthTexture);
|
|
264
|
-
passDisabled.setExecuteFunc((_context) => { });
|
|
194
|
+
return pass;
|
|
265
195
|
}
|
|
266
196
|
dispose() {
|
|
267
197
|
MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);
|
|
268
198
|
this._renderer.dispose();
|
|
269
199
|
super.dispose();
|
|
270
200
|
}
|
|
271
|
-
|
|
201
|
+
_resolveDanglingHandles(_targetTextures) {
|
|
202
|
+
if (this.targetTexture !== undefined) {
|
|
203
|
+
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, Array.isArray(this.targetTexture) ? this.targetTexture[0] : this.targetTexture);
|
|
204
|
+
}
|
|
205
|
+
if (this.depthTexture !== undefined) {
|
|
206
|
+
this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
_checkParameters() {
|
|
210
|
+
if (this.objectList === undefined || this.camera === undefined) {
|
|
211
|
+
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and camera must be provided`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
_checkTextureCompatibility(targetTextures) {
|
|
215
|
+
let depthEnabled = false;
|
|
216
|
+
let dimensions = null;
|
|
217
|
+
if (this.targetTexture !== undefined) {
|
|
218
|
+
const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(Array.isArray(this.targetTexture) ? this.targetTexture[0] : this.targetTexture);
|
|
219
|
+
if (this.samples !== outputTextureDescription.options.samples) {
|
|
220
|
+
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the target texture and the output geometry textures must have the same number of samples`);
|
|
221
|
+
}
|
|
222
|
+
dimensions = outputTextureDescription.size;
|
|
223
|
+
}
|
|
224
|
+
if (this.depthTexture !== undefined) {
|
|
225
|
+
const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);
|
|
226
|
+
if (depthTextureDescription.options.samples !== this.samples && this.textureDescriptions.length > 0) {
|
|
227
|
+
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output geometry textures must have the same number of samples`);
|
|
228
|
+
}
|
|
229
|
+
this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
|
|
230
|
+
depthEnabled = true;
|
|
231
|
+
dimensions = depthTextureDescription.size;
|
|
232
|
+
}
|
|
233
|
+
const geomTextureDimensions = this.sizeIsPercentage ? this._frameGraph.textureManager.getAbsoluteDimensions(this.size) : this.size;
|
|
234
|
+
if (dimensions !== null) {
|
|
235
|
+
if (geomTextureDimensions.width !== dimensions.width || geomTextureDimensions.height !== dimensions.height) {
|
|
236
|
+
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the geometry textures (size: ${geomTextureDimensions.width}x${geomTextureDimensions.height}) and the target/depth texture (size: ${dimensions.width}x${dimensions.height}) must have the same dimensions.`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
depthEnabled = depthEnabled || super._checkTextureCompatibility(targetTextures);
|
|
240
|
+
return depthEnabled;
|
|
241
|
+
}
|
|
242
|
+
_getTargetHandles() {
|
|
272
243
|
const types = [];
|
|
273
244
|
const formats = [];
|
|
274
245
|
const labels = [];
|
|
@@ -284,38 +255,40 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
284
255
|
labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;
|
|
285
256
|
useSRGBBuffers[i] = false;
|
|
286
257
|
}
|
|
287
|
-
const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {
|
|
288
|
-
size: this.size,
|
|
289
|
-
sizeIsPercentage: this.sizeIsPercentage,
|
|
290
|
-
options: {
|
|
291
|
-
createMipMaps: false,
|
|
292
|
-
samples: this.samples,
|
|
293
|
-
types,
|
|
294
|
-
formats,
|
|
295
|
-
useSRGBBuffers,
|
|
296
|
-
labels,
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
258
|
const handles = [];
|
|
300
|
-
|
|
301
|
-
|
|
259
|
+
if (this.textureDescriptions.length > 0) {
|
|
260
|
+
const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {
|
|
261
|
+
size: this.size,
|
|
262
|
+
sizeIsPercentage: this.sizeIsPercentage,
|
|
263
|
+
options: {
|
|
264
|
+
createMipMaps: false,
|
|
265
|
+
samples: this.samples,
|
|
266
|
+
types,
|
|
267
|
+
formats,
|
|
268
|
+
useSRGBBuffers,
|
|
269
|
+
labels,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
for (let i = 0; i < this.textureDescriptions.length; i++) {
|
|
273
|
+
handles.push(baseHandle + i);
|
|
274
|
+
}
|
|
302
275
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
let depthEnabled = false;
|
|
307
|
-
if (this.depthTexture !== undefined) {
|
|
308
|
-
if (this.depthTexture === backbufferDepthStencilTextureHandle) {
|
|
309
|
-
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);
|
|
276
|
+
if (this.targetTexture !== undefined) {
|
|
277
|
+
if (Array.isArray(this.targetTexture)) {
|
|
278
|
+
handles.push(...this.targetTexture);
|
|
310
279
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);
|
|
280
|
+
else {
|
|
281
|
+
handles.push(this.targetTexture);
|
|
314
282
|
}
|
|
315
|
-
this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
|
|
316
|
-
depthEnabled = true;
|
|
317
283
|
}
|
|
318
|
-
return
|
|
284
|
+
return handles;
|
|
285
|
+
}
|
|
286
|
+
_prepareRendering(context, depthEnabled) {
|
|
287
|
+
context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
|
|
288
|
+
this._clearAttachmentsLayout.forEach((layout, clearType) => {
|
|
289
|
+
context.clearColorAttachments(ClearColors[clearType], layout);
|
|
290
|
+
});
|
|
291
|
+
context.bindAttachments(this._allAttachmentsLayout);
|
|
319
292
|
}
|
|
320
293
|
_buildClearAttachmentsLayout() {
|
|
321
294
|
const clearAttachmentsLayout = new Map();
|
|
@@ -337,6 +310,20 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
337
310
|
});
|
|
338
311
|
allAttachmentsLayout.push(true);
|
|
339
312
|
}
|
|
313
|
+
if (this.targetTexture !== undefined) {
|
|
314
|
+
let layout = clearAttachmentsLayout.get(0 /* GeometryRenderingTextureClearType.Zero */);
|
|
315
|
+
if (layout === undefined) {
|
|
316
|
+
layout = [];
|
|
317
|
+
clearAttachmentsLayout.set(0 /* GeometryRenderingTextureClearType.Zero */, layout);
|
|
318
|
+
for (let j = 0; j < this.textureDescriptions.length - 1; j++) {
|
|
319
|
+
layout[j] = false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
clearAttachmentsLayout.forEach((layout) => {
|
|
323
|
+
layout.push(false);
|
|
324
|
+
});
|
|
325
|
+
allAttachmentsLayout.push(true);
|
|
326
|
+
}
|
|
340
327
|
this._clearAttachmentsLayout = new Map();
|
|
341
328
|
clearAttachmentsLayout.forEach((layout, clearType) => {
|
|
342
329
|
this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));
|
|
@@ -351,6 +338,9 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
351
338
|
const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];
|
|
352
339
|
configuration.defines[geometryDescription.defineIndex] = i;
|
|
353
340
|
}
|
|
341
|
+
if (this.targetTexture !== undefined) {
|
|
342
|
+
configuration.defines["PREPASS_COLOR_INDEX"] = this.textureDescriptions.length;
|
|
343
|
+
}
|
|
354
344
|
configuration.reverseCulling = this.reverseCulling;
|
|
355
345
|
}
|
|
356
346
|
}
|