@babylonjs/core 8.38.0 → 8.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animation.d.ts +2 -1
- package/Animations/animation.js +3 -2
- package/Animations/animation.js.map +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.d.ts +4 -0
- package/Behaviors/Cameras/autoRotationBehavior.js +7 -0
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Behaviors/Cameras/bouncingBehavior.d.ts +5 -0
- package/Behaviors/Cameras/bouncingBehavior.js +8 -0
- package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
- package/Behaviors/Cameras/framingBehavior.d.ts +4 -0
- package/Behaviors/Cameras/framingBehavior.js +7 -0
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +7 -1
- package/Behaviors/Cameras/interpolatingBehavior.js +11 -3
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
- package/Behaviors/Meshes/attachToBoxBehavior.d.ts +5 -0
- package/Behaviors/Meshes/attachToBoxBehavior.js +8 -1
- package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
- package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +5 -2
- package/Behaviors/Meshes/baseSixDofDragBehavior.js +8 -0
- package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/fadeInOutBehavior.d.ts +5 -0
- package/Behaviors/Meshes/fadeInOutBehavior.js +6 -0
- package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.d.ts +5 -0
- package/Behaviors/Meshes/handConstraintBehavior.js +8 -0
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Behaviors/Meshes/multiPointerScaleBehavior.d.ts +5 -0
- package/Behaviors/Meshes/multiPointerScaleBehavior.js +8 -0
- package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/surfaceMagnetismBehavior.d.ts +5 -0
- package/Behaviors/Meshes/surfaceMagnetismBehavior.js +7 -0
- package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
- package/Behaviors/behavior.d.ts +4 -0
- package/Behaviors/behavior.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +11 -3
- package/Cameras/geospatialCamera.js +103 -36
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +6 -2
- package/Cameras/geospatialCameraMovement.js +11 -11
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -2
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
- package/Engines/WebGPU/webgpuTextureHelper.js +11 -0
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -0
- package/Engines/WebGPU/webgpuTextureManager.js +100 -9
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +6 -1
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +1 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +7 -4
- package/Engines/webgpuEngine.js +45 -16
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +22 -5
- package/FrameGraph/Node/nodeRenderGraph.js +39 -18
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +2 -0
- package/FrameGraph/Passes/pass.js +2 -0
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +2 -0
- package/FrameGraph/Passes/renderPass.js +4 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +13 -4
- package/FrameGraph/frameGraph.js +45 -5
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderTarget.d.ts +1 -0
- package/FrameGraph/frameGraphRenderTarget.js +3 -0
- package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +6 -0
- package/FrameGraph/frameGraphTask.js +15 -0
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +2 -0
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/Helpers/sceneHelpers.js +1 -1
- package/Helpers/sceneHelpers.js.map +1 -1
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Lights/lightingVolume.d.ts +89 -0
- package/Lights/lightingVolume.js +426 -0
- package/Lights/lightingVolume.js.map +1 -0
- package/Materials/Node/nodeMaterial.js +8 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +6 -5
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/screenshotTools.js +2 -8
- package/Misc/screenshotTools.js.map +1 -1
- package/Particles/solidParticle.d.ts +9 -0
- package/Particles/solidParticle.js +11 -0
- package/Particles/solidParticle.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +28 -0
- package/Particles/solidParticleSystem.js +75 -0
- package/Particles/solidParticleSystem.js.map +1 -1
- package/ShadersWGSL/lightingVolume.compute.d.ts +5 -0
- package/ShadersWGSL/lightingVolume.compute.js +27 -0
- package/ShadersWGSL/lightingVolume.compute.js.map +1 -0
- package/package.json +1 -1
- package/scene.js +6 -4
- package/scene.js.map +1 -1
|
@@ -165,7 +165,12 @@ export class RenderTargetWrapper {
|
|
|
165
165
|
*/
|
|
166
166
|
generateMipMaps() {
|
|
167
167
|
if (this._engine._currentRenderTarget === this) {
|
|
168
|
-
this.
|
|
168
|
+
if (this.isMulti) {
|
|
169
|
+
this._engine.unBindMultiColorAttachmentFramebuffer(this, true);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this._engine.unBindFramebuffer(this, true);
|
|
173
|
+
}
|
|
169
174
|
}
|
|
170
175
|
if (this.isMulti) {
|
|
171
176
|
this._engine.generateMipMapsMultiFramebuffer(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,yDAAwD;AAYnF;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA6B5B;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,OAAkC,EAAE,eAAe,GAAG,IAAI;QACpF,IAAI,eAAe,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/C,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC;QAEpC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,+BAA+B,GAAG,KAAK,CAAC;QAEvG,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,+BAA+B,GAAG,gBAAgB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AAE,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;QAC1C,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3B,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { AbstractEngine } from \"./abstractEngine\";\r\nimport type { IMultiRenderTargetOptions } from \"../Materials/Textures/multiRenderTarget\";\r\nimport { HasStencilAspect } from \"core/Materials/Textures/textureHelper.functions\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: AbstractEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n private _faceIndices: Nullable<number[]> = null;\r\n private _layerIndices: Nullable<number[]> = null;\r\n private _depthStencilTextureLabel?: string;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets or sets the label of the render target wrapper (optional, for debugging purpose)\r\n */\r\n public label?: string;\r\n\r\n /**\r\n * Gets the depth/stencil texture\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Sets the depth/stencil texture\r\n * @param texture The depth/stencil texture to set\r\n * @param disposeExisting True to dispose the existing depth/stencil texture (if any) before replacing it (default: true)\r\n */\r\n public setDepthStencilTexture(texture: Nullable<InternalTexture>, disposeExisting = true) {\r\n if (disposeExisting && this._depthStencilTexture) {\r\n this._depthStencilTexture.dispose();\r\n }\r\n\r\n this._depthStencilTexture = texture;\r\n\r\n this._generateDepthBuffer = this._generateStencilBuffer = this._depthStencilTextureWithStencil = false;\r\n\r\n if (texture) {\r\n this._generateDepthBuffer = true;\r\n this._generateStencilBuffer = this._depthStencilTextureWithStencil = HasStencilAspect(texture.format);\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a 3D texture\r\n */\r\n public get is3D(): boolean {\r\n return this.depth > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the depth of the render target wrapper (only used if is3D is true and wrapper is not a multi render target)\r\n */\r\n public get depth(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).depth || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get faceIndices(): Nullable<number[]> {\r\n return this._faceIndices;\r\n }\r\n\r\n /**\r\n * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get layerIndices(): Nullable<number[]> {\r\n return this._layerIndices;\r\n }\r\n\r\n /**\r\n * Sets this property to true to disable the automatic MSAA resolve that happens when the render target wrapper is unbound (default is false)\r\n */\r\n public disableAutomaticMSAAResolve = false;\r\n\r\n /**\r\n * Indicates if MSAA color texture(s) should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is true)\r\n * Note that you can trigger a MSAA resolve at any time by calling resolveMSAATextures()\r\n */\r\n public resolveMSAAColors = true;\r\n\r\n /**\r\n * Indicates if MSAA depth texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAADepth = false;\r\n\r\n /**\r\n * Indicates if MSAA stencil texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAAStencil = false;\r\n\r\n /**\r\n * Indicates if the depth texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * Indicates if the stencil texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * Gets the base array layer of a texture in the textures array\r\n * This is an number that is calculated based on the layer and face indices set for this texture at that index\r\n * @param index The index of the texture in the textures array to get the base array layer for\r\n * @returns the base array layer of the texture at the given index\r\n */\r\n public getBaseArrayLayer(index: number): number {\r\n if (!this._textures) {\r\n return -1;\r\n }\r\n\r\n const texture = this._textures[index];\r\n const layerIndex = this._layerIndices?.[index] ?? 0;\r\n const faceIndex = this._faceIndices?.[index] ?? 0;\r\n\r\n return texture.isCube ? layerIndex * 6 + faceIndex : texture.is3D ? 0 : layerIndex;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Resolves the MSAA textures into their non-MSAA version.\r\n * Note that if samples equals 1 (no MSAA), no resolve is performed.\r\n */\r\n public resolveMSAATextures(): void {\r\n if (this.isMulti) {\r\n this._engine.resolveMultiFramebuffer(this);\r\n } else {\r\n this._engine.resolveFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Generates mipmaps for each texture of the render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._engine._currentRenderTarget === this) {\r\n this._engine.unBindFramebuffer(this, true);\r\n }\r\n if (this.isMulti) {\r\n this._engine.generateMipMapsMultiFramebuffer(this);\r\n } else {\r\n this._engine.generateMipMapsFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n * @param label defines the label to use for the wrapper (for debugging purpose only)\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: AbstractEngine, label?: string) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture The texture to set\r\n * @param index The index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] === texture) {\r\n return;\r\n }\r\n\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture bound to each color attachment\r\n * @param layers The layers of each texture to be set\r\n * @param faces The faces of each texture to be set\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n this._layerIndices = layers;\r\n this._faceIndices = faces;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n if (!this._layerIndices) {\r\n this._layerIndices = [];\r\n }\r\n if (!this._faceIndices) {\r\n this._faceIndices = [];\r\n }\r\n\r\n if (layer !== undefined && layer >= 0) {\r\n this._layerIndices[index] = layer;\r\n }\r\n if (face !== undefined && face >= 0) {\r\n this._faceIndices[index] = face;\r\n }\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil Not used anymore. \"format\" will be used to determine if stencil should be created\r\n * @param samples sample count to use when creating the texture (default: 1)\r\n * @param format format of the depth texture (default: Constants.TEXTUREFORMAT_DEPTH32_FLOAT)\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTextureLabel = label;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n label,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * @deprecated Use shareDepth instead\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n this.shareDepth(renderTarget);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n renderTarget._depthStencilTextureWithStencil = this._depthStencilTextureWithStencil;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n let depthTextureFormat = -1;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n depthTextureFormat = textureArray[textureArray.length - 1].format;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const targetTypes: number[] = [];\r\n const faceIndex: number[] = [];\r\n const layerIndex: number[] = [];\r\n const layerCounts: number[] = [];\r\n const internalTexture2Index: { [id: number]: number } = {};\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n formats.push(texture.format);\r\n\r\n const index = internalTexture2Index[texture.uniqueId];\r\n if (index !== undefined) {\r\n targetTypes.push(-1);\r\n layerCounts.push(0);\r\n } else {\r\n internalTexture2Index[texture.uniqueId] = i;\r\n if (texture.is2DArray) {\r\n targetTypes.push(Constants.TEXTURE_2D_ARRAY);\r\n layerCounts.push(texture.depth);\r\n } else if (texture.isCube) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP);\r\n layerCounts.push(0);\r\n } /*else if (texture.isCubeArray) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP_ARRAY);\r\n layerCounts.push(texture.depth);\r\n }*/ else if (texture.is3D) {\r\n targetTypes.push(Constants.TEXTURE_3D);\r\n layerCounts.push(texture.depth);\r\n } else {\r\n targetTypes.push(Constants.TEXTURE_2D);\r\n layerCounts.push(0);\r\n }\r\n }\r\n\r\n if (this._faceIndices) {\r\n faceIndex.push(this._faceIndices[i] ?? 0);\r\n }\r\n if (this._layerIndices) {\r\n layerIndex.push(this._layerIndices[i] ?? 0);\r\n }\r\n }\r\n\r\n const optionsMRT: IMultiRenderTargetOptions = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n depthTextureFormat,\r\n types,\r\n formats,\r\n textureCount,\r\n targetTypes,\r\n faceIndex,\r\n layerIndex,\r\n layerCounts,\r\n label: this.label,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n depth: this.depth,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n if (targetTypes[i] !== -1) {\r\n continue;\r\n }\r\n const index = internalTexture2Index[textureArray[i].uniqueId];\r\n rtw.setTexture(rtw.textures![index], i);\r\n }\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n options.noColorAttachment = !this._textures;\r\n options.label = this.label;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray || this.is3D ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n if (rtw.texture) {\r\n rtw.texture.isReady = true;\r\n }\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const format = this._depthStencilTexture.format;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n\r\n rtw.createDepthStencilTexture(\r\n this._depthStencilTexture._comparisonFunction,\r\n bilinear,\r\n this._depthStencilTextureWithStencil,\r\n this._depthStencilTexture.samples,\r\n format,\r\n this._depthStencilTextureLabel\r\n );\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,yDAAwD;AAYnF;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA6B5B;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,OAAkC,EAAE,eAAe,GAAG,IAAI;QACpF,IAAI,eAAe,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/C,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,OAAO,C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C,CAAC;QACN,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YACnB,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACnC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,eAAe;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;QAC1C,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3B,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { AbstractEngine } from \"./abstractEngine\";\r\nimport type { IMultiRenderTargetOptions } from \"../Materials/Textures/multiRenderTarget\";\r\nimport { HasStencilAspect } from \"core/Materials/Textures/textureHelper.functions\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: AbstractEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n private _faceIndices: Nullable<number[]> = null;\r\n private _layerIndices: Nullable<number[]> = null;\r\n private _depthStencilTextureLabel?: string;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets or sets the label of the render target wrapper (optional, for debugging purpose)\r\n */\r\n public label?: string;\r\n\r\n /**\r\n * Gets the depth/stencil texture\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Sets the depth/stencil texture\r\n * @param texture The depth/stencil texture to set\r\n * @param disposeExisting True to dispose the existing depth/stencil texture (if any) before replacing it (default: true)\r\n */\r\n public setDepthStencilTexture(texture: Nullable<InternalTexture>, disposeExisting = true) {\r\n if (disposeExisting && this._depthStencilTexture) {\r\n this._depthStencilTexture.dispose();\r\n }\r\n\r\n this._depthStencilTexture = texture;\r\n\r\n this._generateDepthBuffer = this._generateStencilBuffer = this._depthStencilTextureWithStencil = false;\r\n\r\n if (texture) {\r\n this._generateDepthBuffer = true;\r\n this._generateStencilBuffer = this._depthStencilTextureWithStencil = HasStencilAspect(texture.format);\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a 3D texture\r\n */\r\n public get is3D(): boolean {\r\n return this.depth > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the depth of the render target wrapper (only used if is3D is true and wrapper is not a multi render target)\r\n */\r\n public get depth(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).depth || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get faceIndices(): Nullable<number[]> {\r\n return this._faceIndices;\r\n }\r\n\r\n /**\r\n * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get layerIndices(): Nullable<number[]> {\r\n return this._layerIndices;\r\n }\r\n\r\n /**\r\n * Sets this property to true to disable the automatic MSAA resolve that happens when the render target wrapper is unbound (default is false)\r\n */\r\n public disableAutomaticMSAAResolve = false;\r\n\r\n /**\r\n * Indicates if MSAA color texture(s) should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is true)\r\n * Note that you can trigger a MSAA resolve at any time by calling resolveMSAATextures()\r\n */\r\n public resolveMSAAColors = true;\r\n\r\n /**\r\n * Indicates if MSAA depth texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAADepth = false;\r\n\r\n /**\r\n * Indicates if MSAA stencil texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAAStencil = false;\r\n\r\n /**\r\n * Indicates if the depth texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * Indicates if the stencil texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * Gets the base array layer of a texture in the textures array\r\n * This is an number that is calculated based on the layer and face indices set for this texture at that index\r\n * @param index The index of the texture in the textures array to get the base array layer for\r\n * @returns the base array layer of the texture at the given index\r\n */\r\n public getBaseArrayLayer(index: number): number {\r\n if (!this._textures) {\r\n return -1;\r\n }\r\n\r\n const texture = this._textures[index];\r\n const layerIndex = this._layerIndices?.[index] ?? 0;\r\n const faceIndex = this._faceIndices?.[index] ?? 0;\r\n\r\n return texture.isCube ? layerIndex * 6 + faceIndex : texture.is3D ? 0 : layerIndex;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Resolves the MSAA textures into their non-MSAA version.\r\n * Note that if samples equals 1 (no MSAA), no resolve is performed.\r\n */\r\n public resolveMSAATextures(): void {\r\n if (this.isMulti) {\r\n this._engine.resolveMultiFramebuffer(this);\r\n } else {\r\n this._engine.resolveFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Generates mipmaps for each texture of the render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._engine._currentRenderTarget === this) {\r\n if (this.isMulti) {\r\n this._engine.unBindMultiColorAttachmentFramebuffer(this, true);\r\n } else {\r\n this._engine.unBindFramebuffer(this, true);\r\n }\r\n }\r\n if (this.isMulti) {\r\n this._engine.generateMipMapsMultiFramebuffer(this);\r\n } else {\r\n this._engine.generateMipMapsFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n * @param label defines the label to use for the wrapper (for debugging purpose only)\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: AbstractEngine, label?: string) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture The texture to set\r\n * @param index The index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] === texture) {\r\n return;\r\n }\r\n\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture bound to each color attachment\r\n * @param layers The layers of each texture to be set\r\n * @param faces The faces of each texture to be set\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n this._layerIndices = layers;\r\n this._faceIndices = faces;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n if (!this._layerIndices) {\r\n this._layerIndices = [];\r\n }\r\n if (!this._faceIndices) {\r\n this._faceIndices = [];\r\n }\r\n\r\n if (layer !== undefined && layer >= 0) {\r\n this._layerIndices[index] = layer;\r\n }\r\n if (face !== undefined && face >= 0) {\r\n this._faceIndices[index] = face;\r\n }\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil Not used anymore. \"format\" will be used to determine if stencil should be created\r\n * @param samples sample count to use when creating the texture (default: 1)\r\n * @param format format of the depth texture (default: Constants.TEXTUREFORMAT_DEPTH32_FLOAT)\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTextureLabel = label;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n label,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * @deprecated Use shareDepth instead\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n this.shareDepth(renderTarget);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n renderTarget._depthStencilTextureWithStencil = this._depthStencilTextureWithStencil;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n let depthTextureFormat = -1;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n depthTextureFormat = textureArray[textureArray.length - 1].format;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const targetTypes: number[] = [];\r\n const faceIndex: number[] = [];\r\n const layerIndex: number[] = [];\r\n const layerCounts: number[] = [];\r\n const internalTexture2Index: { [id: number]: number } = {};\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n formats.push(texture.format);\r\n\r\n const index = internalTexture2Index[texture.uniqueId];\r\n if (index !== undefined) {\r\n targetTypes.push(-1);\r\n layerCounts.push(0);\r\n } else {\r\n internalTexture2Index[texture.uniqueId] = i;\r\n if (texture.is2DArray) {\r\n targetTypes.push(Constants.TEXTURE_2D_ARRAY);\r\n layerCounts.push(texture.depth);\r\n } else if (texture.isCube) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP);\r\n layerCounts.push(0);\r\n } /*else if (texture.isCubeArray) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP_ARRAY);\r\n layerCounts.push(texture.depth);\r\n }*/ else if (texture.is3D) {\r\n targetTypes.push(Constants.TEXTURE_3D);\r\n layerCounts.push(texture.depth);\r\n } else {\r\n targetTypes.push(Constants.TEXTURE_2D);\r\n layerCounts.push(0);\r\n }\r\n }\r\n\r\n if (this._faceIndices) {\r\n faceIndex.push(this._faceIndices[i] ?? 0);\r\n }\r\n if (this._layerIndices) {\r\n layerIndex.push(this._layerIndices[i] ?? 0);\r\n }\r\n }\r\n\r\n const optionsMRT: IMultiRenderTargetOptions = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n depthTextureFormat,\r\n types,\r\n formats,\r\n textureCount,\r\n targetTypes,\r\n faceIndex,\r\n layerIndex,\r\n layerCounts,\r\n label: this.label,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n depth: this.depth,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n if (targetTypes[i] !== -1) {\r\n continue;\r\n }\r\n const index = internalTexture2Index[textureArray[i].uniqueId];\r\n rtw.setTexture(rtw.textures![index], i);\r\n }\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n options.noColorAttachment = !this._textures;\r\n options.label = this.label;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray || this.is3D ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n if (rtw.texture) {\r\n rtw.texture.isReady = true;\r\n }\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const format = this._depthStencilTexture.format;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n\r\n rtw.createDepthStencilTexture(\r\n this._depthStencilTexture._comparisonFunction,\r\n bilinear,\r\n this._depthStencilTextureWithStencil,\r\n this._depthStencilTexture.samples,\r\n format,\r\n this._depthStencilTextureLabel\r\n );\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
|
package/Engines/thinEngine.js
CHANGED
|
@@ -2749,7 +2749,7 @@ export class ThinEngine extends AbstractEngine {
|
|
|
2749
2749
|
if (texture.generateMipMaps) {
|
|
2750
2750
|
const webGLHardwareTexture = texture._hardwareTexture;
|
|
2751
2751
|
if (!webGLHardwareTexture.memoryAllocated) {
|
|
2752
|
-
gl.texStorage2D(gl.TEXTURE_2D, Math.floor(Math.log2(Math.max(width, height))) + 1, internalFormat, texture.width, texture.height);
|
|
2752
|
+
gl.texStorage2D(texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D, Math.floor(Math.log2(Math.max(width, height))) + 1, internalFormat, texture.width, texture.height);
|
|
2753
2753
|
webGLHardwareTexture.memoryAllocated = true;
|
|
2754
2754
|
}
|
|
2755
2755
|
this._gl.compressedTexSubImage2D(target, lod, 0, 0, width, height, internalFormat, data);
|