@onerjs/core 8.30.4 → 8.30.6
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/Actions/action.d.ts +5 -0
- package/Actions/action.js.map +1 -1
- package/Actions/actionManager.js +6 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +0 -2
- package/Animations/runtimeAnimation.js +3 -5
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioSceneComponent.d.ts +9 -5
- package/Audio/audioSceneComponent.js +1 -0
- package/Audio/audioSceneComponent.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +1 -0
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
- package/AudioV2/webAudio/webAudioEngine.js +8 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +10 -5
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/camera.d.ts +4 -0
- package/Cameras/camera.js +18 -9
- package/Cameras/camera.js.map +1 -1
- package/Collisions/gpuPicker.js +0 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +3 -1
- package/Decorators/nodeDecorator.js +2 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +12 -13
- package/Engines/nativeEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +17 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +70 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
- package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
- package/FrameGraph/Node/Blocks/executeBlock.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/Blocks/inputBlock.js +2 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
- package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -3
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +11 -1
- package/FrameGraph/Passes/pass.js +11 -1
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +4 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +1 -1
- package/FrameGraph/frameGraph.js +3 -6
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +8 -1
- package/FrameGraph/frameGraphContext.js +9 -0
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +4 -2
- package/FrameGraph/frameGraphRenderContext.js +11 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +11 -2
- package/FrameGraph/frameGraphTask.js +17 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +2 -2
- 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/Lights/directionalLight.js +1 -4
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/pointLight.js +2 -5
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +4 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +11 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
- package/Materials/floatingOriginMatrixOverrides.js +14 -2
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +8 -0
- package/Materials/materialHelper.functions.js +31 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +21 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +55 -16
- package/Maths/math.vector.functions.js +68 -10
- package/Maths/math.vector.functions.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +10 -0
- package/Misc/copyTextureToTexture.js +15 -0
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/decorators.d.ts +1 -1
- package/Misc/decorators.js.map +1 -1
- package/Misc/dumpTools.d.ts +20 -0
- package/Misc/dumpTools.js +60 -49
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/index.d.ts +1 -2
- package/Misc/index.js +1 -2
- package/Misc/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
- package/Particles/Node/Blocks/Emitters/index.js +5 -4
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
- package/Particles/Node/Blocks/systemBlock.js +82 -3
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
- package/Particles/Node/nodeParticleBuildState.js +12 -22
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
- package/Particles/Node/nodeParticleSystemSet.helper.js +344 -112
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
- package/Physics/v2/Plugins/havokPlugin.js +73 -9
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +12 -2
- package/Physics/v2/physicsEngine.js +15 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
- package/PostProcesses/thinSSAO2PostProcess.js +18 -6
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/particles.vertex.js +1 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/picking.fragment.js +1 -1
- package/Shaders/picking.fragment.js.map +1 -1
- package/Shaders/picking.vertex.js +1 -1
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -4
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +1 -1
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +1 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +1 -1
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +10 -8
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +8 -0
- package/XR/features/WebXRLightEstimation.js +6 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/assetContainer.d.ts +1 -1
- package/assetContainer.js +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +7 -2
- package/scene.js +11 -8
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taaTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/taaTask.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,yBAAyB;IAiB5D;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAoC;QAClF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/F,CAAC;IAEe,MAAM;QAClB,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAA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,CAAC,IAAI,EAAE,CAAC;YAC5B,CAAC,EACD,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,SAAS,CACjB,CAAC;QACN,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,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAChD,YAAY,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAEpD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC/D,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAc,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC1F,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphRenderPass,\r\n FrameGraphObjectRendererTask,\r\n FrameGraphTextureCreationOptions,\r\n Observer,\r\n ObjectRenderer,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n} from \"core/index\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task which applies a Temporal Anti-Aliasing post process.\r\n */\r\nexport class FrameGraphTAATask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinTAAPostProcess;\r\n\r\n /**\r\n * The object renderer task used to render the scene objects.\r\n */\r\n public objectRendererTask: FrameGraphObjectRendererTask;\r\n\r\n /**\r\n * The handle to the velocity texture. Only needed if postProcess.reprojectHistory is enabled.\r\n * Note that you must use the linear velocity texture!\r\n */\r\n public velocityTexture: FrameGraphTextureHandle;\r\n\r\n protected _onBeforeRenderSceneObserver: Observer<Scene>;\r\n protected _initRenderingObserver: Observer<ObjectRenderer>;\r\n\r\n /**\r\n * Constructs a new Temporal Anti-Aliasing task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param thinPostProcess The thin post process to use for the Temporal Anti-Aliasing effect. If not provided, a new one will be created.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinTAAPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinTAAPostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.objectRendererTask === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture and objectRendererTask are required`);\r\n }\r\n\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n this._onBeforeRenderSceneObserver = this._frameGraph.scene.onBeforeRenderObservable.add(() => {\r\n if (this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n }\r\n });\r\n\r\n const objectRenderer = this.objectRendererTask.objectRenderer;\r\n\r\n objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._initRenderingObserver = objectRenderer.onInitRenderingObservable.add(() => {\r\n if (!this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n\r\n // We pass false to this.camera.getProjectionMatrix() when TAA is enabled to avoid overwriting the projection matrix calculated by the call to this.postProcess.updateJitter()\r\n const camera = objectRenderer.activeCamera!;\r\n this._frameGraph.scene.setTransformMatrix(camera.getViewMatrix(), camera.getProjectionMatrix(this.postProcess.disabled));\r\n }\r\n });\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const sourceSize = textureManager.getTextureAbsoluteDimensions(this.sourceTexture);\r\n\r\n this._sourceWidth = this._outputWidth = sourceSize.width;\r\n this._sourceHeight = this._outputHeight = sourceSize.height;\r\n\r\n const renderTextureSize = textureManager.getTextureAbsoluteDimensions(this.objectRendererTask.outputTexture);\r\n\r\n this.postProcess.textureWidth = renderTextureSize.width;\r\n this.postProcess.textureHeight = renderTextureSize.height;\r\n\r\n const pingPongTextureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: sourceSize,\r\n options: {\r\n createMipMaps: false,\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 = textureManager.createRenderTargetTexture(`${this.name} history`, pingPongTextureCreationOptions);\r\n\r\n textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n objectRenderer.dontSetTransformationMatrix = !this.postProcess.reprojectHistory;\r\n this.postProcess.camera = objectRenderer.activeCamera;\r\n\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n if (this.velocityTexture !== undefined) {\r\n context.setTextureSamplingMode(this.velocityTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n }\r\n\r\n context.setTextureSamplingMode(pingPongHandle, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture!);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n if (this.postProcess.reprojectHistory && this.velocityTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"velocitySampler\", this.velocityTexture);\r\n }\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest\r\n );\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture!);\r\n });\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose() {\r\n this.objectRendererTask?.objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"taaTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/taaTask.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kB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,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC1F,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphRenderPass,\r\n FrameGraphObjectRendererTask,\r\n FrameGraphTextureCreationOptions,\r\n Observer,\r\n ObjectRenderer,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n} from \"core/index\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task which applies a Temporal Anti-Aliasing post process.\r\n */\r\nexport class FrameGraphTAATask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinTAAPostProcess;\r\n\r\n /**\r\n * The object renderer task used to render the scene objects.\r\n */\r\n public objectRendererTask: FrameGraphObjectRendererTask;\r\n\r\n /**\r\n * The handle to the velocity texture. Only needed if postProcess.reprojectHistory is enabled.\r\n * Note that you must use the linear velocity texture!\r\n */\r\n public velocityTexture?: FrameGraphTextureHandle;\r\n\r\n protected _onBeforeRenderSceneObserver: Observer<Scene>;\r\n protected _initRenderingObserver: Observer<ObjectRenderer>;\r\n\r\n /**\r\n * Constructs a new Temporal Anti-Aliasing task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param thinPostProcess The thin post process to use for the Temporal Anti-Aliasing effect. If not provided, a new one will be created.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinTAAPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinTAAPostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.objectRendererTask === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture and objectRendererTask are required`);\r\n }\r\n\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n this._onBeforeRenderSceneObserver = this._frameGraph.scene.onBeforeRenderObservable.add(() => {\r\n if (this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n }\r\n });\r\n\r\n const objectRenderer = this.objectRendererTask.objectRenderer;\r\n\r\n objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._initRenderingObserver = objectRenderer.onInitRenderingObservable.add(() => {\r\n if (!this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n\r\n // We pass false to this.camera.getProjectionMatrix() when TAA is enabled to avoid overwriting the projection matrix calculated by the call to this.postProcess.updateJitter()\r\n const camera = objectRenderer.activeCamera!;\r\n this._frameGraph.scene.setTransformMatrix(camera.getViewMatrix(), camera.getProjectionMatrix(this.postProcess.disabled));\r\n }\r\n });\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const sourceSize = textureManager.getTextureAbsoluteDimensions(this.sourceTexture);\r\n\r\n this._sourceWidth = this._outputWidth = sourceSize.width;\r\n this._sourceHeight = this._outputHeight = sourceSize.height;\r\n\r\n const renderTextureSize = textureManager.getTextureAbsoluteDimensions(this.objectRendererTask.outputTexture);\r\n\r\n this.postProcess.textureWidth = renderTextureSize.width;\r\n this.postProcess.textureHeight = renderTextureSize.height;\r\n\r\n const pingPongTextureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: sourceSize,\r\n options: {\r\n createMipMaps: false,\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 = textureManager.createRenderTargetTexture(`${this.name} history`, pingPongTextureCreationOptions);\r\n\r\n textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n objectRenderer.dontSetTransformationMatrix = !this.postProcess.reprojectHistory;\r\n this.postProcess.camera = objectRenderer.activeCamera;\r\n\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n if (this.velocityTexture !== undefined) {\r\n context.setTextureSamplingMode(this.velocityTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n }\r\n\r\n context.setTextureSamplingMode(pingPongHandle, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture!);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n if (this.postProcess.reprojectHistory && this.velocityTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"velocitySampler\", this.velocityTexture);\r\n }\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest\r\n );\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture!);\r\n });\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose() {\r\n this.objectRendererTask?.objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -55,19 +55,19 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
55
55
|
isMainObjectRenderer: boolean;
|
|
56
56
|
private _renderParticles;
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* Defines if particles should be rendered (default is true).
|
|
59
59
|
*/
|
|
60
60
|
get renderParticles(): boolean;
|
|
61
61
|
set renderParticles(value: boolean);
|
|
62
62
|
private _renderSprites;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* Defines if sprites should be rendered (default is true).
|
|
65
65
|
*/
|
|
66
66
|
get renderSprites(): boolean;
|
|
67
67
|
set renderSprites(value: boolean);
|
|
68
68
|
private _forceLayerMaskCheck;
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Forces checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
|
|
71
71
|
*/
|
|
72
72
|
get forceLayerMaskCheck(): boolean;
|
|
73
73
|
set forceLayerMaskCheck(value: boolean);
|
|
@@ -85,7 +85,7 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
85
85
|
set enableOutlineRendering(value: boolean);
|
|
86
86
|
/**
|
|
87
87
|
* The output texture.
|
|
88
|
-
* This texture will point to the same texture than the targetTexture property
|
|
88
|
+
* This texture will point to the same texture than the targetTexture property.
|
|
89
89
|
* Note, however, that the handle itself will be different!
|
|
90
90
|
*/
|
|
91
91
|
readonly outputTexture: FrameGraphTextureHandle;
|
|
@@ -32,7 +32,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
32
32
|
this._renderer.disableImageProcessing = value;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Defines if particles should be rendered (default is true).
|
|
36
36
|
*/
|
|
37
37
|
get renderParticles() {
|
|
38
38
|
return this._renderParticles;
|
|
@@ -45,7 +45,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
45
45
|
this._renderer.renderParticles = value;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Defines if sprites should be rendered (default is true).
|
|
49
49
|
*/
|
|
50
50
|
get renderSprites() {
|
|
51
51
|
return this._renderSprites;
|
|
@@ -58,7 +58,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
58
58
|
this._renderer.renderSprites = value;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Forces checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
|
|
62
62
|
*/
|
|
63
63
|
get forceLayerMaskCheck() {
|
|
64
64
|
return this._forceLayerMaskCheck;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAiBA,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;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CA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C;gBACvD,CAAC;gBACD,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 FrameGraphRenderPass,\r\n AbstractEngine,\r\n BoundingBoxRenderer,\r\n ShadowLight,\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\nimport { Constants } from \"../../../Engines/constants\";\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 target texture where the objects will be rendered.\r\n */\r\n public targetTexture: FrameGraphTextureHandle | 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 private _disableImageProcessing = false;\r\n /**\r\n * If image processing should be disabled (default is false).\r\n * false means that the default image processing configuration will be applied (the one from the scene)\r\n */\r\n public get disableImageProcessing() {\r\n return this._disableImageProcessing;\r\n }\r\n\r\n public set disableImageProcessing(value: boolean) {\r\n if (value === this._disableImageProcessing) {\r\n return;\r\n }\r\n\r\n this._disableImageProcessing = value;\r\n this._renderer.disableImageProcessing = value;\r\n }\r\n\r\n /**\r\n * Sets this property to true if this task is the main object renderer of the frame graph.\r\n * It will help to locate the main object renderer in the frame graph when multiple object renderers are used.\r\n * This is useful for the inspector to know which object renderer to use for additional rendering features like wireframe rendering or frustum light debugging.\r\n * It is also used to determine the main camera used by the frame graph: this is the camera used by the main object renderer.\r\n */\r\n public isMainObjectRenderer = false;\r\n\r\n private _renderParticles = true;\r\n /**\r\n * Define if particles should be rendered (default is true).\r\n */\r\n public get renderParticles() {\r\n return this._renderParticles;\r\n }\r\n\r\n public set renderParticles(value: boolean) {\r\n if (value === this._renderParticles) {\r\n return;\r\n }\r\n\r\n this._renderParticles = value;\r\n this._renderer.renderParticles = value;\r\n }\r\n\r\n private _renderSprites = true;\r\n /**\r\n * Define if sprites should be rendered (default is true).\r\n */\r\n public get renderSprites() {\r\n return this._renderSprites;\r\n }\r\n\r\n public set renderSprites(value: boolean) {\r\n if (value === this._renderSprites) {\r\n return;\r\n }\r\n\r\n this._renderSprites = value;\r\n this._renderer.renderSprites = value;\r\n }\r\n\r\n private _forceLayerMaskCheck = true;\r\n /**\r\n * Force checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.\r\n */\r\n public get forceLayerMaskCheck() {\r\n return this._forceLayerMaskCheck;\r\n }\r\n\r\n public set forceLayerMaskCheck(value: boolean) {\r\n if (value === this._forceLayerMaskCheck) {\r\n return;\r\n }\r\n\r\n this._forceLayerMaskCheck = value;\r\n this._renderer.forceLayerMaskCheck = value;\r\n }\r\n\r\n private _enableBoundingBoxRendering = true;\r\n /**\r\n * Enables the rendering of bounding boxes for meshes (still subject to Mesh.showBoundingBox or scene.forceShowBoundingBoxes). Default is true.\r\n */\r\n public get enableBoundingBoxRendering() {\r\n return this._enableBoundingBoxRendering;\r\n }\r\n\r\n public set enableBoundingBoxRendering(value: boolean) {\r\n if (value === this._enableBoundingBoxRendering) {\r\n return;\r\n }\r\n\r\n this._enableBoundingBoxRendering = value;\r\n this._renderer.enableBoundingBoxRendering = value;\r\n }\r\n\r\n private _enableOutlineRendering = true;\r\n /**\r\n * Enables the rendering of outlines/overlays for meshes (still subject to Mesh.renderOutline/Mesh.renderOverlay). Default is true.\r\n */\r\n public get enableOutlineRendering() {\r\n return this._enableOutlineRendering;\r\n }\r\n\r\n public set enableOutlineRendering(value: boolean) {\r\n if (value === this._enableOutlineRendering) {\r\n return;\r\n }\r\n\r\n this._enableOutlineRendering = value;\r\n this._renderer.enableOutlineRendering = value;\r\n }\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the targetTexture 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 _engine: AbstractEngine;\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._engine = scene.getEngine();\r\n this._externalObjectRenderer = !!existingObjectRenderer;\r\n this._renderer = existingObjectRenderer ?? new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.disableImageProcessing = this._disableImageProcessing;\r\n this._renderer.renderParticles = this._renderParticles;\r\n this._renderer.renderSprites = this._renderSprites;\r\n this._renderer.enableBoundingBoxRendering = this._enableBoundingBoxRendering;\r\n this._renderer.forceLayerMaskCheck = this._forceLayerMaskCheck;\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): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: targetTexture 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 targetTextures = Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture];\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(targetTextures[0]);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && (targetTextures[0] !== backbufferColorTextureHandle || targetTextures.length > 1)) {\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 && targetTextures[0] === 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 target 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, targetTextures[0]);\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(targetTextures);\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 // The cast to \"any\" is to avoid an error in ES6 in case you don't import boundingBoxRenderer\r\n const boundingBoxRenderer = (this as any).getBoundingBoxRenderer?.() as Nullable<BoundingBoxRenderer>;\r\n\r\n const currentBoundingBoxMeshList = boundingBoxRenderer && boundingBoxRenderer.renderList.length > 0 ? boundingBoxRenderer.renderList.data.slice() : [];\r\n if (boundingBoxRenderer) {\r\n currentBoundingBoxMeshList.length = boundingBoxRenderer.renderList.length;\r\n }\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n const camera = this._renderer.activeCamera;\r\n if (camera && camera.cameraRigMode !== Constants.RIG_MODE_NONE && !camera._renderingMultiview) {\r\n for (let index = 0; index < camera._rigCameras.length; index++) {\r\n const rigCamera = camera._rigCameras[index];\r\n\r\n rigCamera.rigParent = undefined; // for some reasons, ObjectRenderer uses the rigParent viewport if rigParent is defined (we want to use rigCamera.viewport instead)\r\n\r\n this._renderer.activeCamera = rigCamera;\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n rigCamera.rigParent = camera;\r\n }\r\n this._renderer.activeCamera = camera;\r\n } else {\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n }\r\n\r\n additionalExecute?.(context);\r\n\r\n if (boundingBoxRenderer) {\r\n boundingBoxRenderer.renderList.data = currentBoundingBoxMeshList;\r\n boundingBoxRenderer.renderList.length = currentBoundingBoxMeshList.length;\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(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n return pass;\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 if (!(light as ShadowLight).setShadowProjectionMatrix) {\r\n continue; // Ignore lights that cannot cast shadows\r\n }\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 if (!(light as ShadowLight).setShadowProjectionMatrix) {\r\n continue; // Ignore lights that cannot cast shadows\r\n }\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":"AAiBA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAA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AAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpC,IAAI,CAAE,KAAqB,CAAC,yBAAyB,EAAE,CAAC;oBACpD,SAAS,CAAC,yCAAyC;gBACvD,CAAC;gBACD,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 FrameGraphRenderPass,\r\n AbstractEngine,\r\n BoundingBoxRenderer,\r\n ShadowLight,\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\nimport { Constants } from \"../../../Engines/constants\";\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 target texture where the objects will be rendered.\r\n */\r\n public targetTexture: FrameGraphTextureHandle | 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 private _disableImageProcessing = false;\r\n /**\r\n * If image processing should be disabled (default is false).\r\n * false means that the default image processing configuration will be applied (the one from the scene)\r\n */\r\n public get disableImageProcessing() {\r\n return this._disableImageProcessing;\r\n }\r\n\r\n public set disableImageProcessing(value: boolean) {\r\n if (value === this._disableImageProcessing) {\r\n return;\r\n }\r\n\r\n this._disableImageProcessing = value;\r\n this._renderer.disableImageProcessing = value;\r\n }\r\n\r\n /**\r\n * Sets this property to true if this task is the main object renderer of the frame graph.\r\n * It will help to locate the main object renderer in the frame graph when multiple object renderers are used.\r\n * This is useful for the inspector to know which object renderer to use for additional rendering features like wireframe rendering or frustum light debugging.\r\n * It is also used to determine the main camera used by the frame graph: this is the camera used by the main object renderer.\r\n */\r\n public isMainObjectRenderer = false;\r\n\r\n private _renderParticles = true;\r\n /**\r\n * Defines if particles should be rendered (default is true).\r\n */\r\n public get renderParticles() {\r\n return this._renderParticles;\r\n }\r\n\r\n public set renderParticles(value: boolean) {\r\n if (value === this._renderParticles) {\r\n return;\r\n }\r\n\r\n this._renderParticles = value;\r\n this._renderer.renderParticles = value;\r\n }\r\n\r\n private _renderSprites = true;\r\n /**\r\n * Defines if sprites should be rendered (default is true).\r\n */\r\n public get renderSprites() {\r\n return this._renderSprites;\r\n }\r\n\r\n public set renderSprites(value: boolean) {\r\n if (value === this._renderSprites) {\r\n return;\r\n }\r\n\r\n this._renderSprites = value;\r\n this._renderer.renderSprites = value;\r\n }\r\n\r\n private _forceLayerMaskCheck = true;\r\n /**\r\n * Forces checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.\r\n */\r\n public get forceLayerMaskCheck() {\r\n return this._forceLayerMaskCheck;\r\n }\r\n\r\n public set forceLayerMaskCheck(value: boolean) {\r\n if (value === this._forceLayerMaskCheck) {\r\n return;\r\n }\r\n\r\n this._forceLayerMaskCheck = value;\r\n this._renderer.forceLayerMaskCheck = value;\r\n }\r\n\r\n private _enableBoundingBoxRendering = true;\r\n /**\r\n * Enables the rendering of bounding boxes for meshes (still subject to Mesh.showBoundingBox or scene.forceShowBoundingBoxes). Default is true.\r\n */\r\n public get enableBoundingBoxRendering() {\r\n return this._enableBoundingBoxRendering;\r\n }\r\n\r\n public set enableBoundingBoxRendering(value: boolean) {\r\n if (value === this._enableBoundingBoxRendering) {\r\n return;\r\n }\r\n\r\n this._enableBoundingBoxRendering = value;\r\n this._renderer.enableBoundingBoxRendering = value;\r\n }\r\n\r\n private _enableOutlineRendering = true;\r\n /**\r\n * Enables the rendering of outlines/overlays for meshes (still subject to Mesh.renderOutline/Mesh.renderOverlay). Default is true.\r\n */\r\n public get enableOutlineRendering() {\r\n return this._enableOutlineRendering;\r\n }\r\n\r\n public set enableOutlineRendering(value: boolean) {\r\n if (value === this._enableOutlineRendering) {\r\n return;\r\n }\r\n\r\n this._enableOutlineRendering = value;\r\n this._renderer.enableOutlineRendering = value;\r\n }\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the targetTexture property.\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 _engine: AbstractEngine;\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._engine = scene.getEngine();\r\n this._externalObjectRenderer = !!existingObjectRenderer;\r\n this._renderer = existingObjectRenderer ?? new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.disableImageProcessing = this._disableImageProcessing;\r\n this._renderer.renderParticles = this._renderParticles;\r\n this._renderer.renderSprites = this._renderSprites;\r\n this._renderer.enableBoundingBoxRendering = this._enableBoundingBoxRendering;\r\n this._renderer.forceLayerMaskCheck = this._forceLayerMaskCheck;\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): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: targetTexture 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 targetTextures = Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture];\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(targetTextures[0]);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && (targetTextures[0] !== backbufferColorTextureHandle || targetTextures.length > 1)) {\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 && targetTextures[0] === 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 target 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, targetTextures[0]);\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(targetTextures);\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 // The cast to \"any\" is to avoid an error in ES6 in case you don't import boundingBoxRenderer\r\n const boundingBoxRenderer = (this as any).getBoundingBoxRenderer?.() as Nullable<BoundingBoxRenderer>;\r\n\r\n const currentBoundingBoxMeshList = boundingBoxRenderer && boundingBoxRenderer.renderList.length > 0 ? boundingBoxRenderer.renderList.data.slice() : [];\r\n if (boundingBoxRenderer) {\r\n currentBoundingBoxMeshList.length = boundingBoxRenderer.renderList.length;\r\n }\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n const camera = this._renderer.activeCamera;\r\n if (camera && camera.cameraRigMode !== Constants.RIG_MODE_NONE && !camera._renderingMultiview) {\r\n for (let index = 0; index < camera._rigCameras.length; index++) {\r\n const rigCamera = camera._rigCameras[index];\r\n\r\n rigCamera.rigParent = undefined; // for some reasons, ObjectRenderer uses the rigParent viewport if rigParent is defined (we want to use rigCamera.viewport instead)\r\n\r\n this._renderer.activeCamera = rigCamera;\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n rigCamera.rigParent = camera;\r\n }\r\n this._renderer.activeCamera = camera;\r\n } else {\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n }\r\n\r\n additionalExecute?.(context);\r\n\r\n if (boundingBoxRenderer) {\r\n boundingBoxRenderer.renderList.data = currentBoundingBoxMeshList;\r\n boundingBoxRenderer.renderList.length = currentBoundingBoxMeshList.length;\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(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n return pass;\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 if (!(light as ShadowLight).setShadowProjectionMatrix) {\r\n continue; // Ignore lights that cannot cast shadows\r\n }\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 if (!(light as ShadowLight).setShadowProjectionMatrix) {\r\n continue; // Ignore lights that cannot cast shadows\r\n }\r\n light.shadowEnabled = shadowEnabled.get(light)!;\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameGraph, FrameGraphTextureHandle } from "../../../index.js";
|
|
1
|
+
import type { FrameGraph, FrameGraphTextureHandle, IViewportLike, Nullable } from "../../../index.js";
|
|
2
2
|
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
3
3
|
/**
|
|
4
4
|
* Task used to copy a texture to another texture.
|
|
@@ -12,6 +12,12 @@ export declare class FrameGraphCopyToTextureTask extends FrameGraphTask {
|
|
|
12
12
|
* The target texture to copy to.
|
|
13
13
|
*/
|
|
14
14
|
targetTexture: FrameGraphTextureHandle;
|
|
15
|
+
/**
|
|
16
|
+
* The viewport to use when doing the copy.
|
|
17
|
+
* If set to null, the currently active viewport is used.
|
|
18
|
+
* If undefined (default), the viewport is reset to a full screen viewport before performing the copy.
|
|
19
|
+
*/
|
|
20
|
+
viewport?: Nullable<IViewportLike>;
|
|
15
21
|
/**
|
|
16
22
|
* The output texture (same as targetTexture, but the handle may be different).
|
|
17
23
|
*/
|
|
@@ -21,7 +21,10 @@ export class FrameGraphCopyToTextureTask extends FrameGraphTask {
|
|
|
21
21
|
pass.addDependencies(this.sourceTexture);
|
|
22
22
|
pass.setRenderTarget(this.outputTexture);
|
|
23
23
|
pass.setExecuteFunc((context) => {
|
|
24
|
-
|
|
24
|
+
if (this.viewport) {
|
|
25
|
+
context.setViewport(this.viewport);
|
|
26
|
+
}
|
|
27
|
+
context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);
|
|
25
28
|
});
|
|
26
29
|
const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
|
|
27
30
|
passDisabled.setRenderTarget(this.outputTexture);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyToTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/copyToTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,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,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;QACpF,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,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, IViewportLike, Nullable } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to copy a texture to another texture.\r\n */\r\nexport class FrameGraphCopyToTextureTask extends FrameGraphTask {\r\n /**\r\n * The source texture to copy from.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The target texture to copy to.\r\n */\r\n public targetTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The viewport to use when doing the copy.\r\n * If set to null, the currently active viewport is used.\r\n * If undefined (default), the viewport is reset to a full screen viewport before performing the copy.\r\n */\r\n public viewport?: Nullable<IViewportLike>;\r\n\r\n /**\r\n * The output texture (same as targetTexture, but the handle may be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new FrameGraphCopyToTextureTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.sourceTexture === undefined || this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphCopyToTextureTask \"${this.name}\": sourceTexture and targetTexture are required`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);\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.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
|
|
@@ -121,7 +121,7 @@ export declare class FrameGraph implements IDisposable {
|
|
|
121
121
|
* Returns a promise that resolves when the frame graph is ready to be executed
|
|
122
122
|
* This method must be called after the graph has been built (FrameGraph.build called)!
|
|
123
123
|
* @param timeStep Time step in ms between retries (default is 16)
|
|
124
|
-
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is
|
|
124
|
+
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)
|
|
125
125
|
* @returns The promise that resolves when the graph is ready
|
|
126
126
|
*/
|
|
127
127
|
whenReadyAsync(timeStep?: number, maxTimeout?: number): Promise<void>;
|
package/FrameGraph/frameGraph.js
CHANGED
|
@@ -198,10 +198,10 @@ export class FrameGraph {
|
|
|
198
198
|
* Returns a promise that resolves when the frame graph is ready to be executed
|
|
199
199
|
* This method must be called after the graph has been built (FrameGraph.build called)!
|
|
200
200
|
* @param timeStep Time step in ms between retries (default is 16)
|
|
201
|
-
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is
|
|
201
|
+
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)
|
|
202
202
|
* @returns The promise that resolves when the graph is ready
|
|
203
203
|
*/
|
|
204
|
-
async whenReadyAsync(timeStep = 16, maxTimeout =
|
|
204
|
+
async whenReadyAsync(timeStep = 16, maxTimeout = 5000) {
|
|
205
205
|
let firstNotReadyTask = null;
|
|
206
206
|
return await new Promise((resolve) => {
|
|
207
207
|
this._whenReadyAsyncCancel = _RetryWithInterval(() => {
|
|
@@ -247,10 +247,7 @@ export class FrameGraph {
|
|
|
247
247
|
this._renderContext.bindRenderTarget();
|
|
248
248
|
this.textureManager._updateHistoryTextures();
|
|
249
249
|
for (const task of this._tasks) {
|
|
250
|
-
|
|
251
|
-
for (const pass of passes) {
|
|
252
|
-
pass._execute();
|
|
253
|
-
}
|
|
250
|
+
task._execute();
|
|
254
251
|
}
|
|
255
252
|
this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer
|
|
256
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,EAAE,+BAA8B;AAC3D,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,iBAAiB,EAAE,qCAAoC;AAEhE,qDAAoD;AACpD,4DAA2D;AAE3D,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACnB,+DAAU,CAAA;IACV,+DAAU,CAAA;IACV,2DAAQ,CAAA;AACZ,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED;;;GAGG;AACH,MAAM,OAAO,UAAU;IAkCnB;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;I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AC7B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAEjC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;gBACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8BAA8B;IACpG,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph, IDisposable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _RetryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph implements IDisposable {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Indicates whether the execution of the frame graph is paused (default is false)\r\n */\r\n public pausedExecution = false;\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n try {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n } catch (e) {\r\n this._tasks.length = 0;\r\n this._currentProcessedTask = null;\r\n this.textureManager._isRecordingTask = false;\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return await new Promise((resolve) => {\r\n this._whenReadyAsyncCancel = _RetryWithInterval(\r\n () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n const taskIsReady = task.isReady();\r\n if (!taskIsReady && !firstNotReadyTask) {\r\n firstNotReadyTask = task;\r\n }\r\n ready &&= taskIsReady;\r\n }\r\n return ready;\r\n },\r\n () => {\r\n this._whenReadyAsyncCancel = null;\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n this._whenReadyAsyncCancel = null;\r\n if (!isTimeout) {\r\n Logger.Error(\"FrameGraph: An unexpected error occurred while waiting for the frame graph to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(\r\n `FrameGraph: Timeout while waiting for the frame graph to be ready.${firstNotReadyTask ? ` First task not ready: ${firstNotReadyTask.name}` : \"\"}`\r\n );\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n if (this.pausedExecution) {\r\n return;\r\n }\r\n\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n\r\n this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n\r\n this._scene.removeFrameGraph(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../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CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph, IDisposable } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _RetryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph implements IDisposable {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Indicates whether the execution of the frame graph is paused (default is false)\r\n */\r\n public pausedExecution = false;\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n try {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n } catch (e) {\r\n this._tasks.length = 0;\r\n this._currentProcessedTask = null;\r\n this.textureManager._isRecordingTask = false;\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 5000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return await new Promise((resolve) => {\r\n this._whenReadyAsyncCancel = _RetryWithInterval(\r\n () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n const taskIsReady = task.isReady();\r\n if (!taskIsReady && !firstNotReadyTask) {\r\n firstNotReadyTask = task;\r\n }\r\n ready &&= taskIsReady;\r\n }\r\n return ready;\r\n },\r\n () => {\r\n this._whenReadyAsyncCancel = null;\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n this._whenReadyAsyncCancel = null;\r\n if (!isTimeout) {\r\n Logger.Error(\"FrameGraph: An unexpected error occurred while waiting for the frame graph to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(\r\n `FrameGraph: Timeout while waiting for the frame graph to be ready.${firstNotReadyTask ? ` First task not ready: ${firstNotReadyTask.name}` : \"\"}`\r\n );\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n if (this.pausedExecution) {\r\n return;\r\n }\r\n\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n task._execute();\r\n }\r\n\r\n this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n\r\n this._scene.removeFrameGraph(this);\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AbstractEngine, FrameGraphTextureManager, Scene, FrameGraphTextureHandle, Nullable, InternalTexture } from "../index.js";
|
|
1
|
+
import type { AbstractEngine, FrameGraphTextureManager, Scene, FrameGraphTextureHandle, Nullable, InternalTexture, IViewportLike } from "../index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Base class for frame graph context.
|
|
4
4
|
*/
|
|
@@ -49,4 +49,11 @@ export declare class FrameGraphContext {
|
|
|
49
49
|
* @param depthWrite If true, depth writing is enabled
|
|
50
50
|
*/
|
|
51
51
|
setDepthStates(depthTest: boolean, depthWrite: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Sets the current viewport
|
|
54
|
+
* @param viewport defines the viewport element to be used
|
|
55
|
+
* @param requiredWidth defines the width required for rendering. If not provided, the width of the render texture is used.
|
|
56
|
+
* @param requiredHeight defines the height required for rendering. If not provided the height of the render texture is used.
|
|
57
|
+
*/
|
|
58
|
+
setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
|
|
52
59
|
}
|
|
@@ -75,5 +75,14 @@ export class FrameGraphContext {
|
|
|
75
75
|
this._engine.setDepthBuffer(depthTest);
|
|
76
76
|
this._engine.setDepthWrite(depthWrite);
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Sets the current viewport
|
|
80
|
+
* @param viewport defines the viewport element to be used
|
|
81
|
+
* @param requiredWidth defines the width required for rendering. If not provided, the width of the render texture is used.
|
|
82
|
+
* @param requiredHeight defines the height required for rendering. If not provided the height of the render texture is used.
|
|
83
|
+
*/
|
|
84
|
+
setViewport(viewport, requiredWidth, requiredHeight) {
|
|
85
|
+
this._engine.setViewport(viewport, requiredHeight, requiredWidth);
|
|
86
|
+
}
|
|
78
87
|
}
|
|
79
88
|
//# sourceMappingURL=frameGraphContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphContext.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAI1B,gBAAgB;IAChB,YACuB,OAAuB,EACvB,eAAyC,EACzC,MAAa;QAFb,YAAO,GAAP,OAAO,CAAgB;QACvB,oBAAe,GAAf,eAAe,CAA0B;QACzC,WAAM,GAAN,MAAM,CAAO;IACjC,CAAC;IAEJ;;;;;OAKG;IACI,eAAe,CAAC,SAAiC,EAAE,qBAAqB,GAAG,IAAI;QAClF,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAE9D,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAElC,IAAI,CAAC,MAAM,CAAC,sBAAsB,GAAG,qBAAqB,CAAC;QAE3D,SAAS,CAAC,MAAM,EAAE,CAAC;QAEnB,IAAI,CAAC,MAAM,CAAC,sBAAsB,GAAG,KAAK,CAAC;QAE3C,I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GraphTextureHandle, Nullable, InternalTexture } from \"core/index\";\r\n\r\n/**\r\n * Base class for frame graph context.\r\n */\r\nexport class FrameGraphContext {\r\n private _depthTest: boolean;\r\n private _depthWrite: boolean;\r\n\r\n /** @internal */\r\n constructor(\r\n protected readonly _engine: AbstractEngine,\r\n protected readonly _textureManager: FrameGraphTextureManager,\r\n protected readonly _scene: Scene\r\n ) {}\r\n\r\n /**\r\n * Renders a component without managing the render target.\r\n * Use this method when you have a component that handles its own rendering logic which is not fully integrated into the frame graph system.\r\n * @param component The component to render.\r\n * @param intermediateRendering If true, the scene's intermediate rendering flag will be set to true during the render call (default: true)\r\n */\r\n public renderUnmanaged(component: { render: () => void }, intermediateRendering = true): void {\r\n const currentRenderTarget = this._engine._currentRenderTarget;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._scene._intermediateRendering = intermediateRendering;\r\n\r\n component.render();\r\n\r\n this._scene._intermediateRendering = false;\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 /**\r\n * Gets a texture from a handle.\r\n * Note that if the texture is a history texture, the read texture for the current frame will be returned.\r\n * @param handle The handle of the texture\r\n * @returns The texture or null if not found\r\n */\r\n public getTextureFromHandle(handle: FrameGraphTextureHandle): Nullable<InternalTexture> {\r\n return this._textureManager.getTextureFromHandle(handle);\r\n }\r\n\r\n /**\r\n * Pushes a debug group to the engine's debug stack.\r\n * @param name The name of the debug group\r\n */\r\n public pushDebugGroup(name: string) {\r\n this._engine._debugPushGroup?.(name, 1);\r\n }\r\n\r\n /**\r\n * Pops a debug group from the engine's debug stack.\r\n */\r\n public popDebugGroup() {\r\n this._engine._debugPopGroup?.(1);\r\n }\r\n\r\n /**\r\n * Saves the current depth states (depth testing and depth writing)\r\n */\r\n public saveDepthStates(): void {\r\n this._depthTest = this._engine.getDepthBuffer();\r\n this._depthWrite = this._engine.getDepthWrite();\r\n }\r\n\r\n /**\r\n * Restores the depth states saved by saveDepthStates\r\n */\r\n public restoreDepthStates(): void {\r\n this._engine.setDepthBuffer(this._depthTest);\r\n this._engine.setDepthWrite(this._depthWrite);\r\n }\r\n\r\n /**\r\n * Sets the depth states for the current render target\r\n * @param depthTest If true, depth testing is enabled\r\n * @param depthWrite If true, depth writing is enabled\r\n */\r\n public setDepthStates(depthTest: boolean, depthWrite: boolean): void {\r\n this._engine.setDepthBuffer(depthTest);\r\n this._engine.setDepthWrite(depthWrite);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphContext.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAI1B,gBAAgB;IAChB,YACuB,OAAuB,EACvB,eAAyC,EACzC,MAAa;QAFb,YAAO,GAAP,OAAO,CAAgB;QACvB,oBAAe,GAAf,eAAe,CAA0B;QACzC,WAAM,GAAN,MAAM,CAAO;IACjC,CAAC;IAEJ;;;;;OAKG;IACI,eAAe,CAAC,SAAiC,EAAE,qBAAqB,GAAG,IAAI;QAClF,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAE9D,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAElC,IAAI,CAAC,MAAM,CAAC,sBAAsB,GAAG,qBAAqB,CAAC;QAE3D,SAAS,CAAC,MAAM,EAAE,CAAC;QAEnB,IAAI,CAAC,MAAM,CAAC,sBAAsB,GAAG,KAAK,CAAC;QAE3C,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,KAAK,mBAAmB,EAAE,CAAC;YAC5D,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBACvB,IAAI,CAAC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esContent":["import type { AbstractEngine, FrameGraphTextureManager, Scene, FrameGraphTextureHandle, Nullable, InternalTexture, IViewportLike } from \"core/index\";\r\n\r\n/**\r\n * Base class for frame graph context.\r\n */\r\nexport class FrameGraphContext {\r\n private _depthTest: boolean;\r\n private _depthWrite: boolean;\r\n\r\n /** @internal */\r\n constructor(\r\n protected readonly _engine: AbstractEngine,\r\n protected readonly _textureManager: FrameGraphTextureManager,\r\n protected readonly _scene: Scene\r\n ) {}\r\n\r\n /**\r\n * Renders a component without managing the render target.\r\n * Use this method when you have a component that handles its own rendering logic which is not fully integrated into the frame graph system.\r\n * @param component The component to render.\r\n * @param intermediateRendering If true, the scene's intermediate rendering flag will be set to true during the render call (default: true)\r\n */\r\n public renderUnmanaged(component: { render: () => void }, intermediateRendering = true): void {\r\n const currentRenderTarget = this._engine._currentRenderTarget;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this._scene._intermediateRendering = intermediateRendering;\r\n\r\n component.render();\r\n\r\n this._scene._intermediateRendering = false;\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 /**\r\n * Gets a texture from a handle.\r\n * Note that if the texture is a history texture, the read texture for the current frame will be returned.\r\n * @param handle The handle of the texture\r\n * @returns The texture or null if not found\r\n */\r\n public getTextureFromHandle(handle: FrameGraphTextureHandle): Nullable<InternalTexture> {\r\n return this._textureManager.getTextureFromHandle(handle);\r\n }\r\n\r\n /**\r\n * Pushes a debug group to the engine's debug stack.\r\n * @param name The name of the debug group\r\n */\r\n public pushDebugGroup(name: string) {\r\n this._engine._debugPushGroup?.(name, 1);\r\n }\r\n\r\n /**\r\n * Pops a debug group from the engine's debug stack.\r\n */\r\n public popDebugGroup() {\r\n this._engine._debugPopGroup?.(1);\r\n }\r\n\r\n /**\r\n * Saves the current depth states (depth testing and depth writing)\r\n */\r\n public saveDepthStates(): void {\r\n this._depthTest = this._engine.getDepthBuffer();\r\n this._depthWrite = this._engine.getDepthWrite();\r\n }\r\n\r\n /**\r\n * Restores the depth states saved by saveDepthStates\r\n */\r\n public restoreDepthStates(): void {\r\n this._engine.setDepthBuffer(this._depthTest);\r\n this._engine.setDepthWrite(this._depthWrite);\r\n }\r\n\r\n /**\r\n * Sets the depth states for the current render target\r\n * @param depthTest If true, depth testing is enabled\r\n * @param depthWrite If true, depth writing is enabled\r\n */\r\n public setDepthStates(depthTest: boolean, depthWrite: boolean): void {\r\n this._engine.setDepthBuffer(depthTest);\r\n this._engine.setDepthWrite(depthWrite);\r\n }\r\n\r\n /**\r\n * Sets the current viewport\r\n * @param viewport defines the viewport element to be used\r\n * @param requiredWidth defines the width required for rendering. If not provided, the width of the render texture is used.\r\n * @param requiredHeight defines the height required for rendering. If not provided the height of the render texture is used.\r\n */\r\n public setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void {\r\n this._engine.setViewport(viewport, requiredHeight, requiredWidth);\r\n }\r\n}\r\n"]}
|
|
@@ -99,15 +99,17 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
99
99
|
* @param disableColorWrite If true, color write will be disabled when applying the effect (optional)
|
|
100
100
|
* @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)
|
|
101
101
|
* @param depthTest If true, depth testing will be enabled when applying the effect (default is false)
|
|
102
|
+
* @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.
|
|
102
103
|
* @returns True if the effect was applied, otherwise false (effect not ready)
|
|
103
104
|
*/
|
|
104
|
-
applyFullScreenEffect(drawWrapper: DrawWrapper, customBindings?: () => void, stencilState?: IStencilState, disableColorWrite?: boolean, drawBackFace?: boolean, depthTest?: boolean): boolean;
|
|
105
|
+
applyFullScreenEffect(drawWrapper: DrawWrapper, customBindings?: () => void, stencilState?: IStencilState, disableColorWrite?: boolean, drawBackFace?: boolean, depthTest?: boolean, noViewport?: boolean): boolean;
|
|
105
106
|
/**
|
|
106
107
|
* Copies a texture to the current render target
|
|
107
108
|
* @param sourceTexture The source texture to copy from
|
|
108
109
|
* @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target
|
|
110
|
+
* @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.
|
|
109
111
|
*/
|
|
110
|
-
copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer?: boolean): void;
|
|
112
|
+
copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer?: boolean, noViewport?: boolean): void;
|
|
111
113
|
/**
|
|
112
114
|
* Renders a RenderTargetTexture or a layer
|
|
113
115
|
* @param object The RenderTargetTexture/Layer to render
|
|
@@ -165,9 +165,10 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
165
165
|
* @param disableColorWrite If true, color write will be disabled when applying the effect (optional)
|
|
166
166
|
* @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)
|
|
167
167
|
* @param depthTest If true, depth testing will be enabled when applying the effect (default is false)
|
|
168
|
+
* @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.
|
|
168
169
|
* @returns True if the effect was applied, otherwise false (effect not ready)
|
|
169
170
|
*/
|
|
170
|
-
applyFullScreenEffect(drawWrapper, customBindings, stencilState, disableColorWrite, drawBackFace, depthTest) {
|
|
171
|
+
applyFullScreenEffect(drawWrapper, customBindings, stencilState, disableColorWrite, drawBackFace, depthTest, noViewport) {
|
|
171
172
|
if (!drawWrapper.effect?.isReady()) {
|
|
172
173
|
return false;
|
|
173
174
|
}
|
|
@@ -175,7 +176,9 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
175
176
|
const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates
|
|
176
177
|
const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;
|
|
177
178
|
effectRenderer.saveStates();
|
|
178
|
-
|
|
179
|
+
if (!noViewport) {
|
|
180
|
+
effectRenderer.setViewport();
|
|
181
|
+
}
|
|
179
182
|
this._engine.enableEffect(drawWrapper);
|
|
180
183
|
this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);
|
|
181
184
|
this._engine.setDepthBuffer(!!depthTest);
|
|
@@ -198,13 +201,16 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
198
201
|
* Copies a texture to the current render target
|
|
199
202
|
* @param sourceTexture The source texture to copy from
|
|
200
203
|
* @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target
|
|
204
|
+
* @param noViewport If true, the current viewport will be left unchanged (optional). If false or undefined, the viewport will be set to the full render target size.
|
|
201
205
|
*/
|
|
202
|
-
copyTexture(sourceTexture, forceCopyToBackbuffer = false) {
|
|
206
|
+
copyTexture(sourceTexture, forceCopyToBackbuffer = false, noViewport) {
|
|
203
207
|
if (forceCopyToBackbuffer) {
|
|
204
208
|
this.bindRenderTarget();
|
|
205
209
|
}
|
|
206
|
-
this.
|
|
207
|
-
this.
|
|
210
|
+
this._copyTexture.source = this._textureManager.getTextureFromHandle(sourceTexture, true);
|
|
211
|
+
this.applyFullScreenEffect(this._copyTexture.effectWrapper.drawWrapper, () => {
|
|
212
|
+
this._copyTexture.effectWrapper.onApplyObservable.notifyObservers({});
|
|
213
|
+
}, undefined, undefined, undefined, undefined, noViewport);
|
|
208
214
|
}
|
|
209
215
|
/**
|
|
210
216
|
* Renders a RenderTargetTexture or a layer
|