@babylonjs/core 7.41.1 → 7.43.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/Animations/animation.js +1 -1
- package/Animations/animation.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +3 -4
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js +27 -64
- package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +3 -2
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +5 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +6 -1
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +64 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +147 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +0 -15
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.d.ts +4 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +9 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +1 -6
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +0 -13
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +0 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +17 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +0 -8
- package/FrameGraph/Passes/renderPass.js +0 -10
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +57 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.js +173 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +5 -5
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +12 -4
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +0 -8
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +1 -17
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +3 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -6
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +20 -22
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +7 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +21 -5
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +4 -6
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +22 -11
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +2 -1
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +11 -1
- package/FrameGraph/frameGraphTask.js +8 -0
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +8 -2
- package/FrameGraph/frameGraphTextureManager.js +10 -4
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Layers/effectLayer.d.ts +32 -33
- package/Layers/effectLayer.js +144 -530
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +14 -41
- package/Layers/glowLayer.js +92 -178
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +0 -1
- package/Layers/highlightLayer.js +0 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/index.d.ts +2 -0
- package/Layers/index.js +2 -0
- package/Layers/index.js.map +1 -1
- package/Layers/thinEffectLayer.d.ts +230 -0
- package/Layers/thinEffectLayer.js +734 -0
- package/Layers/thinEffectLayer.js.map +1 -0
- package/Layers/thinGlowLayer.d.ts +141 -0
- package/Layers/thinGlowLayer.js +292 -0
- package/Layers/thinGlowLayer.js.map +1 -0
- package/Lights/Shadows/shadowGenerator.js +40 -19
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +17 -11
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +18 -12
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +34 -2
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +34 -24
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +10 -0
- package/Materials/Node/nodeMaterial.js +12 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +5 -0
- package/Materials/PBR/pbrBaseMaterial.js +5 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +12 -0
- package/Materials/Textures/renderTargetTexture.js +29 -8
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +17 -1
- package/Materials/materialHelper.functions.js +76 -4
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +5 -4
- package/Materials/shaderMaterial.js +28 -51
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +5 -0
- package/Materials/standardMaterial.js +5 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +5 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +30 -22
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +1 -0
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -2
- package/Meshes/abstractMesh.js +1 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/linesMesh.js +2 -2
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +30 -3
- package/Meshes/mesh.js +56 -29
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.js +16 -3
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/fileTools.js +14 -7
- package/Misc/fileTools.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +20 -0
- package/Morph/morphTargetManager.js +31 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +15 -16
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +13 -15
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +13 -15
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +9 -2
- package/Rendering/objectRenderer.js +44 -7
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +13 -15
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js +16 -4
- package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +17 -5
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/assetContainer.d.ts +43 -0
- package/assetContainer.js +67 -0
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +10 -3
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAE,+DAAwD;AAClG,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAuBnE,MAAM,WAAW,GAAa,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,cAAc;IAQ9D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IA8FD;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI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r\n FrameGraphObjectList,\r\n AbstractMesh,\r\n ObjectRendererOptions,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Description of a texture used by the geometry renderer task.\r\n */\r\nexport interface IFrameGraphGeometryRendererTextureDescription {\r\n /**\r\n * The type of the texture.\r\n * The value should be one of the Constants.PREPASS_XXX_TEXTURE_TYPE values.\r\n */\r\n type: number;\r\n\r\n /**\r\n * The type of the texture.\r\n */\r\n textureType: number;\r\n\r\n /**\r\n * The format of the texture.\r\n */\r\n textureFormat: number;\r\n}\r\n\r\nconst clearColors: Color4[] = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(1e8, 1e8, 1e8, 1e8)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphTask {\r\n /**\r\n * The depth texture attachment to use for rendering (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used for rendering.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The object list used for rendering.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Whether depth testing is enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * Whether depth writing is enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The size of the output textures (default is 100% of the back buffer texture size).\r\n */\r\n public size: { width: number; height: number } = { width: 100, height: 100 };\r\n\r\n /**\r\n * Whether the size is a percentage of the back buffer size (default is true).\r\n */\r\n public sizeIsPercentage = true;\r\n\r\n /**\r\n * The number of samples to use for the output textures (default is 1).\r\n */\r\n public samples = 1;\r\n\r\n /**\r\n * The list of texture descriptions used by the geometry renderer task.\r\n */\r\n public textureDescriptions: IFrameGraphGeometryRendererTextureDescription[] = [];\r\n\r\n /**\r\n * The output depth texture attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in screen space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryScreenDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in local space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLocalPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The albedo output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryAlbedoTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The reflectivity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryReflectivityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used by the geometry renderer task.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the task.\r\n */\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _renderer: ObjectRenderer;\r\n private _textureWidth: number;\r\n private _textureHeight: number;\r\n private _clearAttachmentsLayout: Map<GeometryRenderingTextureClearType, number[]>;\r\n private _allAttachmentsLayout: number[];\r\n\r\n /**\r\n * Constructs a new geometry renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = this._scene.getEngine();\r\n\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this._renderer.renderSprites = false;\r\n this._renderer.renderParticles = false;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.name = name;\r\n this._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Gets the list of excluded meshes from the velocity texture.\r\n */\r\n public get excludedSkinnedMeshFromVelocityTexture(): AbstractMesh[] {\r\n return MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId).excludedSkinnedMesh;\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record() {\r\n if (this.textureDescriptions.length === 0 || this.objectList === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and at least one geometry texture description must be provided`);\r\n }\r\n\r\n const outputTextureHandle = this._createMultiRenderTargetTexture();\r\n\r\n const depthEnabled = this._checkDepthTextureCompatibility();\r\n\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(outputTextureHandle[0]);\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n // Create pass\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(outputTextureHandle);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const handle = outputTextureHandle[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryScreenDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLocalPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryAlbedoTexture, handle);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryReflectivityTexture, handle);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryVelocityTexture, handle);\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle);\r\n break;\r\n }\r\n }\r\n\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n this._clearAttachmentsLayout.forEach((layout, clearType) => {\r\n context.clearColorAttachments(clearColors[clearType], layout);\r\n });\r\n\r\n context.bindAttachments(this._allAttachmentsLayout);\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _createMultiRenderTargetTexture(): FrameGraphTextureHandle[] {\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const labels: string[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n\r\n if (index === -1) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: unknown texture type ${description.type}`);\r\n }\r\n\r\n types[i] = description.textureType;\r\n formats[i] = description.textureFormat;\r\n labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;\r\n useSRGBBuffers[i] = false;\r\n }\r\n\r\n const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n });\r\n\r\n const handles: FrameGraphTextureHandle[] = [];\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n handles.push(baseHandle + i);\r\n }\r\n\r\n return handles;\r\n }\r\n\r\n private _checkDepthTextureCompatibility(): boolean {\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n return depthEnabled;\r\n }\r\n\r\n private _buildClearAttachmentsLayout() {\r\n const clearAttachmentsLayout = new Map<GeometryRenderingTextureClearType, boolean[]>();\r\n const allAttachmentsLayout: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n let layout = clearAttachmentsLayout.get(geometryDescription.clearType);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(geometryDescription.clearType, layout);\r\n for (let j = 0; j < i; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n layout.push(clearType === geometryDescription.clearType);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n this._clearAttachmentsLayout = new Map();\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));\r\n });\r\n\r\n this._allAttachmentsLayout = this._engine.buildTextureLayout(allAttachmentsLayout);\r\n }\r\n\r\n private _registerForRenderPassId(renderPassId: number) {\r\n const configuration = MaterialHelperGeometryRendering.CreateConfiguration(renderPassId);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n configuration.defines[geometryDescription.defineIndex] = i;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAE,+DAAwD;AAClG,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAuBnE,MAAM,WAAW,GAAa,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,cAAc;IAQ9D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC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C,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;YACxH,MAAM,mBAAmB,GAAG,+BAA+B,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;YAE/F,aAAa,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/D,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n AbstractEngine,\r\n FrameGraph,\r\n GeometryRenderingTextureClearType,\r\n FrameGraphObjectList,\r\n AbstractMesh,\r\n ObjectRendererOptions,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Description of a texture used by the geometry renderer task.\r\n */\r\nexport interface IFrameGraphGeometryRendererTextureDescription {\r\n /**\r\n * The type of the texture.\r\n * The value should be one of the Constants.PREPASS_XXX_TEXTURE_TYPE values.\r\n */\r\n type: number;\r\n\r\n /**\r\n * The type of the texture.\r\n */\r\n textureType: number;\r\n\r\n /**\r\n * The format of the texture.\r\n */\r\n textureFormat: number;\r\n}\r\n\r\nconst clearColors: Color4[] = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(1e8, 1e8, 1e8, 1e8)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphTask {\r\n /**\r\n * The depth texture attachment to use for rendering (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used for rendering.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The object list used for rendering.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Whether depth testing is enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * Whether depth writing is enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The size of the output textures (default is 100% of the back buffer texture size).\r\n */\r\n public size: { width: number; height: number } = { width: 100, height: 100 };\r\n\r\n /**\r\n * Whether the size is a percentage of the back buffer size (default is true).\r\n */\r\n public sizeIsPercentage = true;\r\n\r\n /**\r\n * The number of samples to use for the output textures (default is 1).\r\n */\r\n public samples = 1;\r\n\r\n /**\r\n * The list of texture descriptions used by the geometry renderer task.\r\n */\r\n public textureDescriptions: IFrameGraphGeometryRendererTextureDescription[] = [];\r\n\r\n /**\r\n * The output depth texture attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in screen space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryScreenDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in local space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLocalPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The albedo output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryAlbedoTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The reflectivity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryReflectivityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used by the geometry renderer task.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the task.\r\n */\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _renderer: ObjectRenderer;\r\n private _textureWidth: number;\r\n private _textureHeight: number;\r\n private _clearAttachmentsLayout: Map<GeometryRenderingTextureClearType, number[]>;\r\n private _allAttachmentsLayout: number[];\r\n\r\n /**\r\n * Constructs a new geometry renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = this._scene.getEngine();\r\n\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this._renderer.renderSprites = false;\r\n this._renderer.renderParticles = false;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.name = name;\r\n this._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Gets the list of excluded meshes from the velocity texture.\r\n */\r\n public get excludedSkinnedMeshFromVelocityTexture(): AbstractMesh[] {\r\n return MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId).excludedSkinnedMesh;\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record() {\r\n if (this.textureDescriptions.length === 0 || this.objectList === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and at least one geometry texture description must be provided`);\r\n }\r\n\r\n // Make sure the renderList / particleSystemList are set when FrameGraphGeometryRendererTask.isReady() is called!\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n const outputTextureHandle = this._createMultiRenderTargetTexture();\r\n\r\n const depthEnabled = this._checkDepthTextureCompatibility();\r\n\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(outputTextureHandle[0]);\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n // Create pass\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(outputTextureHandle);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const handle = outputTextureHandle[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryScreenDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLocalPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryAlbedoTexture, handle);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryReflectivityTexture, handle);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryVelocityTexture, handle);\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle);\r\n break;\r\n }\r\n }\r\n\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n this._clearAttachmentsLayout.forEach((layout, clearType) => {\r\n context.clearColorAttachments(clearColors[clearType], layout);\r\n });\r\n\r\n context.bindAttachments(this._allAttachmentsLayout);\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _createMultiRenderTargetTexture(): FrameGraphTextureHandle[] {\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const labels: string[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n\r\n if (index === -1) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: unknown texture type ${description.type}`);\r\n }\r\n\r\n types[i] = description.textureType;\r\n formats[i] = description.textureFormat;\r\n labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;\r\n useSRGBBuffers[i] = false;\r\n }\r\n\r\n const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n });\r\n\r\n const handles: FrameGraphTextureHandle[] = [];\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n handles.push(baseHandle + i);\r\n }\r\n\r\n return handles;\r\n }\r\n\r\n private _checkDepthTextureCompatibility(): boolean {\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n return depthEnabled;\r\n }\r\n\r\n private _buildClearAttachmentsLayout() {\r\n const clearAttachmentsLayout = new Map<GeometryRenderingTextureClearType, boolean[]>();\r\n const allAttachmentsLayout: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n let layout = clearAttachmentsLayout.get(geometryDescription.clearType);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(geometryDescription.clearType, layout);\r\n for (let j = 0; j < i; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n layout.push(clearType === geometryDescription.clearType);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n this._clearAttachmentsLayout = new Map();\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));\r\n });\r\n\r\n this._allAttachmentsLayout = this._engine.buildTextureLayout(allAttachmentsLayout);\r\n }\r\n\r\n private _registerForRenderPassId(renderPassId: number) {\r\n const configuration = MaterialHelperGeometryRendering.CreateConfiguration(renderPassId);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n configuration.defines[geometryDescription.defineIndex] = i;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -13,10 +13,6 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
13
13
|
* The depth attachment texture where the objects will be rendered (optional).
|
|
14
14
|
*/
|
|
15
15
|
depthTexture?: FrameGraphTextureHandle;
|
|
16
|
-
/**
|
|
17
|
-
* The dependencies of the task (optional).
|
|
18
|
-
*/
|
|
19
|
-
dependencies?: FrameGraphTextureHandle[];
|
|
20
16
|
/**
|
|
21
17
|
* The shadow generators used to render the objects (optional).
|
|
22
18
|
*/
|
|
@@ -67,16 +63,18 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
67
63
|
protected _textureHeight: number;
|
|
68
64
|
protected _onBeforeRenderObservable: Nullable<Observer<number>>;
|
|
69
65
|
protected _onAfterRenderObservable: Nullable<Observer<number>>;
|
|
66
|
+
protected _externalObjectRenderer: boolean;
|
|
70
67
|
/**
|
|
71
68
|
* Constructs a new object renderer task.
|
|
72
69
|
* @param name The name of the task.
|
|
73
70
|
* @param frameGraph The frame graph the task belongs to.
|
|
74
71
|
* @param scene The scene the frame graph is associated with.
|
|
75
72
|
* @param options The options of the object renderer.
|
|
73
|
+
* @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.
|
|
76
74
|
*/
|
|
77
|
-
constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions);
|
|
75
|
+
constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions, existingObjectRenderer?: ObjectRenderer);
|
|
78
76
|
isReady(): boolean;
|
|
79
77
|
record(skipCreationOfDisabledPasses?: boolean, additionalExecute?: (context: FrameGraphRenderContext) => void): void;
|
|
80
78
|
dispose(): void;
|
|
81
|
-
|
|
79
|
+
protected _setLightsForShadow(): void;
|
|
82
80
|
}
|
|
@@ -37,13 +37,10 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
37
37
|
* @param frameGraph The frame graph the task belongs to.
|
|
38
38
|
* @param scene The scene the frame graph is associated with.
|
|
39
39
|
* @param options The options of the object renderer.
|
|
40
|
+
* @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.
|
|
40
41
|
*/
|
|
41
|
-
constructor(name, frameGraph, scene, options) {
|
|
42
|
+
constructor(name, frameGraph, scene, options, existingObjectRenderer) {
|
|
42
43
|
super(name, frameGraph);
|
|
43
|
-
/**
|
|
44
|
-
* The dependencies of the task (optional).
|
|
45
|
-
*/
|
|
46
|
-
this.dependencies = [];
|
|
47
44
|
/**
|
|
48
45
|
* The shadow generators used to render the objects (optional).
|
|
49
46
|
*/
|
|
@@ -62,14 +59,18 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
62
59
|
this.disableShadows = false;
|
|
63
60
|
this._onBeforeRenderObservable = null;
|
|
64
61
|
this._onAfterRenderObservable = null;
|
|
62
|
+
this._externalObjectRenderer = false;
|
|
65
63
|
this._scene = scene;
|
|
66
|
-
this.
|
|
64
|
+
this._externalObjectRenderer = !!existingObjectRenderer;
|
|
65
|
+
this._renderer = existingObjectRenderer ?? new ObjectRenderer(name, scene, options);
|
|
67
66
|
this.name = name;
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
if (!this._externalObjectRenderer) {
|
|
68
|
+
this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {
|
|
69
|
+
if (!this._renderer.options.doNotChangeAspectRatio) {
|
|
70
|
+
scene.updateTransformMatrix(true);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
73
74
|
this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
74
75
|
this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
75
76
|
}
|
|
@@ -80,6 +81,9 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
80
81
|
if (this.destinationTexture === undefined || this.objectList === undefined) {
|
|
81
82
|
throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);
|
|
82
83
|
}
|
|
84
|
+
// Make sure the renderList / particleSystemList are set when FrameGraphObjectRendererTask.isReady() is called!
|
|
85
|
+
this._renderer.renderList = this.objectList.meshes;
|
|
86
|
+
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
83
87
|
const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);
|
|
84
88
|
let depthEnabled = false;
|
|
85
89
|
if (this.depthTexture !== undefined) {
|
|
@@ -112,25 +116,19 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
112
116
|
context.render(this._renderer, this._textureWidth, this._textureHeight);
|
|
113
117
|
additionalExecute?.(context);
|
|
114
118
|
});
|
|
115
|
-
if (this.dependencies !== undefined) {
|
|
116
|
-
for (const handle of this.dependencies) {
|
|
117
|
-
pass.useTexture(handle);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
119
|
if (!skipCreationOfDisabledPasses) {
|
|
121
120
|
const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
|
|
122
121
|
passDisabled.setRenderTarget(this.destinationTexture);
|
|
123
122
|
passDisabled.setRenderTargetDepth(this.depthTexture);
|
|
124
123
|
passDisabled.setExecuteFunc((_context) => { });
|
|
125
|
-
if (this.dependencies !== undefined) {
|
|
126
|
-
for (const handle of this.dependencies) {
|
|
127
|
-
passDisabled.useTexture(handle);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
124
|
}
|
|
131
125
|
}
|
|
132
126
|
dispose() {
|
|
133
|
-
this._renderer.
|
|
127
|
+
this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);
|
|
128
|
+
this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);
|
|
129
|
+
if (!this._externalObjectRenderer) {
|
|
130
|
+
this._renderer.dispose();
|
|
131
|
+
}
|
|
134
132
|
super.dispose();
|
|
135
133
|
}
|
|
136
134
|
_setLightsForShadow() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;G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,aAAa,CAAC,CAAC;gBAC9C,KAAK,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC7E,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC7E,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC5E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpC,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;YACpD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n FrameGraphObjectList,\r\n FrameGraphRenderContext,\r\n ObjectRendererOptions,\r\n Light,\r\n Nullable,\r\n Observer,\r\n FrameGraphShadowGeneratorTask,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\nimport { FrameGraphCascadedShadowGeneratorTask } from \"./csmShadowGeneratorTask\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n /**\r\n * The shadow generators used to render the objects (optional).\r\n */\r\n public shadowGenerators?: FrameGraphShadowGeneratorTask[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * If shadows should be disabled (default is false).\r\n */\r\n public disableShadows = false;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\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(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n protected _onBeforeRenderObservable: Nullable<Observer<number>> = null;\r\n protected _onAfterRenderObservable: Nullable<Observer<number>> = null;\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n this._setLightsForShadow();\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _setLightsForShadow() {\r\n const lightsForShadow: Set<Light> = new Set();\r\n const shadowEnabled: Map<Light, boolean> = new Map();\r\n\r\n if (this.shadowGenerators) {\r\n for (const shadowGeneratorTask of this.shadowGenerators) {\r\n const shadowGenerator = shadowGeneratorTask.shadowGenerator;\r\n const light = shadowGenerator.getLight();\r\n if (light.isEnabled() && light.shadowEnabled) {\r\n lightsForShadow.add(light);\r\n if (FrameGraphCascadedShadowGeneratorTask.IsCascadedShadowGenerator(shadowGeneratorTask)) {\r\n light._shadowGenerators!.set(shadowGeneratorTask.camera, shadowGenerator);\r\n } else {\r\n light._shadowGenerators!.set(null, shadowGenerator);\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);\r\n this._onBeforeRenderObservable = this._renderer.onBeforeRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n shadowEnabled.set(light, light.shadowEnabled);\r\n light.shadowEnabled = !this.disableShadows && lightsForShadow.has(light);\r\n }\r\n });\r\n\r\n this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);\r\n this._onAfterRenderObservable = this._renderer.onAfterRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n light.shadowEnabled = shadowEnabled.get(light)!;\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,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GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;gBAC9C,KAAK,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC7E,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC7E,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC5E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpC,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;YACpD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n FrameGraphObjectList,\r\n FrameGraphRenderContext,\r\n ObjectRendererOptions,\r\n Light,\r\n Nullable,\r\n Observer,\r\n FrameGraphShadowGeneratorTask,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\nimport { FrameGraphCascadedShadowGeneratorTask } from \"./csmShadowGeneratorTask\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The shadow generators used to render the objects (optional).\r\n */\r\n public shadowGenerators?: FrameGraphShadowGeneratorTask[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * If shadows should be disabled (default is false).\r\n */\r\n public disableShadows = false;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\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(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n protected _onBeforeRenderObservable: Nullable<Observer<number>> = null;\r\n protected _onAfterRenderObservable: Nullable<Observer<number>> = null;\r\n protected _externalObjectRenderer = false;\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n * @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions, existingObjectRenderer?: ObjectRenderer) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._externalObjectRenderer = !!existingObjectRenderer;\r\n this._renderer = existingObjectRenderer ?? new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n if (!this._externalObjectRenderer) {\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n }\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n // Make sure the renderList / particleSystemList are set when FrameGraphObjectRendererTask.isReady() is called!\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n this._setLightsForShadow();\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);\r\n this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);\r\n if (!this._externalObjectRenderer) {\r\n this._renderer.dispose();\r\n }\r\n super.dispose();\r\n }\r\n\r\n protected _setLightsForShadow() {\r\n const lightsForShadow: Set<Light> = new Set();\r\n const shadowEnabled: Map<Light, boolean> = new Map();\r\n\r\n if (this.shadowGenerators) {\r\n for (const shadowGeneratorTask of this.shadowGenerators) {\r\n const shadowGenerator = shadowGeneratorTask.shadowGenerator;\r\n const light = shadowGenerator.getLight();\r\n if (light.isEnabled() && light.shadowEnabled) {\r\n lightsForShadow.add(light);\r\n if (FrameGraphCascadedShadowGeneratorTask.IsCascadedShadowGenerator(shadowGeneratorTask)) {\r\n light._shadowGenerators!.set(shadowGeneratorTask.camera, shadowGenerator);\r\n } else {\r\n light._shadowGenerators!.set(null, shadowGenerator);\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);\r\n this._onBeforeRenderObservable = this._renderer.onBeforeRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n shadowEnabled.set(light, light.shadowEnabled);\r\n light.shadowEnabled = !this.disableShadows && lightsForShadow.has(light);\r\n }\r\n });\r\n\r\n this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);\r\n this._onAfterRenderObservable = this._renderer.onAfterRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n light.shadowEnabled = shadowEnabled.get(light)!;\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Scene, FrameGraph, FrameGraphObjectList, IShadowLight, FrameGraphTextureHandle } from "../../../index.js";
|
|
1
|
+
import type { Scene, FrameGraph, FrameGraphObjectList, IShadowLight, FrameGraphTextureHandle, Camera } from "../../../index.js";
|
|
2
2
|
import { FrameGraphTask } from "../../frameGraphTask";
|
|
3
3
|
import { ShadowGenerator } from "../../../Lights/Shadows/shadowGenerator";
|
|
4
4
|
/**
|
|
@@ -15,6 +15,12 @@ export declare class FrameGraphShadowGeneratorTask extends FrameGraphTask {
|
|
|
15
15
|
*/
|
|
16
16
|
get light(): IShadowLight;
|
|
17
17
|
set light(value: IShadowLight);
|
|
18
|
+
private _camera;
|
|
19
|
+
/**
|
|
20
|
+
* Gets or sets the camera used to generate the shadow generator.
|
|
21
|
+
*/
|
|
22
|
+
get camera(): Camera;
|
|
23
|
+
set camera(camera: Camera);
|
|
18
24
|
private _mapSize;
|
|
19
25
|
/**
|
|
20
26
|
* The size of the shadow map.
|
|
@@ -17,6 +17,16 @@ export class FrameGraphShadowGeneratorTask extends FrameGraphTask {
|
|
|
17
17
|
this._light = value;
|
|
18
18
|
this._setupShadowGenerator();
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets or sets the camera used to generate the shadow generator.
|
|
22
|
+
*/
|
|
23
|
+
get camera() {
|
|
24
|
+
return this._camera;
|
|
25
|
+
}
|
|
26
|
+
set camera(camera) {
|
|
27
|
+
this._camera = camera;
|
|
28
|
+
this._setupShadowGenerator();
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
31
|
* The size of the shadow map.
|
|
22
32
|
*/
|
|
@@ -196,7 +206,9 @@ export class FrameGraphShadowGeneratorTask extends FrameGraphTask {
|
|
|
196
206
|
shadowGenerator.useOpacityTextureForTransparentShadow = this._useOpacityTextureForTransparentShadow;
|
|
197
207
|
shadowGenerator.filter = this._filter;
|
|
198
208
|
shadowGenerator.filteringQuality = this._filteringQuality;
|
|
199
|
-
shadowGenerator.getShadowMap()
|
|
209
|
+
const shadowMap = shadowGenerator.getShadowMap();
|
|
210
|
+
shadowMap._disableEngineStages = true;
|
|
211
|
+
shadowMap.cameraForLOD = this._camera;
|
|
200
212
|
this.shadowGenerator = shadowGenerator;
|
|
201
213
|
}
|
|
202
214
|
}
|
|
@@ -227,11 +239,15 @@ export class FrameGraphShadowGeneratorTask extends FrameGraphTask {
|
|
|
227
239
|
this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
228
240
|
}
|
|
229
241
|
record() {
|
|
230
|
-
if (this.light === undefined || this.objectList === undefined) {
|
|
231
|
-
throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light and
|
|
242
|
+
if (this.light === undefined || this.objectList === undefined || this.camera === undefined) {
|
|
243
|
+
throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light, objectList and camera are required`);
|
|
232
244
|
}
|
|
233
|
-
|
|
234
|
-
this.
|
|
245
|
+
// Make sure the renderList / particleSystemList are set when FrameGraphShadowGeneratorTask.isReady() is called!
|
|
246
|
+
const shadowMap = this._shadowGenerator.getShadowMap();
|
|
247
|
+
shadowMap.renderList = this.objectList.meshes;
|
|
248
|
+
shadowMap.particleSystemList = this.objectList.particleSystems;
|
|
249
|
+
const shadowTextureHandle = this._frameGraph.textureManager.importTexture(`${this.name} shadowmap`, this._shadowGenerator.getShadowMap().getInternalTexture());
|
|
250
|
+
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, shadowTextureHandle);
|
|
235
251
|
const pass = this._frameGraph.addPass(this.name);
|
|
236
252
|
pass.setExecuteFunc((_context) => {
|
|
237
253
|
if (!this.light.isEnabled() || !this.light.shadowEnabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowGeneratorTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/shadowGeneratorTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,cAAc;IAO7D;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAmB;QAChC,IAAI,KAAK,KAAK,IAAI,CAAC,MAA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AC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACtC,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Scene, FrameGraph, FrameGraphObjectList, IShadowLight, WritableObject, AbstractEngine, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ShadowGenerator } from \"../../../Lights/Shadows/shadowGenerator\";\r\n\r\n/**\r\n * Task used to generate shadows from a list of objects.\r\n */\r\nexport class FrameGraphShadowGeneratorTask extends FrameGraphTask {\r\n /**\r\n * The object list that generates shadows.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n private _light: IShadowLight;\r\n /**\r\n * The light to generate shadows from.\r\n */\r\n public get light(): IShadowLight {\r\n return this._light;\r\n }\r\n\r\n public set light(value: IShadowLight) {\r\n if (value === this._light) {\r\n return;\r\n }\r\n\r\n this._light = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _mapSize = 1024;\r\n /**\r\n * The size of the shadow map.\r\n */\r\n public get mapSize() {\r\n return this._mapSize;\r\n }\r\n\r\n public set mapSize(value: number) {\r\n if (value === this._mapSize) {\r\n return;\r\n }\r\n\r\n this._mapSize = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _useFloat32TextureType = false;\r\n /**\r\n * If true, the shadow map will use a 32 bits float texture type (else, 16 bits float is used if supported).\r\n */\r\n public get useFloat32TextureType() {\r\n return this._useFloat32TextureType;\r\n }\r\n\r\n public set useFloat32TextureType(value: boolean) {\r\n if (value === this._useFloat32TextureType) {\r\n return;\r\n }\r\n\r\n this._useFloat32TextureType = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _useRedTextureFormat = true;\r\n /**\r\n * If true, the shadow map will use a red texture format (else, a RGBA format is used).\r\n */\r\n public get useRedTextureFormat() {\r\n return this._useRedTextureFormat;\r\n }\r\n\r\n public set useRedTextureFormat(value: boolean) {\r\n if (value === this._useRedTextureFormat) {\r\n return;\r\n }\r\n\r\n this._useRedTextureFormat = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _bias = 0.01;\r\n /**\r\n * The bias to apply to the shadow map.\r\n */\r\n public get bias() {\r\n return this._bias;\r\n }\r\n\r\n public set bias(value: number) {\r\n if (value === this._bias) {\r\n return;\r\n }\r\n\r\n this._bias = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.bias = value;\r\n }\r\n }\r\n\r\n private _normalBias = 0;\r\n /**\r\n * The normal bias to apply to the shadow map.\r\n */\r\n public get normalBias() {\r\n return this._normalBias;\r\n }\r\n\r\n public set normalBias(value: number) {\r\n if (value === this._normalBias) {\r\n return;\r\n }\r\n\r\n this._normalBias = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.normalBias = value;\r\n }\r\n }\r\n\r\n private _darkness = 0;\r\n /**\r\n * The darkness of the shadows.\r\n */\r\n public get darkness() {\r\n return this._darkness;\r\n }\r\n\r\n public set darkness(value: number) {\r\n if (value === this._darkness) {\r\n return;\r\n }\r\n\r\n this._darkness = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.darkness = value;\r\n }\r\n }\r\n\r\n private _transparencyShadow = false;\r\n /**\r\n * Gets or sets the ability to have transparent shadow\r\n */\r\n public get transparencyShadow() {\r\n return this._transparencyShadow;\r\n }\r\n\r\n public set transparencyShadow(value: boolean) {\r\n if (value === this._transparencyShadow) {\r\n return;\r\n }\r\n\r\n this._transparencyShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.transparencyShadow = value;\r\n }\r\n }\r\n\r\n private _enableSoftTransparentShadow = false;\r\n /**\r\n * Enables or disables shadows with varying strength based on the transparency\r\n */\r\n public get enableSoftTransparentShadow() {\r\n return this._enableSoftTransparentShadow;\r\n }\r\n\r\n public set enableSoftTransparentShadow(value: boolean) {\r\n if (value === this._enableSoftTransparentShadow) {\r\n return;\r\n }\r\n\r\n this._enableSoftTransparentShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.enableSoftTransparentShadow = value;\r\n }\r\n }\r\n\r\n private _useOpacityTextureForTransparentShadow = false;\r\n /**\r\n * If this is true, use the opacity texture's alpha channel for transparent shadows instead of the diffuse one\r\n */\r\n public get useOpacityTextureForTransparentShadow() {\r\n return this._useOpacityTextureForTransparentShadow;\r\n }\r\n\r\n public set useOpacityTextureForTransparentShadow(value: boolean) {\r\n if (value === this._useOpacityTextureForTransparentShadow) {\r\n return;\r\n }\r\n\r\n this._useOpacityTextureForTransparentShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.useOpacityTextureForTransparentShadow = value;\r\n }\r\n }\r\n\r\n private _filter = ShadowGenerator.FILTER_PCF;\r\n /**\r\n * The filter to apply to the shadow map.\r\n */\r\n public get filter() {\r\n return this._filter;\r\n }\r\n\r\n public set filter(value: number) {\r\n if (value === this._filter) {\r\n return;\r\n }\r\n\r\n this._filter = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.filter = value;\r\n }\r\n }\r\n\r\n private _filteringQuality = ShadowGenerator.QUALITY_HIGH;\r\n /**\r\n * The filtering quality to apply to the filter.\r\n */\r\n public get filteringQuality() {\r\n return this._filteringQuality;\r\n }\r\n\r\n public set filteringQuality(value: number) {\r\n if (value === this._filteringQuality) {\r\n return;\r\n }\r\n\r\n this._filteringQuality = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.filteringQuality = value;\r\n }\r\n }\r\n\r\n /**\r\n * The shadow generator.\r\n */\r\n public readonly shadowGenerator: ShadowGenerator;\r\n\r\n /**\r\n * The shadow map texture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n protected _shadowGenerator: ShadowGenerator | undefined;\r\n\r\n protected _createShadowGenerator() {\r\n this._shadowGenerator = new ShadowGenerator(this._mapSize, this._light, this._useFloat32TextureType, undefined, this._useRedTextureFormat);\r\n }\r\n\r\n protected _setupShadowGenerator() {\r\n this._shadowGenerator?.dispose();\r\n this._shadowGenerator = undefined;\r\n if (this._light !== undefined) {\r\n this._createShadowGenerator();\r\n const shadowGenerator = this._shadowGenerator as ShadowGenerator | undefined;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n shadowGenerator.bias = this._bias;\r\n shadowGenerator.normalBias = this._normalBias;\r\n shadowGenerator.darkness = this._darkness;\r\n shadowGenerator.transparencyShadow = this._transparencyShadow;\r\n shadowGenerator.enableSoftTransparentShadow = this._enableSoftTransparentShadow;\r\n shadowGenerator.useOpacityTextureForTransparentShadow = this._useOpacityTextureForTransparentShadow;\r\n shadowGenerator.filter = this._filter;\r\n shadowGenerator.filteringQuality = this._filteringQuality;\r\n shadowGenerator.getShadowMap()!._disableEngineStages = true;\r\n (this.shadowGenerator as WritableObject<ShadowGenerator | undefined>) = shadowGenerator;\r\n }\r\n }\r\n\r\n public override isReady(): boolean {\r\n return !!this._shadowGenerator && !!this._shadowGenerator.getShadowMap()?.isReadyForRendering();\r\n }\r\n\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\r\n\r\n /**\r\n * Creates a new shadow generator task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene to create the shadow generator for.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph);\r\n\r\n this._engine = scene.getEngine();\r\n this._scene = scene;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.light === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light and objectList are required`);\r\n }\r\n\r\n const shadowMap = this._frameGraph.textureManager.importTexture(`${this.name} shadowmap`, this._shadowGenerator!.getShadowMap()!.getInternalTexture()!);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, shadowMap);\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((_context) => {\r\n if (!this.light.isEnabled() || !this.light.shadowEnabled) {\r\n return;\r\n }\r\n\r\n const shadowMap = this._shadowGenerator!.getShadowMap()!;\r\n\r\n shadowMap.renderList = this.objectList.meshes;\r\n shadowMap.particleSystemList = this.objectList.particleSystems;\r\n\r\n const currentRenderTarget = this._engine._currentRenderTarget;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n shadowMap.render();\r\n\r\n if (this._engine._currentRenderTarget !== currentRenderTarget) {\r\n if (!currentRenderTarget) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n this._engine.bindFramebuffer(currentRenderTarget);\r\n }\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n public override dispose() {\r\n this._shadowGenerator?.dispose();\r\n this._shadowGenerator = undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"shadowGeneratorTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/shadowGeneratorTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,cAAc;IAO7D;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAmB;QAChC,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,I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C,mBAAmB,EAAE,CAAC;YAElC,SAAS,CAAC,MAAM,EAAE,CAAC;YAEnB,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,KAAK,mBAAmB,EAAE,CAAC;gBAC5D,IAAI,CAAC,mBAAmB,EAAE,CAAC;oBACvB,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;gBAC7C,CAAC;qBAAM,CAAC;oBACJ,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;gBACtD,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACtC,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Scene, FrameGraph, FrameGraphObjectList, IShadowLight, WritableObject, AbstractEngine, FrameGraphTextureHandle, Camera } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ShadowGenerator } from \"../../../Lights/Shadows/shadowGenerator\";\r\n\r\n/**\r\n * Task used to generate shadows from a list of objects.\r\n */\r\nexport class FrameGraphShadowGeneratorTask extends FrameGraphTask {\r\n /**\r\n * The object list that generates shadows.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n private _light: IShadowLight;\r\n /**\r\n * The light to generate shadows from.\r\n */\r\n public get light(): IShadowLight {\r\n return this._light;\r\n }\r\n\r\n public set light(value: IShadowLight) {\r\n if (value === this._light) {\r\n return;\r\n }\r\n\r\n this._light = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _camera: Camera;\r\n /**\r\n * Gets or sets the camera used to generate the shadow generator.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _mapSize = 1024;\r\n /**\r\n * The size of the shadow map.\r\n */\r\n public get mapSize() {\r\n return this._mapSize;\r\n }\r\n\r\n public set mapSize(value: number) {\r\n if (value === this._mapSize) {\r\n return;\r\n }\r\n\r\n this._mapSize = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _useFloat32TextureType = false;\r\n /**\r\n * If true, the shadow map will use a 32 bits float texture type (else, 16 bits float is used if supported).\r\n */\r\n public get useFloat32TextureType() {\r\n return this._useFloat32TextureType;\r\n }\r\n\r\n public set useFloat32TextureType(value: boolean) {\r\n if (value === this._useFloat32TextureType) {\r\n return;\r\n }\r\n\r\n this._useFloat32TextureType = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _useRedTextureFormat = true;\r\n /**\r\n * If true, the shadow map will use a red texture format (else, a RGBA format is used).\r\n */\r\n public get useRedTextureFormat() {\r\n return this._useRedTextureFormat;\r\n }\r\n\r\n public set useRedTextureFormat(value: boolean) {\r\n if (value === this._useRedTextureFormat) {\r\n return;\r\n }\r\n\r\n this._useRedTextureFormat = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _bias = 0.01;\r\n /**\r\n * The bias to apply to the shadow map.\r\n */\r\n public get bias() {\r\n return this._bias;\r\n }\r\n\r\n public set bias(value: number) {\r\n if (value === this._bias) {\r\n return;\r\n }\r\n\r\n this._bias = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.bias = value;\r\n }\r\n }\r\n\r\n private _normalBias = 0;\r\n /**\r\n * The normal bias to apply to the shadow map.\r\n */\r\n public get normalBias() {\r\n return this._normalBias;\r\n }\r\n\r\n public set normalBias(value: number) {\r\n if (value === this._normalBias) {\r\n return;\r\n }\r\n\r\n this._normalBias = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.normalBias = value;\r\n }\r\n }\r\n\r\n private _darkness = 0;\r\n /**\r\n * The darkness of the shadows.\r\n */\r\n public get darkness() {\r\n return this._darkness;\r\n }\r\n\r\n public set darkness(value: number) {\r\n if (value === this._darkness) {\r\n return;\r\n }\r\n\r\n this._darkness = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.darkness = value;\r\n }\r\n }\r\n\r\n private _transparencyShadow = false;\r\n /**\r\n * Gets or sets the ability to have transparent shadow\r\n */\r\n public get transparencyShadow() {\r\n return this._transparencyShadow;\r\n }\r\n\r\n public set transparencyShadow(value: boolean) {\r\n if (value === this._transparencyShadow) {\r\n return;\r\n }\r\n\r\n this._transparencyShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.transparencyShadow = value;\r\n }\r\n }\r\n\r\n private _enableSoftTransparentShadow = false;\r\n /**\r\n * Enables or disables shadows with varying strength based on the transparency\r\n */\r\n public get enableSoftTransparentShadow() {\r\n return this._enableSoftTransparentShadow;\r\n }\r\n\r\n public set enableSoftTransparentShadow(value: boolean) {\r\n if (value === this._enableSoftTransparentShadow) {\r\n return;\r\n }\r\n\r\n this._enableSoftTransparentShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.enableSoftTransparentShadow = value;\r\n }\r\n }\r\n\r\n private _useOpacityTextureForTransparentShadow = false;\r\n /**\r\n * If this is true, use the opacity texture's alpha channel for transparent shadows instead of the diffuse one\r\n */\r\n public get useOpacityTextureForTransparentShadow() {\r\n return this._useOpacityTextureForTransparentShadow;\r\n }\r\n\r\n public set useOpacityTextureForTransparentShadow(value: boolean) {\r\n if (value === this._useOpacityTextureForTransparentShadow) {\r\n return;\r\n }\r\n\r\n this._useOpacityTextureForTransparentShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.useOpacityTextureForTransparentShadow = value;\r\n }\r\n }\r\n\r\n private _filter = ShadowGenerator.FILTER_PCF;\r\n /**\r\n * The filter to apply to the shadow map.\r\n */\r\n public get filter() {\r\n return this._filter;\r\n }\r\n\r\n public set filter(value: number) {\r\n if (value === this._filter) {\r\n return;\r\n }\r\n\r\n this._filter = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.filter = value;\r\n }\r\n }\r\n\r\n private _filteringQuality = ShadowGenerator.QUALITY_HIGH;\r\n /**\r\n * The filtering quality to apply to the filter.\r\n */\r\n public get filteringQuality() {\r\n return this._filteringQuality;\r\n }\r\n\r\n public set filteringQuality(value: number) {\r\n if (value === this._filteringQuality) {\r\n return;\r\n }\r\n\r\n this._filteringQuality = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.filteringQuality = value;\r\n }\r\n }\r\n\r\n /**\r\n * The shadow generator.\r\n */\r\n public readonly shadowGenerator: ShadowGenerator;\r\n\r\n /**\r\n * The shadow map texture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n protected _shadowGenerator: ShadowGenerator | undefined;\r\n\r\n protected _createShadowGenerator() {\r\n this._shadowGenerator = new ShadowGenerator(this._mapSize, this._light, this._useFloat32TextureType, undefined, this._useRedTextureFormat);\r\n }\r\n\r\n protected _setupShadowGenerator() {\r\n this._shadowGenerator?.dispose();\r\n this._shadowGenerator = undefined;\r\n if (this._light !== undefined) {\r\n this._createShadowGenerator();\r\n const shadowGenerator = this._shadowGenerator as ShadowGenerator | undefined;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n shadowGenerator.bias = this._bias;\r\n shadowGenerator.normalBias = this._normalBias;\r\n shadowGenerator.darkness = this._darkness;\r\n shadowGenerator.transparencyShadow = this._transparencyShadow;\r\n shadowGenerator.enableSoftTransparentShadow = this._enableSoftTransparentShadow;\r\n shadowGenerator.useOpacityTextureForTransparentShadow = this._useOpacityTextureForTransparentShadow;\r\n shadowGenerator.filter = this._filter;\r\n shadowGenerator.filteringQuality = this._filteringQuality;\r\n\r\n const shadowMap = shadowGenerator.getShadowMap()!;\r\n shadowMap._disableEngineStages = true;\r\n shadowMap.cameraForLOD = this._camera;\r\n\r\n (this.shadowGenerator as WritableObject<ShadowGenerator | undefined>) = shadowGenerator;\r\n }\r\n }\r\n\r\n public override isReady(): boolean {\r\n return !!this._shadowGenerator && !!this._shadowGenerator.getShadowMap()?.isReadyForRendering();\r\n }\r\n\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\r\n\r\n /**\r\n * Creates a new shadow generator task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene to create the shadow generator for.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph);\r\n\r\n this._engine = scene.getEngine();\r\n this._scene = scene;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.light === undefined || this.objectList === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light, objectList and camera are required`);\r\n }\r\n\r\n // Make sure the renderList / particleSystemList are set when FrameGraphShadowGeneratorTask.isReady() is called!\r\n const shadowMap = this._shadowGenerator!.getShadowMap()!;\r\n\r\n shadowMap.renderList = this.objectList.meshes;\r\n shadowMap.particleSystemList = this.objectList.particleSystems;\r\n\r\n const shadowTextureHandle = this._frameGraph.textureManager.importTexture(`${this.name} shadowmap`, this._shadowGenerator!.getShadowMap()!.getInternalTexture()!);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, shadowTextureHandle);\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((_context) => {\r\n if (!this.light.isEnabled() || !this.light.shadowEnabled) {\r\n return;\r\n }\r\n\r\n const shadowMap = this._shadowGenerator!.getShadowMap()!;\r\n\r\n shadowMap.renderList = this.objectList.meshes;\r\n shadowMap.particleSystemList = this.objectList.particleSystems;\r\n\r\n const currentRenderTarget = this._engine._currentRenderTarget;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n shadowMap.render();\r\n\r\n if (this._engine._currentRenderTarget !== currentRenderTarget) {\r\n if (!currentRenderTarget) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n this._engine.bindFramebuffer(currentRenderTarget);\r\n }\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n public override dispose() {\r\n this._shadowGenerator?.dispose();\r\n this._shadowGenerator = undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -25,6 +25,9 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
|
|
|
25
25
|
if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {
|
|
26
26
|
throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);
|
|
27
27
|
}
|
|
28
|
+
// Make sure the renderList / particleSystemList are set when FrameGraphObjectRendererTask.isReady() is called!
|
|
29
|
+
this._renderer.renderList = this.objectList.meshes;
|
|
30
|
+
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
28
31
|
const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);
|
|
29
32
|
let depthEnabled = false;
|
|
30
33
|
if (this.depthTexture !== undefined) {
|
|
@@ -59,6 +62,7 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
|
|
|
59
62
|
this._textureWidth = outputTextureDescription.size.width;
|
|
60
63
|
this._textureHeight = outputTextureDescription.size.height;
|
|
61
64
|
let pingPongRenderTargetWrapper;
|
|
65
|
+
this._setLightsForShadow();
|
|
62
66
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
63
67
|
pass.setRenderTarget(this.destinationTexture);
|
|
64
68
|
pass.setRenderTargetDepth(this.depthTexture);
|
|
@@ -94,12 +98,6 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
|
|
|
94
98
|
passDisabled.setExecuteFunc((context) => {
|
|
95
99
|
context.copyTexture(this.destinationTexture);
|
|
96
100
|
});
|
|
97
|
-
if (this.dependencies !== undefined) {
|
|
98
|
-
for (const handle of this.dependencies) {
|
|
99
|
-
pass.useTexture(handle);
|
|
100
|
-
passDisabled.useTexture(handle);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
//# sourceMappingURL=taaObjectRendererTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taaObjectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/taaObjectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,4BAA4B;IAQ7E;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,KAAY,EAAE,OAA+B;QAC3F,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExC,IAAI,CAAC,WAAW,GAAG,IAAI,kBAAkB,CAAC,GAAG,IAAI,eAAe,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACrF,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;IAChE,CAAC;IAEe,MAAM;QAClB,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACzE,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAA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C;YACP,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACjD,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACxB,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACpC,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, Scene, DrawWrapper, FrameGraphTextureCreationOptions, ObjectRendererOptions, FrameGraphRenderTarget } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\r\n */\r\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The TAA post process.\r\n */\r\n public readonly postProcess: ThinTAAPostProcess;\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n\r\n /**\r\n * Constructs a new TAA object renderer task.\r\n * @param name The name of the task\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph, scene, options);\r\n\r\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n }\r\n\r\n public override record() {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this.postProcess.camera = this.camera;\r\n this.postProcess.textureWidth = outputTextureDescription.size.width;\r\n this.postProcess.textureHeight = outputTextureDescription.size.height;\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: outputTextureDescription.size,\r\n options: {\r\n createMipMaps: outputTextureDescription.options.createMipMaps,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n creationFlags: [0],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n let pingPongRenderTargetWrapper: FrameGraphRenderTarget | undefined;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n this.postProcess.updateProjectionMatrix();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\r\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\r\n if (!this.postProcess.disabled) {\r\n this._scene.activeCamera = this.camera;\r\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\r\n }\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n this._scene.activeCamera = null;\r\n\r\n pingPongRenderTargetWrapper = pingPongRenderTargetWrapper || context.createRenderTarget(`${this.name} ping/pong`, pingPongHandle);\r\n\r\n context.bindRenderTarget(pingPongRenderTargetWrapper, \"frame graph - TAA merge with history texture\");\r\n\r\n if (!this.postProcess.disabled) {\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n this.postProcess.bind();\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.destinationTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n });\r\n } else {\r\n context.copyTexture(this.destinationTexture);\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.destinationTexture);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"taaObjectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/taaObjectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,4BAA4B;IAQ7E;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,KAAY,EAAE,OAA+B;QAC3F,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExC,IAAI,CAAC,WAAW,GAAG,IAAI,kBAAkB,CAAC,GAAG,IAAI,eAAe,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACrF,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;IAChE,CAAC;IAEe,MAAM;QAClB,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,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,GAAG,EAAE;oBAC7D,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;oBACxB,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;oBAC3G,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;gBACtG,CAAC,CAAC,CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACjD,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, Scene, DrawWrapper, FrameGraphTextureCreationOptions, ObjectRendererOptions, FrameGraphRenderTarget } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\r\n */\r\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The TAA post process.\r\n */\r\n public readonly postProcess: ThinTAAPostProcess;\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n\r\n /**\r\n * Constructs a new TAA object renderer task.\r\n * @param name The name of the task\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph, scene, options);\r\n\r\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n }\r\n\r\n public override record() {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\r\n }\r\n\r\n // Make sure the renderList / particleSystemList are set when FrameGraphObjectRendererTask.isReady() is called!\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this.postProcess.camera = this.camera;\r\n this.postProcess.textureWidth = outputTextureDescription.size.width;\r\n this.postProcess.textureHeight = outputTextureDescription.size.height;\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: outputTextureDescription.size,\r\n options: {\r\n createMipMaps: outputTextureDescription.options.createMipMaps,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n creationFlags: [0],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n let pingPongRenderTargetWrapper: FrameGraphRenderTarget | undefined;\r\n\r\n this._setLightsForShadow();\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n this.postProcess.updateProjectionMatrix();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\r\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\r\n if (!this.postProcess.disabled) {\r\n this._scene.activeCamera = this.camera;\r\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\r\n }\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n this._scene.activeCamera = null;\r\n\r\n pingPongRenderTargetWrapper = pingPongRenderTargetWrapper || context.createRenderTarget(`${this.name} ping/pong`, pingPongHandle);\r\n\r\n context.bindRenderTarget(pingPongRenderTargetWrapper, \"frame graph - TAA merge with history texture\");\r\n\r\n if (!this.postProcess.disabled) {\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n this.postProcess.bind();\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.destinationTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n });\r\n } else {\r\n context.copyTexture(this.destinationTexture);\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.destinationTexture);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -17,8 +17,8 @@ export class FrameGraphCopyToTextureTask extends FrameGraphTask {
|
|
|
17
17
|
throw new Error(`FrameGraphCopyToTextureTask "${this.name}": sourceTexture and destinationTexture are required`);
|
|
18
18
|
}
|
|
19
19
|
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
|
|
20
|
+
this._internalDependencies.push(this.sourceTexture);
|
|
20
21
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
21
|
-
pass.useTexture(this.sourceTexture);
|
|
22
22
|
pass.setRenderTarget(this.outputTexture);
|
|
23
23
|
pass.setExecuteFunc((context) => {
|
|
24
24
|
context.copyTexture(this.sourceTexture);
|