@onerjs/core 8.32.7 → 8.32.9
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/Audio/sound.js +0 -1
- package/Audio/sound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.js +12 -4
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +10 -3
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +18 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +105 -15
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +7 -7
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +11 -2
- package/FrameGraph/Passes/pass.js +14 -2
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +4 -2
- package/FrameGraph/Passes/renderPass.js +5 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +27 -31
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +41 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +122 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +6 -4
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +3 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderTarget.js +1 -0
- package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +2 -0
- package/FrameGraph/frameGraphTask.js +11 -0
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +8 -0
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +2 -0
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +2 -0
- package/Layers/highlightLayer.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +9 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +66 -22
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +3 -6
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/materialHelper.functions.js +2 -8
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +2 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +16 -6
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +37 -33
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +10 -0
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +7 -78
- package/Rendering/depthPeelingRenderer.js +12 -398
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthPeelingSceneComponent.d.ts +3 -3
- package/Rendering/depthPeelingSceneComponent.js.map +1 -1
- package/Rendering/depthRenderer.js +9 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/index.d.ts +1 -0
- package/Rendering/index.js +1 -0
- package/Rendering/index.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +20 -0
- package/Rendering/objectRenderer.js +17 -1
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/renderingGroup.d.ts +10 -3
- package/Rendering/renderingGroup.js +24 -13
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/renderingManager.d.ts +6 -2
- package/Rendering/renderingManager.js +8 -2
- package/Rendering/renderingManager.js.map +1 -1
- package/Rendering/thinDepthPeelingRenderer.d.ts +120 -0
- package/Rendering/thinDepthPeelingRenderer.js +469 -0
- package/Rendering/thinDepthPeelingRenderer.js.map +1 -0
- package/Shaders/ShadersInclude/gaussianSplatting.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +2 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.fragment.js +9 -2
- package/Shaders/gaussianSplattingDepth.fragment.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +13 -2
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/Shaders/oitFinalSimpleBlend.fragment.d.ts +5 -0
- package/Shaders/oitFinalSimpleBlend.fragment.js +12 -0
- package/Shaders/oitFinalSimpleBlend.fragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +1 -5
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.fragment.js +12 -3
- package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +13 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +1 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.js +15 -8
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/oitFinalSimpleBlend.fragment.d.ts +5 -0
- package/ShadersWGSL/oitFinalSimpleBlend.fragment.js +13 -0
- package/ShadersWGSL/oitFinalSimpleBlend.fragment.js.map +1 -0
- package/node.d.ts +2 -0
- package/node.js +5 -0
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Nullable } from "../types.js";
|
|
1
|
+
import type { Immutable, Nullable } from "../types.js";
|
|
2
2
|
import type { SmartArray } from "../Misc/smartArray.js";
|
|
3
3
|
import type { ISpriteManager } from "../Sprites/spriteManager.js";
|
|
4
4
|
import type { IParticleSystem } from "../Particles/IParticleSystem.js";
|
|
@@ -101,6 +101,10 @@ export declare class RenderingManager {
|
|
|
101
101
|
* @param scene Defines the scene the groups belongs to
|
|
102
102
|
*/
|
|
103
103
|
constructor(scene: Scene);
|
|
104
|
+
/**
|
|
105
|
+
* @returns the list of rendering groups managed by the manager.
|
|
106
|
+
*/
|
|
107
|
+
get renderingGroups(): Immutable<RenderingGroup[]>;
|
|
104
108
|
/**
|
|
105
109
|
* @returns the rendering group with the specified id.
|
|
106
110
|
* @param id the id of the rendering group (0 by default)
|
|
@@ -111,7 +115,7 @@ export declare class RenderingManager {
|
|
|
111
115
|
* Renders the entire managed groups. This is used by the scene or the different render targets.
|
|
112
116
|
* @internal
|
|
113
117
|
*/
|
|
114
|
-
render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
|
|
118
|
+
render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean, renderDepthOnlyMeshes?: boolean, renderOpaqueMeshes?: boolean, renderAlphaTestMeshes?: boolean, renderTransparentMeshes?: boolean, customRenderTransparentSubMeshes?: (transparentSubMeshes: SmartArray<SubMesh>) => void): void;
|
|
115
119
|
/**
|
|
116
120
|
* Resets the different information of the group to prepare a new frame
|
|
117
121
|
* @internal
|
|
@@ -82,6 +82,12 @@ export class RenderingManager {
|
|
|
82
82
|
this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* @returns the list of rendering groups managed by the manager.
|
|
87
|
+
*/
|
|
88
|
+
get renderingGroups() {
|
|
89
|
+
return this._renderingGroups;
|
|
90
|
+
}
|
|
85
91
|
/**
|
|
86
92
|
* @returns the rendering group with the specified id.
|
|
87
93
|
* @param id the id of the rendering group (0 by default)
|
|
@@ -102,7 +108,7 @@ export class RenderingManager {
|
|
|
102
108
|
* Renders the entire managed groups. This is used by the scene or the different render targets.
|
|
103
109
|
* @internal
|
|
104
110
|
*/
|
|
105
|
-
render(customRenderFunction, activeMeshes, renderParticles, renderSprites) {
|
|
111
|
+
render(customRenderFunction, activeMeshes, renderParticles, renderSprites, renderDepthOnlyMeshes = true, renderOpaqueMeshes = true, renderAlphaTestMeshes = true, renderTransparentMeshes = true, customRenderTransparentSubMeshes) {
|
|
106
112
|
// Update the observable context (not null as it only goes away on dispose)
|
|
107
113
|
const info = this._renderingGroupInfo;
|
|
108
114
|
info.scene = this._scene;
|
|
@@ -137,7 +143,7 @@ export class RenderingManager {
|
|
|
137
143
|
for (const step of this._scene._beforeRenderingGroupDrawStage) {
|
|
138
144
|
step.action(index);
|
|
139
145
|
}
|
|
140
|
-
renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
|
|
146
|
+
renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes, renderDepthOnlyMeshes, renderOpaqueMeshes, renderAlphaTestMeshes, renderTransparentMeshes, customRenderTransparentSubMeshes);
|
|
141
147
|
for (const step of this._scene._afterRenderingGroupDrawStage) {
|
|
142
148
|
step.action(index);
|
|
143
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderingManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/renderingManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2BlD;;GAEG;AACH,MAAM,OAAO,kBAAkB;CAoB9B;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAsBzB;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED,IAAW,mBAAmB,CAAC,KAAc;QACzC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAClC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxC,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC;QACtC,CAAC;IACL,CAAC;IAaD;;;;;OAKG;IACH,IAAW,0BAA0B;QACjC,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC5C,CAAC;IAED,IAAW,0BAA0B,CAAC,KAAc;QAChD,IAAI,KAAK,KAAK,IAAI,CAAC,2BAA2B,EAAE,CAAC;YAC7C,OAAO;QACX,CAAC;QAED,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,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,CAAC;YACpF,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;QAC5F,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACI,iCAAiC,CAAC,gBAAwB,EAAE,qBAA8B,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI;QAC3H,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,GAAG;YAC5C,SAAS,EAAE,qBAAqB;YAChC,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,OAAO;SACnB,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACI,6BAA6B,CAAC,KAAa;QAC9C,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;;AAhWD;;GAEG;AACW,oCAAmB,GAAG,CAAC,AAAJ,CAAK;AAEtC;;GAEG;AACW,oCAAmB,GAAG,CAAC,AAAJ,CAAK;AAEtC;;GAEG;AACW,0BAAS,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { SmartArray } from \"../Misc/smartArray\";\r\nimport type { ISpriteManager } from \"../Sprites/spriteManager\";\r\nimport type { IParticleSystem } from \"../Particles/IParticleSystem\";\r\nimport { RenderingGroup } from \"./renderingGroup\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Interface describing the different options available in the rendering manager\r\n * regarding Auto Clear between groups.\r\n */\r\nexport interface IRenderingManagerAutoClearSetup {\r\n /**\r\n * Defines whether or not autoclear is enable.\r\n */\r\n autoClear: boolean;\r\n /**\r\n * Defines whether or not to autoclear the depth buffer.\r\n */\r\n depth: boolean;\r\n /**\r\n * Defines whether or not to autoclear the stencil buffer.\r\n */\r\n stencil: boolean;\r\n}\r\n\r\n/**\r\n * This class is used by the onRenderingGroupObservable\r\n */\r\nexport class RenderingGroupInfo {\r\n /**\r\n * The Scene that being rendered\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * The camera currently used for the rendering pass\r\n */\r\n camera: Nullable<Camera>;\r\n\r\n /**\r\n * The ID of the renderingGroup being processed\r\n */\r\n renderingGroupId: number;\r\n\r\n /**\r\n * The rendering manager\r\n */\r\n renderingManager: RenderingManager;\r\n}\r\n\r\n/**\r\n * This is the manager responsible of all the rendering for meshes sprites and particles.\r\n * It is enable to manage the different groups as well as the different necessary sort functions.\r\n * This should not be used directly aside of the few static configurations\r\n */\r\nexport class RenderingManager {\r\n /**\r\n * The max id used for rendering groups (not included)\r\n */\r\n public static MAX_RENDERINGGROUPS = 4;\r\n\r\n /**\r\n * The min id used for rendering groups (included)\r\n */\r\n public static MIN_RENDERINGGROUPS = 0;\r\n\r\n /**\r\n * Used to globally prevent autoclearing scenes.\r\n */\r\n public static AUTOCLEAR = true;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _useSceneAutoClearSetup = false;\r\n\r\n private _disableDepthPrePass = false;\r\n /**\r\n * Specifies to disable depth pre-pass if true (default: false)\r\n */\r\n public get disableDepthPrePass() {\r\n return this._disableDepthPrePass;\r\n }\r\n\r\n public set disableDepthPrePass(value: boolean) {\r\n this._disableDepthPrePass = value;\r\n for (const group of this._renderingGroups) {\r\n group.disableDepthPrePass = value;\r\n }\r\n }\r\n\r\n private _scene: Scene;\r\n private _renderingGroups = new Array<RenderingGroup>();\r\n private _depthStencilBufferAlreadyCleaned: boolean;\r\n\r\n private _autoClearDepthStencil: { [id: number]: IRenderingManagerAutoClearSetup } = {};\r\n private _customOpaqueSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customAlphaTestSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customTransparentSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _renderingGroupInfo: Nullable<RenderingGroupInfo> = new RenderingGroupInfo();\r\n\r\n private _maintainStateBetweenFrames = false;\r\n /**\r\n * Gets or sets a boolean indicating that the manager will not reset between frames.\r\n * This means that if a mesh becomes invisible or transparent it will not be visible until this boolean is set to false again.\r\n * By default, the rendering manager will dispatch all active meshes per frame (moving them to the transparent, opaque or alpha testing lists).\r\n * By turning this property on, you will accelerate the rendering by keeping all these lists unchanged between frames.\r\n */\r\n public get maintainStateBetweenFrames() {\r\n return this._maintainStateBetweenFrames;\r\n }\r\n\r\n public set maintainStateBetweenFrames(value: boolean) {\r\n if (value === this._maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n this._maintainStateBetweenFrames = value;\r\n if (!this._maintainStateBetweenFrames) {\r\n this.restoreDispachedFlags();\r\n }\r\n }\r\n\r\n /**\r\n * Restore wasDispatched flags on the lists of elements to render.\r\n */\r\n public restoreDispachedFlags() {\r\n for (const mesh of this._scene.meshes) {\r\n if (mesh.subMeshes) {\r\n for (const subMesh of mesh.subMeshes) {\r\n subMesh._wasDispatched = false;\r\n }\r\n }\r\n }\r\n\r\n if (this._scene.spriteManagers) {\r\n for (const spriteManager of this._scene.spriteManagers) {\r\n spriteManager._wasDispatched = false;\r\n }\r\n }\r\n\r\n for (const particleSystem of this._scene.particleSystems) {\r\n particleSystem._wasDispatched = false;\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates a new rendering group for a particular scene\r\n * @param scene Defines the scene the groups belongs to\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n\r\n for (let i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {\r\n this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };\r\n }\r\n }\r\n\r\n /**\r\n * @returns the rendering group with the specified id.\r\n * @param id the id of the rendering group (0 by default)\r\n */\r\n public getRenderingGroup(id: number): RenderingGroup {\r\n const renderingGroupId = id || 0;\r\n\r\n this._prepareRenderingGroup(renderingGroupId);\r\n\r\n return this._renderingGroups[renderingGroupId];\r\n }\r\n\r\n private _clearDepthStencilBuffer(depth = true, stencil = true): void {\r\n if (this._depthStencilBufferAlreadyCleaned) {\r\n return;\r\n }\r\n\r\n this._scene.getEngine().clear(null, false, depth, stencil);\r\n this._depthStencilBufferAlreadyCleaned = true;\r\n }\r\n\r\n /**\r\n * Renders the entire managed groups. This is used by the scene or the different render targets.\r\n * @internal\r\n */\r\n public render(\r\n customRenderFunction: Nullable<\r\n (\r\n opaqueSubMeshes: SmartArray<SubMesh>,\r\n transparentSubMeshes: SmartArray<SubMesh>,\r\n alphaTestSubMeshes: SmartArray<SubMesh>,\r\n depthOnlySubMeshes: SmartArray<SubMesh>\r\n ) => void\r\n >,\r\n activeMeshes: Nullable<AbstractMesh[]>,\r\n renderParticles: boolean,\r\n renderSprites: boolean\r\n ): void {\r\n // Update the observable context (not null as it only goes away on dispose)\r\n const info = this._renderingGroupInfo!;\r\n info.scene = this._scene;\r\n info.camera = this._scene.activeCamera;\r\n info.renderingManager = this;\r\n\r\n // Dispatch sprites\r\n if (this._scene.spriteManagers && renderSprites) {\r\n for (let index = 0; index < this._scene.spriteManagers.length; index++) {\r\n const manager = this._scene.spriteManagers[index];\r\n this.dispatchSprites(manager);\r\n }\r\n }\r\n\r\n // Render\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;\r\n const renderingGroup = this._renderingGroups[index];\r\n if (!renderingGroup || renderingGroup._empty) {\r\n continue;\r\n }\r\n\r\n const renderingGroupMask = 1 << index;\r\n info.renderingGroupId = index;\r\n\r\n // Before Observable\r\n this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n\r\n // Clear depth/stencil if needed\r\n if (RenderingManager.AUTOCLEAR) {\r\n const autoClear = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(index) : this._autoClearDepthStencil[index];\r\n\r\n if (autoClear && autoClear.autoClear) {\r\n this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);\r\n }\r\n }\r\n\r\n // Render\r\n for (const step of this._scene._beforeRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);\r\n for (const step of this._scene._afterRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n\r\n // After Observable\r\n this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n }\r\n }\r\n\r\n /**\r\n * Resets the different information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public reset(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepare();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Resets the sprites information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public resetSprites(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepareSprites();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Dispose and release the group and its associated resources.\r\n * @internal\r\n */\r\n public dispose(): void {\r\n this.freeRenderingGroups();\r\n this._renderingGroups.length = 0;\r\n this._renderingGroupInfo = null;\r\n }\r\n\r\n /**\r\n * Clear the info related to rendering groups preventing retention points during dispose.\r\n */\r\n public freeRenderingGroups(): void {\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.dispose();\r\n }\r\n }\r\n }\r\n\r\n private _prepareRenderingGroup(renderingGroupId: number): void {\r\n if (this._renderingGroups[renderingGroupId] === undefined) {\r\n this._renderingGroups[renderingGroupId] = new RenderingGroup(\r\n renderingGroupId,\r\n this._scene,\r\n this._customOpaqueSortCompareFn[renderingGroupId],\r\n this._customAlphaTestSortCompareFn[renderingGroupId],\r\n this._customTransparentSortCompareFn[renderingGroupId]\r\n );\r\n this._renderingGroups[renderingGroupId].disableDepthPrePass = this._disableDepthPrePass;\r\n }\r\n }\r\n\r\n /**\r\n * Add a sprite manager to the rendering manager in order to render it this frame.\r\n * @param spriteManager Define the sprite manager to render\r\n */\r\n public dispatchSprites(spriteManager: ISpriteManager) {\r\n if (this.maintainStateBetweenFrames && spriteManager._wasDispatched) {\r\n return;\r\n }\r\n spriteManager._wasDispatched = true;\r\n this.getRenderingGroup(spriteManager.renderingGroupId).dispatchSprites(spriteManager);\r\n }\r\n\r\n /**\r\n * Add a particle system to the rendering manager in order to render it this frame.\r\n * @param particleSystem Define the particle system to render\r\n */\r\n public dispatchParticles(particleSystem: IParticleSystem) {\r\n if (this.maintainStateBetweenFrames && particleSystem._wasDispatched) {\r\n return;\r\n }\r\n particleSystem._wasDispatched = true;\r\n this.getRenderingGroup(particleSystem.renderingGroupId).dispatchParticles(particleSystem);\r\n }\r\n\r\n /**\r\n * Add a submesh to the manager in order to render it this frame\r\n * @param subMesh The submesh to dispatch\r\n * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.\r\n * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.\r\n */\r\n public dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void {\r\n if (mesh === undefined) {\r\n mesh = subMesh.getMesh();\r\n }\r\n if (this.maintainStateBetweenFrames && subMesh._wasDispatched) {\r\n return;\r\n }\r\n subMesh._wasDispatched = true;\r\n this.getRenderingGroup(mesh.renderingGroupId).dispatch(subMesh, mesh, material);\r\n }\r\n\r\n /**\r\n * Overrides the default sort function applied in the rendering group to prepare the meshes.\r\n * This allowed control for front to back rendering or reversely depending of the special needs.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param opaqueSortCompareFn The opaque queue comparison function use to sort.\r\n * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.\r\n * @param transparentSortCompareFn The transparent queue comparison function use to sort.\r\n */\r\n public setRenderingOrder(\r\n renderingGroupId: number,\r\n opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null\r\n ) {\r\n this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;\r\n this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;\r\n this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;\r\n\r\n if (this._renderingGroups[renderingGroupId]) {\r\n const group = this._renderingGroups[renderingGroupId];\r\n group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];\r\n group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];\r\n group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];\r\n }\r\n }\r\n\r\n /**\r\n * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.\r\n * @param depth Automatically clears depth between groups if true and autoClear is true.\r\n * @param stencil Automatically clears stencil between groups if true and autoClear is true.\r\n */\r\n public setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth = true, stencil = true): void {\r\n this._autoClearDepthStencil[renderingGroupId] = {\r\n autoClear: autoClearDepthStencil,\r\n depth: depth,\r\n stencil: stencil,\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current auto clear configuration for one rendering group of the rendering\r\n * manager.\r\n * @param index the rendering group index to get the information for\r\n * @returns The auto clear setup for the requested rendering group\r\n */\r\n public getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup {\r\n return this._autoClearDepthStencil[index];\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"renderingManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/renderingManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2BlD;;GAEG;AACH,MAAM,OAAO,kBAAkB;CAoB9B;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAsBzB;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED,IAAW,mBAAmB,CAAC,KAAc;QACzC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAClC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxC,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC;QACtC,CAAC;IACL,CAAC;IAaD;;;;;OAKG;IACH,IAAW,0BAA0B;QACjC,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC5C,CAAC;IAED,IAAW,0BAA0B,CAAC,KAAc;QAChD,IAAI,KAAK,KAAK,IAAI,CAAC,2BAA2B,EAAE,CAAC;YAC7C,OAAO;QACX,CAAC;QAED,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACpC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACjC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,qBAAqB;QACxB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,IAAI,CAA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G,IAAI,CAAC,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;YACpF,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;QAC5F,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACI,iCAAiC,CAAC,gBAAwB,EAAE,qBAA8B,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI;QAC3H,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,GAAG;YAC5C,SAAS,EAAE,qBAAqB;YAChC,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,OAAO;SACnB,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACI,6BAA6B,CAAC,KAAa;QAC9C,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;;AAtXD;;GAEG;AACW,oCAAmB,GAAG,CAAC,AAAJ,CAAK;AAEtC;;GAEG;AACW,oCAAmB,GAAG,CAAC,AAAJ,CAAK;AAEtC;;GAEG;AACW,0BAAS,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport type { SmartArray } from \"../Misc/smartArray\";\r\nimport type { ISpriteManager } from \"../Sprites/spriteManager\";\r\nimport type { IParticleSystem } from \"../Particles/IParticleSystem\";\r\nimport { RenderingGroup } from \"./renderingGroup\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Interface describing the different options available in the rendering manager\r\n * regarding Auto Clear between groups.\r\n */\r\nexport interface IRenderingManagerAutoClearSetup {\r\n /**\r\n * Defines whether or not autoclear is enable.\r\n */\r\n autoClear: boolean;\r\n /**\r\n * Defines whether or not to autoclear the depth buffer.\r\n */\r\n depth: boolean;\r\n /**\r\n * Defines whether or not to autoclear the stencil buffer.\r\n */\r\n stencil: boolean;\r\n}\r\n\r\n/**\r\n * This class is used by the onRenderingGroupObservable\r\n */\r\nexport class RenderingGroupInfo {\r\n /**\r\n * The Scene that being rendered\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * The camera currently used for the rendering pass\r\n */\r\n camera: Nullable<Camera>;\r\n\r\n /**\r\n * The ID of the renderingGroup being processed\r\n */\r\n renderingGroupId: number;\r\n\r\n /**\r\n * The rendering manager\r\n */\r\n renderingManager: RenderingManager;\r\n}\r\n\r\n/**\r\n * This is the manager responsible of all the rendering for meshes sprites and particles.\r\n * It is enable to manage the different groups as well as the different necessary sort functions.\r\n * This should not be used directly aside of the few static configurations\r\n */\r\nexport class RenderingManager {\r\n /**\r\n * The max id used for rendering groups (not included)\r\n */\r\n public static MAX_RENDERINGGROUPS = 4;\r\n\r\n /**\r\n * The min id used for rendering groups (included)\r\n */\r\n public static MIN_RENDERINGGROUPS = 0;\r\n\r\n /**\r\n * Used to globally prevent autoclearing scenes.\r\n */\r\n public static AUTOCLEAR = true;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _useSceneAutoClearSetup = false;\r\n\r\n private _disableDepthPrePass = false;\r\n /**\r\n * Specifies to disable depth pre-pass if true (default: false)\r\n */\r\n public get disableDepthPrePass() {\r\n return this._disableDepthPrePass;\r\n }\r\n\r\n public set disableDepthPrePass(value: boolean) {\r\n this._disableDepthPrePass = value;\r\n for (const group of this._renderingGroups) {\r\n group.disableDepthPrePass = value;\r\n }\r\n }\r\n\r\n private _scene: Scene;\r\n private _renderingGroups = new Array<RenderingGroup>();\r\n private _depthStencilBufferAlreadyCleaned: boolean;\r\n\r\n private _autoClearDepthStencil: { [id: number]: IRenderingManagerAutoClearSetup } = {};\r\n private _customOpaqueSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customAlphaTestSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _customTransparentSortCompareFn: { [id: number]: Nullable<(a: SubMesh, b: SubMesh) => number> } = {};\r\n private _renderingGroupInfo: Nullable<RenderingGroupInfo> = new RenderingGroupInfo();\r\n\r\n private _maintainStateBetweenFrames = false;\r\n /**\r\n * Gets or sets a boolean indicating that the manager will not reset between frames.\r\n * This means that if a mesh becomes invisible or transparent it will not be visible until this boolean is set to false again.\r\n * By default, the rendering manager will dispatch all active meshes per frame (moving them to the transparent, opaque or alpha testing lists).\r\n * By turning this property on, you will accelerate the rendering by keeping all these lists unchanged between frames.\r\n */\r\n public get maintainStateBetweenFrames() {\r\n return this._maintainStateBetweenFrames;\r\n }\r\n\r\n public set maintainStateBetweenFrames(value: boolean) {\r\n if (value === this._maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n this._maintainStateBetweenFrames = value;\r\n if (!this._maintainStateBetweenFrames) {\r\n this.restoreDispachedFlags();\r\n }\r\n }\r\n\r\n /**\r\n * Restore wasDispatched flags on the lists of elements to render.\r\n */\r\n public restoreDispachedFlags() {\r\n for (const mesh of this._scene.meshes) {\r\n if (mesh.subMeshes) {\r\n for (const subMesh of mesh.subMeshes) {\r\n subMesh._wasDispatched = false;\r\n }\r\n }\r\n }\r\n\r\n if (this._scene.spriteManagers) {\r\n for (const spriteManager of this._scene.spriteManagers) {\r\n spriteManager._wasDispatched = false;\r\n }\r\n }\r\n\r\n for (const particleSystem of this._scene.particleSystems) {\r\n particleSystem._wasDispatched = false;\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates a new rendering group for a particular scene\r\n * @param scene Defines the scene the groups belongs to\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n\r\n for (let i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {\r\n this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };\r\n }\r\n }\r\n\r\n /**\r\n * @returns the list of rendering groups managed by the manager.\r\n */\r\n public get renderingGroups(): Immutable<RenderingGroup[]> {\r\n return this._renderingGroups;\r\n }\r\n\r\n /**\r\n * @returns the rendering group with the specified id.\r\n * @param id the id of the rendering group (0 by default)\r\n */\r\n public getRenderingGroup(id: number): RenderingGroup {\r\n const renderingGroupId = id || 0;\r\n\r\n this._prepareRenderingGroup(renderingGroupId);\r\n\r\n return this._renderingGroups[renderingGroupId];\r\n }\r\n\r\n private _clearDepthStencilBuffer(depth = true, stencil = true): void {\r\n if (this._depthStencilBufferAlreadyCleaned) {\r\n return;\r\n }\r\n\r\n this._scene.getEngine().clear(null, false, depth, stencil);\r\n this._depthStencilBufferAlreadyCleaned = true;\r\n }\r\n\r\n /**\r\n * Renders the entire managed groups. This is used by the scene or the different render targets.\r\n * @internal\r\n */\r\n public render(\r\n customRenderFunction: Nullable<\r\n (\r\n opaqueSubMeshes: SmartArray<SubMesh>,\r\n transparentSubMeshes: SmartArray<SubMesh>,\r\n alphaTestSubMeshes: SmartArray<SubMesh>,\r\n depthOnlySubMeshes: SmartArray<SubMesh>\r\n ) => void\r\n >,\r\n activeMeshes: Nullable<AbstractMesh[]>,\r\n renderParticles: boolean,\r\n renderSprites: boolean,\r\n renderDepthOnlyMeshes: boolean = true,\r\n renderOpaqueMeshes: boolean = true,\r\n renderAlphaTestMeshes: boolean = true,\r\n renderTransparentMeshes: boolean = true,\r\n customRenderTransparentSubMeshes?: (transparentSubMeshes: SmartArray<SubMesh>) => void\r\n ): void {\r\n // Update the observable context (not null as it only goes away on dispose)\r\n const info = this._renderingGroupInfo!;\r\n info.scene = this._scene;\r\n info.camera = this._scene.activeCamera;\r\n info.renderingManager = this;\r\n\r\n // Dispatch sprites\r\n if (this._scene.spriteManagers && renderSprites) {\r\n for (let index = 0; index < this._scene.spriteManagers.length; index++) {\r\n const manager = this._scene.spriteManagers[index];\r\n this.dispatchSprites(manager);\r\n }\r\n }\r\n\r\n // Render\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;\r\n const renderingGroup = this._renderingGroups[index];\r\n if (!renderingGroup || renderingGroup._empty) {\r\n continue;\r\n }\r\n\r\n const renderingGroupMask = 1 << index;\r\n info.renderingGroupId = index;\r\n\r\n // Before Observable\r\n this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n\r\n // Clear depth/stencil if needed\r\n if (RenderingManager.AUTOCLEAR) {\r\n const autoClear = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(index) : this._autoClearDepthStencil[index];\r\n\r\n if (autoClear && autoClear.autoClear) {\r\n this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);\r\n }\r\n }\r\n\r\n // Render\r\n for (const step of this._scene._beforeRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n renderingGroup.render(\r\n customRenderFunction,\r\n renderSprites,\r\n renderParticles,\r\n activeMeshes,\r\n renderDepthOnlyMeshes,\r\n renderOpaqueMeshes,\r\n renderAlphaTestMeshes,\r\n renderTransparentMeshes,\r\n customRenderTransparentSubMeshes\r\n );\r\n for (const step of this._scene._afterRenderingGroupDrawStage) {\r\n step.action(index);\r\n }\r\n\r\n // After Observable\r\n this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);\r\n }\r\n }\r\n\r\n /**\r\n * Resets the different information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public reset(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepare();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Resets the sprites information of the group to prepare a new frame\r\n * @internal\r\n */\r\n public resetSprites(): void {\r\n if (this.maintainStateBetweenFrames) {\r\n return;\r\n }\r\n\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.prepareSprites();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Dispose and release the group and its associated resources.\r\n * @internal\r\n */\r\n public dispose(): void {\r\n this.freeRenderingGroups();\r\n this._renderingGroups.length = 0;\r\n this._renderingGroupInfo = null;\r\n }\r\n\r\n /**\r\n * Clear the info related to rendering groups preventing retention points during dispose.\r\n */\r\n public freeRenderingGroups(): void {\r\n for (let index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {\r\n const renderingGroup = this._renderingGroups[index];\r\n if (renderingGroup) {\r\n renderingGroup.dispose();\r\n }\r\n }\r\n }\r\n\r\n private _prepareRenderingGroup(renderingGroupId: number): void {\r\n if (this._renderingGroups[renderingGroupId] === undefined) {\r\n this._renderingGroups[renderingGroupId] = new RenderingGroup(\r\n renderingGroupId,\r\n this._scene,\r\n this._customOpaqueSortCompareFn[renderingGroupId],\r\n this._customAlphaTestSortCompareFn[renderingGroupId],\r\n this._customTransparentSortCompareFn[renderingGroupId]\r\n );\r\n this._renderingGroups[renderingGroupId].disableDepthPrePass = this._disableDepthPrePass;\r\n }\r\n }\r\n\r\n /**\r\n * Add a sprite manager to the rendering manager in order to render it this frame.\r\n * @param spriteManager Define the sprite manager to render\r\n */\r\n public dispatchSprites(spriteManager: ISpriteManager) {\r\n if (this.maintainStateBetweenFrames && spriteManager._wasDispatched) {\r\n return;\r\n }\r\n spriteManager._wasDispatched = true;\r\n this.getRenderingGroup(spriteManager.renderingGroupId).dispatchSprites(spriteManager);\r\n }\r\n\r\n /**\r\n * Add a particle system to the rendering manager in order to render it this frame.\r\n * @param particleSystem Define the particle system to render\r\n */\r\n public dispatchParticles(particleSystem: IParticleSystem) {\r\n if (this.maintainStateBetweenFrames && particleSystem._wasDispatched) {\r\n return;\r\n }\r\n particleSystem._wasDispatched = true;\r\n this.getRenderingGroup(particleSystem.renderingGroupId).dispatchParticles(particleSystem);\r\n }\r\n\r\n /**\r\n * Add a submesh to the manager in order to render it this frame\r\n * @param subMesh The submesh to dispatch\r\n * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.\r\n * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.\r\n */\r\n public dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void {\r\n if (mesh === undefined) {\r\n mesh = subMesh.getMesh();\r\n }\r\n if (this.maintainStateBetweenFrames && subMesh._wasDispatched) {\r\n return;\r\n }\r\n subMesh._wasDispatched = true;\r\n this.getRenderingGroup(mesh.renderingGroupId).dispatch(subMesh, mesh, material);\r\n }\r\n\r\n /**\r\n * Overrides the default sort function applied in the rendering group to prepare the meshes.\r\n * This allowed control for front to back rendering or reversely depending of the special needs.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param opaqueSortCompareFn The opaque queue comparison function use to sort.\r\n * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.\r\n * @param transparentSortCompareFn The transparent queue comparison function use to sort.\r\n */\r\n public setRenderingOrder(\r\n renderingGroupId: number,\r\n opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null,\r\n transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null\r\n ) {\r\n this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;\r\n this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;\r\n this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;\r\n\r\n if (this._renderingGroups[renderingGroupId]) {\r\n const group = this._renderingGroups[renderingGroupId];\r\n group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];\r\n group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];\r\n group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];\r\n }\r\n }\r\n\r\n /**\r\n * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.\r\n *\r\n * @param renderingGroupId The rendering group id corresponding to its index\r\n * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.\r\n * @param depth Automatically clears depth between groups if true and autoClear is true.\r\n * @param stencil Automatically clears stencil between groups if true and autoClear is true.\r\n */\r\n public setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth = true, stencil = true): void {\r\n this._autoClearDepthStencil[renderingGroupId] = {\r\n autoClear: autoClearDepthStencil,\r\n depth: depth,\r\n stencil: stencil,\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current auto clear configuration for one rendering group of the rendering\r\n * manager.\r\n * @param index the rendering group index to get the information for\r\n * @returns The auto clear setup for the requested rendering group\r\n */\r\n public getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup {\r\n return this._autoClearDepthStencil[index];\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
2
|
+
import type { Effect } from "../Materials/effect.js";
|
|
3
|
+
import { MultiRenderTarget } from "../Materials/Textures/multiRenderTarget.js";
|
|
4
|
+
import { Color4 } from "../Maths/math.color.js";
|
|
5
|
+
import type { SubMesh } from "../Meshes/subMesh.js";
|
|
6
|
+
import type { AbstractMesh } from "../Meshes/abstractMesh.js";
|
|
7
|
+
import { SmartArray } from "../Misc/smartArray.js";
|
|
8
|
+
import type { Scene } from "../scene.js";
|
|
9
|
+
import { ThinTexture } from "../Materials/Textures/thinTexture.js";
|
|
10
|
+
import { EffectRenderer, EffectWrapper } from "../Materials/effectRenderer.js";
|
|
11
|
+
import type { PrePassRenderer } from "./prePassRenderer.js";
|
|
12
|
+
import "../Engines/Extensions/engine.multiRender.js";
|
|
13
|
+
import { ShaderLanguage } from "../Materials/shaderLanguage.js";
|
|
14
|
+
import type { RenderTargetWrapper } from "../Engines/renderTargetWrapper.js";
|
|
15
|
+
import type { Nullable } from "../types.js";
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare class ThinDepthPeelingRenderer {
|
|
20
|
+
protected _scene: Scene;
|
|
21
|
+
protected _engine: AbstractEngine;
|
|
22
|
+
protected _depthMrts: MultiRenderTarget[];
|
|
23
|
+
protected _thinTextures: ThinTexture[];
|
|
24
|
+
protected _colorMrts: MultiRenderTarget[];
|
|
25
|
+
protected _blendBackMrt: MultiRenderTarget;
|
|
26
|
+
protected _blendBackEffectWrapper: EffectWrapper;
|
|
27
|
+
protected _blendBackEffectWrapperPingPong: EffectWrapper;
|
|
28
|
+
protected _finalEffectWrapper: EffectWrapper;
|
|
29
|
+
protected _effectRenderer: EffectRenderer;
|
|
30
|
+
protected _currentPingPongState: number;
|
|
31
|
+
protected _layoutCacheFormat: boolean[][];
|
|
32
|
+
protected _layoutCache: number[][];
|
|
33
|
+
protected _renderPassIds: number[];
|
|
34
|
+
protected _candidateSubMeshes: SmartArray<SubMesh>;
|
|
35
|
+
protected _excludedSubMeshes: SmartArray<SubMesh>;
|
|
36
|
+
protected _excludedMeshes: number[];
|
|
37
|
+
protected static _DEPTH_CLEAR_VALUE: number;
|
|
38
|
+
protected static _MIN_DEPTH: number;
|
|
39
|
+
protected static _MAX_DEPTH: number;
|
|
40
|
+
protected _colorCache: Color4[];
|
|
41
|
+
protected _passCount: number;
|
|
42
|
+
/**
|
|
43
|
+
* Number of depth peeling passes. As we are using dual depth peeling, each pass two levels of transparency are processed.
|
|
44
|
+
*/
|
|
45
|
+
get passCount(): number;
|
|
46
|
+
set passCount(count: number);
|
|
47
|
+
protected _useRenderPasses: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Instructs the renderer to use render passes. It is an optimization that makes the rendering faster for some engines (like WebGPU) but that consumes more memory, so it is disabled by default.
|
|
50
|
+
*/
|
|
51
|
+
get useRenderPasses(): boolean;
|
|
52
|
+
set useRenderPasses(usePasses: boolean);
|
|
53
|
+
/**
|
|
54
|
+
* Add a mesh in the exclusion list to prevent it to be handled by the depth peeling renderer
|
|
55
|
+
* @param mesh The mesh to exclude from the depth peeling renderer
|
|
56
|
+
*/
|
|
57
|
+
addExcludedMesh(mesh: AbstractMesh): void;
|
|
58
|
+
/**
|
|
59
|
+
* Remove a mesh from the exclusion list of the depth peeling renderer
|
|
60
|
+
* @param mesh The mesh to remove
|
|
61
|
+
*/
|
|
62
|
+
removeExcludedMesh(mesh: AbstractMesh): void;
|
|
63
|
+
/** Shader language used by the renderer */
|
|
64
|
+
protected _shaderLanguage: ShaderLanguage;
|
|
65
|
+
/**
|
|
66
|
+
* Gets the shader language used in this renderer
|
|
67
|
+
*/
|
|
68
|
+
get shaderLanguage(): ShaderLanguage;
|
|
69
|
+
private _blendOutput;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the render target wrapper we will blend the transparent objects onto
|
|
72
|
+
*/
|
|
73
|
+
get blendOutput(): Nullable<RenderTargetWrapper>;
|
|
74
|
+
set blendOutput(blendOutput: Nullable<RenderTargetWrapper>);
|
|
75
|
+
/**
|
|
76
|
+
* Instanciates the depth peeling renderer
|
|
77
|
+
* @param scene Scene to attach to
|
|
78
|
+
* @param passCount Number of depth layers to peel
|
|
79
|
+
* @returns The depth peeling renderer
|
|
80
|
+
*/
|
|
81
|
+
constructor(scene: Scene, passCount?: number);
|
|
82
|
+
private _createRenderPassIds;
|
|
83
|
+
private _releaseRenderPassIds;
|
|
84
|
+
protected _getTextureSize(): {
|
|
85
|
+
width: number;
|
|
86
|
+
height: number;
|
|
87
|
+
};
|
|
88
|
+
protected _createTextures(): void;
|
|
89
|
+
protected _disposeTextures(): void;
|
|
90
|
+
protected _createEffects(finalEffectFragmentShaderName: string, finalEffectSamplerNames: string[]): void;
|
|
91
|
+
/**
|
|
92
|
+
* Links to the prepass renderer
|
|
93
|
+
* @param _prePassRenderer The scene PrePassRenderer
|
|
94
|
+
*/
|
|
95
|
+
setPrePassRenderer(_prePassRenderer: PrePassRenderer): void;
|
|
96
|
+
/**
|
|
97
|
+
* Binds depth peeling textures on an effect
|
|
98
|
+
* @param effect The effect to bind textures on
|
|
99
|
+
*/
|
|
100
|
+
bind(effect: Effect): void;
|
|
101
|
+
private _renderSubMeshes;
|
|
102
|
+
protected _finalCompose(writeId: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* Checks if the depth peeling renderer is ready to render transparent meshes
|
|
105
|
+
* @returns true if the depth peeling renderer is ready to render the transparent meshes
|
|
106
|
+
*/
|
|
107
|
+
isReady(): boolean;
|
|
108
|
+
protected _beforeRender(): void;
|
|
109
|
+
protected _afterRender(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Renders transparent submeshes with depth peeling
|
|
112
|
+
* @param transparentSubMeshes List of transparent meshes to render
|
|
113
|
+
* @returns The array of submeshes that could not be handled by this renderer
|
|
114
|
+
*/
|
|
115
|
+
render(transparentSubMeshes: SmartArray<SubMesh>): SmartArray<SubMesh>;
|
|
116
|
+
/**
|
|
117
|
+
* Disposes the depth peeling renderer and associated resources
|
|
118
|
+
*/
|
|
119
|
+
dispose(): void;
|
|
120
|
+
}
|