@babylonjs/core 5.6.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animation.js +2 -1
- package/Animations/animation.js.map +1 -1
- package/Animations/easing.d.ts +14 -14
- package/Animations/easing.js +13 -13
- package/Animations/easing.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +2 -2
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.js +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.dynamicBuffer.js +7 -5
- package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +10 -1
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.d.ts +4 -2
- package/Engines/Extensions/engine.rawTexture.js +7 -4
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +2 -0
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +3 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicBuffer.js +3 -21
- package/Engines/WebGPU/Extensions/engine.dynamicBuffer.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +7 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +7 -3
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuConstants.d.ts +8 -2
- package/Engines/WebGPU/webgpuConstants.js +15 -8
- package/Engines/WebGPU/webgpuConstants.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +4 -0
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/constants.d.ts +2 -0
- package/Engines/constants.js +2 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +59 -51
- package/Engines/engine.js +2 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/engineFactory.d.ts +2 -2
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/nativeEngine.d.ts +4 -4
- package/Engines/nativeEngine.js +12 -7
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +4 -2
- package/Engines/nullEngine.js +9 -2
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -0
- package/Engines/thinEngine.js +43 -5
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +3 -8
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +5 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +1 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/index.d.ts +0 -1
- package/Materials/Node/Blocks/Dual/index.js +0 -1
- package/Materials/Node/Blocks/Dual/index.js.map +1 -1
- package/Materials/Node/Blocks/{Dual → Fragment}/TBNBlock.d.ts +0 -0
- package/Materials/Node/Blocks/{Dual → Fragment}/TBNBlock.js +4 -4
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -0
- package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
- package/Materials/Node/Blocks/Fragment/index.js +1 -0
- package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +7 -0
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +4 -2
- package/Materials/Node/nodeMaterial.js +13 -5
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +2 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/internalTexture.js +1 -1
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +4 -0
- package/Materials/Textures/multiRenderTarget.js +16 -3
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +10 -4
- package/Materials/Textures/rawTexture.js +20 -9
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/shaderMaterial.js +2 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +7 -2
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.js +5 -5
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/groundBuilder.d.ts +1 -1
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/linesBuilder.js +4 -0
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +15 -5
- package/Meshes/abstractMesh.js +46 -27
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/instancedMesh.js +1 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +1 -1
- package/Meshes/mesh.js +60 -32
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.js +1 -1
- package/Meshes/subMesh.js.map +1 -1
- package/Morph/morphTargetManager.js +2 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/particleHelper.js +3 -2
- package/Particles/particleHelper.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.d.ts +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js +2 -4
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Shaders/ShadersInclude/vertexColorMixing.js +1 -1
- package/Shaders/ShadersInclude/vertexColorMixing.js.map +1 -1
- package/Shaders/default.fragment.js +1 -1
- package/Shaders/default.fragment.js.map +1 -1
- package/Sprites/spriteManager.js +2 -1
- package/Sprites/spriteManager.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +1 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -1
- package/scene.js.map +1 -1
- package/Materials/Node/Blocks/Dual/TBNBlock.js.map +0 -1
|
@@ -333,7 +333,7 @@ var InternalTexture = /** @class */ (function (_super) {
|
|
|
333
333
|
}, null, this._buffer, undefined, this.format, this._extension, undefined, undefined, undefined, this._useSRGBBuffer);
|
|
334
334
|
return;
|
|
335
335
|
case InternalTextureSource.Raw:
|
|
336
|
-
proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type);
|
|
336
|
+
proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type, undefined, this._useSRGBBuffer);
|
|
337
337
|
proxy._swapAndDie(this, false);
|
|
338
338
|
this.isReady = true;
|
|
339
339
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalTexture.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Textures/internalTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD;;GAEG;AACH,MAAM,CAAN,IAAY,qBA6DX;AA7DD,WAAY,qBAAqB;IAC7B;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,iFAAY,CAAA;IACZ;;OAEG;IACH,2FAAiB,CAAA;IACjB;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,uFAAe,CAAA;IACf;;OAEG;IACH,oEAAK,CAAA;IACL;;OAEG;IACH,8EAAU,CAAA;IACV;;OAEG;IACH,kFAAY,CAAA;IACZ;;OAEG;IACH,gFAAW,CAAA;IACX;;OAEG;IACH,oEAAK,CAAA;AACT,CAAC,EA7DW,qBAAqB,KAArB,qBAAqB,QA6DhC;AAED;;;GAGG;AACH;IAAqC,mCAAc;IAuM/C;;;;;OAKG;IACH,yBAAY,MAAkB,EAAE,MAA6B,EAAE,eAAuB;QAAvB,gCAAA,EAAA,uBAAuB;QAAtF,YACI,iBAAO,SASV;QAtND;;WAEG;QACI,aAAO,GAAY,KAAK,CAAC;QAChC;;WAEG;QACI,YAAM,GAAY,KAA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AAE,CAAC;QACnB,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;IACL,CAAC;IApTD,cAAc;IACA,wBAAQ,GAAG,CAAC,CAAC;IAoT/B,sBAAC;CAAA,AAreD,CAAqC,cAAc,GAqelD;SAreY,eAAe","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable, int } from \"../../types\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\nimport type { HardwareTextureWrapper } from \"./hardwareTextureWrapper\";\r\nimport { TextureSampler } from \"./textureSampler\";\r\n\r\ndeclare type ThinEngine = import(\"../../Engines/thinEngine\").ThinEngine;\r\ndeclare type BaseTexture = import(\"../../Materials/Textures/baseTexture\").BaseTexture;\r\ndeclare type SphericalPolynomial = import(\"../../Maths/sphericalPolynomial\").SphericalPolynomial;\r\n\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport enum InternalTextureSource {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n Unknown,\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n Url,\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n Temp,\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n Raw,\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n Dynamic,\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n RenderTarget,\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n MultiRenderTarget,\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n Cube,\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n CubeRaw,\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n CubePrefiltered,\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n Raw3D,\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n Raw2DArray,\r\n /**\r\n * Texture content is a depth/stencil texture\r\n */\r\n DepthStencil,\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n CubeRawRGBD,\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n Depth,\r\n}\r\n\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nexport class InternalTexture extends TextureSampler {\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n public isReady: boolean = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n public isCube: boolean = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n public is3D: boolean = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n public is2DArray: boolean = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n public isMultiview: boolean = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n public url: string = \"\";\r\n /** @hidden */\r\n public _originalUrl: string; // not empty only if different from url\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n public generateMipMaps: boolean = false;\r\n /**\r\n * Gets a boolean indicating if the texture uses mipmaps\r\n * TODO implements useMipMaps as a separate setting from generateMipMaps\r\n */\r\n public get useMipMaps() {\r\n return this.generateMipMaps;\r\n }\r\n public set useMipMaps(value: boolean) {\r\n this.generateMipMaps = value;\r\n }\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n public samples: number = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n public type: number = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n public format: number = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n public onLoadedObservable = new Observable<InternalTexture>();\r\n /**\r\n * Observable called when the texture load is raising an error\r\n */\r\n public onErrorObservable = new Observable<Partial<{ message: string; exception: any }>>();\r\n /**\r\n * If this callback is defined it will be called instead of the default _rebuild function\r\n */\r\n public onRebuildCallback: Nullable<\r\n (internalTexture: InternalTexture) => {\r\n proxy: Nullable<InternalTexture | Promise<InternalTexture>>;\r\n isReady: boolean;\r\n isAsync: boolean;\r\n }\r\n > = null;\r\n /**\r\n * Gets the width of the texture\r\n */\r\n public width: number = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n public height: number = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n public depth: number = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseWidth: number = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseHeight: number = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseDepth: number = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n public invertY: boolean = false;\r\n\r\n // Private\r\n /** @hidden */\r\n public _invertVScale = false;\r\n /** @hidden */\r\n public _associatedChannel = -1;\r\n /** @hidden */\r\n public _source = InternalTextureSource.Unknown;\r\n /** @hidden */\r\n public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap> = null;\r\n /** @hidden */\r\n public _bufferView: Nullable<ArrayBufferView> = null;\r\n /** @hidden */\r\n public _bufferViewArray: Nullable<ArrayBufferView[]> = null;\r\n /** @hidden */\r\n public _bufferViewArrayArray: Nullable<ArrayBufferView[][]> = null;\r\n /** @hidden */\r\n public _size: number = 0;\r\n /** @hidden */\r\n public _extension: string = \"\";\r\n /** @hidden */\r\n public _files: Nullable<string[]> = null;\r\n /** @hidden */\r\n public _workingCanvas: Nullable<ICanvas> = null;\r\n /** @hidden */\r\n public _workingContext: Nullable<ICanvasRenderingContext> = null;\r\n /** @hidden */\r\n public _cachedCoordinatesMode: Nullable<number> = null;\r\n /** @hidden */\r\n public _isDisabled: boolean = false;\r\n /** @hidden */\r\n public _compression: Nullable<string> = null;\r\n /** @hidden */\r\n public _sphericalPolynomial: Nullable<SphericalPolynomial> = null;\r\n /** @hidden */\r\n public _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>> = null;\r\n /** @hidden */\r\n public _sphericalPolynomialComputed = false;\r\n /** @hidden */\r\n public _lodGenerationScale: number = 0;\r\n /** @hidden */\r\n public _lodGenerationOffset: number = 0;\r\n /** @hidden */\r\n public _useSRGBBuffer: boolean = false;\r\n\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @hidden */\r\n public _lodTextureHigh: Nullable<BaseTexture> = null;\r\n /** @hidden */\r\n public _lodTextureMid: Nullable<BaseTexture> = null;\r\n /** @hidden */\r\n public _lodTextureLow: Nullable<BaseTexture> = null;\r\n /** @hidden */\r\n public _isRGBD: boolean = false;\r\n\r\n /** @hidden */\r\n public _linearSpecularLOD: boolean = false;\r\n /** @hidden */\r\n public _irradianceTexture: Nullable<BaseTexture> = null;\r\n\r\n /** @hidden */\r\n public _hardwareTexture: Nullable<HardwareTextureWrapper> = null;\r\n\r\n /** @hidden */\r\n public _maxLodLevel: Nullable<number> = null;\r\n\r\n /** @hidden */\r\n public _references: number = 1;\r\n\r\n /** @hidden */\r\n public _gammaSpace: Nullable<boolean> = null;\r\n\r\n private _engine: ThinEngine;\r\n private _uniqueId: number;\r\n\r\n /** @hidden */\r\n public static _Counter = 0;\r\n\r\n /** Gets the unique id of the internal texture */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n public getEngine(): ThinEngine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n public get source(): InternalTextureSource {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation = false) {\r\n super();\r\n\r\n this._engine = engine;\r\n this._source = source;\r\n this._uniqueId = InternalTexture._Counter++;\r\n\r\n if (!delayAllocation) {\r\n this._hardwareTexture = engine._createHardwareTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n public incrementReferences(): void {\r\n this._references++;\r\n }\r\n\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n public updateSize(width: int, height: int, depth: int = 1): void {\r\n this._engine.updateTextureDimensions(this, width, height, depth);\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n\r\n this._size = width * height * depth;\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedWrapR = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n if (this.onRebuildCallback) {\r\n const data = this.onRebuildCallback(this);\r\n const swapAndSetIsReady = (proxyInternalTexture: InternalTexture) => {\r\n proxyInternalTexture._swapAndDie(this, false);\r\n this.isReady = data.isReady;\r\n };\r\n if (data.isAsync) {\r\n (data.proxy as Promise<InternalTexture>).then(swapAndSetIsReady);\r\n } else {\r\n swapAndSetIsReady(data.proxy as InternalTexture);\r\n }\r\n return;\r\n }\r\n\r\n let proxy: InternalTexture;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n break;\r\n\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(\r\n this._originalUrl ?? this.url,\r\n !this.generateMipMaps,\r\n this.invertY,\r\n null,\r\n this.samplingMode,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this._buffer,\r\n undefined,\r\n this.format,\r\n this._extension,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this, false);\r\n this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas()!, this.invertY, undefined, undefined, true);\r\n\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n break;\r\n\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(\r\n this.url,\r\n null,\r\n this._files,\r\n !this.generateMipMaps,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension,\r\n false,\r\n 0,\r\n 0,\r\n null,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(\r\n this._bufferViewArray!,\r\n this.width,\r\n this.format,\r\n this.type,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression\r\n );\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.CubeRawRGBD:\r\n // This case is being handeled by the environment texture tools and is not a part of the rebuild process.\r\n // To use CubeRawRGBD use updateRGBDAsync on the cube texture.\r\n return;\r\n\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(\r\n this.url,\r\n null,\r\n this._lodGenerationScale,\r\n this._lodGenerationOffset,\r\n (proxy) => {\r\n if (proxy) {\r\n proxy._swapAndDie(this, false);\r\n }\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension\r\n );\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * @param target\r\n * @param swapAll\r\n * @hidden\r\n */\r\n public _swapAndDie(target: InternalTexture, swapAll = true): void {\r\n // TODO what about refcount on target?\r\n\r\n this._hardwareTexture?.setUsage(target._source, this.generateMipMaps, this.isCube, this.width, this.height);\r\n\r\n target._hardwareTexture = this._hardwareTexture;\r\n if (swapAll) {\r\n target._isRGBD = this._isRGBD;\r\n }\r\n\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n\r\n const cache = this._engine.getLoadedTexturesCache();\r\n let index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n\r\n index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n public dispose(): void {\r\n this._references--;\r\n this.onLoadedObservable.clear();\r\n this.onErrorObservable.clear();\r\n if (this._references === 0) {\r\n this._engine._releaseTexture(this);\r\n this._hardwareTexture = null;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"internalTexture.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Textures/internalTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD;;GAEG;AACH,MAAM,CAAN,IAAY,qBA6DX;AA7DD,WAAY,qBAAqB;IAC7B;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,iFAAY,CAAA;IACZ;;OAEG;IACH,2FAAiB,CAAA;IACjB;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,uFAAe,CAAA;IACf;;OAEG;IACH,oEA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,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACpD,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC1B;QAED,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACtB;IACL,CAAC;IAED;;OAEG;IACI,iCAAO,GAAd;QACI,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;IACL,CAAC;IAtTD,cAAc;IACA,wBAAQ,GAAG,CAAC,CAAC;IAsT/B,sBAAC;CAAA,AAveD,CAAqC,cAAc,GAuelD;SAveY,eAAe","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable, int } from \"../../types\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\nimport type { HardwareTextureWrapper } from \"./hardwareTextureWrapper\";\r\nimport { TextureSampler } from \"./textureSampler\";\r\n\r\ndeclare type ThinEngine = import(\"../../Engines/thinEngine\").ThinEngine;\r\ndeclare type BaseTexture = import(\"../../Materials/Textures/baseTexture\").BaseTexture;\r\ndeclare type SphericalPolynomial = import(\"../../Maths/sphericalPolynomial\").SphericalPolynomial;\r\n\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport enum InternalTextureSource {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n Unknown,\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n Url,\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n Temp,\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n Raw,\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n Dynamic,\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n RenderTarget,\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n MultiRenderTarget,\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n Cube,\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n CubeRaw,\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n CubePrefiltered,\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n Raw3D,\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n Raw2DArray,\r\n /**\r\n * Texture content is a depth/stencil texture\r\n */\r\n DepthStencil,\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n CubeRawRGBD,\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n Depth,\r\n}\r\n\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nexport class InternalTexture extends TextureSampler {\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n public isReady: boolean = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n public isCube: boolean = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n public is3D: boolean = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n public is2DArray: boolean = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n public isMultiview: boolean = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n public url: string = \"\";\r\n /** @hidden */\r\n public _originalUrl: string; // not empty only if different from url\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n public generateMipMaps: boolean = false;\r\n /**\r\n * Gets a boolean indicating if the texture uses mipmaps\r\n * TODO implements useMipMaps as a separate setting from generateMipMaps\r\n */\r\n public get useMipMaps() {\r\n return this.generateMipMaps;\r\n }\r\n public set useMipMaps(value: boolean) {\r\n this.generateMipMaps = value;\r\n }\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n public samples: number = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n public type: number = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n public format: number = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n public onLoadedObservable = new Observable<InternalTexture>();\r\n /**\r\n * Observable called when the texture load is raising an error\r\n */\r\n public onErrorObservable = new Observable<Partial<{ message: string; exception: any }>>();\r\n /**\r\n * If this callback is defined it will be called instead of the default _rebuild function\r\n */\r\n public onRebuildCallback: Nullable<\r\n (internalTexture: InternalTexture) => {\r\n proxy: Nullable<InternalTexture | Promise<InternalTexture>>;\r\n isReady: boolean;\r\n isAsync: boolean;\r\n }\r\n > = null;\r\n /**\r\n * Gets the width of the texture\r\n */\r\n public width: number = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n public height: number = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n public depth: number = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseWidth: number = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseHeight: number = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseDepth: number = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n public invertY: boolean = false;\r\n\r\n // Private\r\n /** @hidden */\r\n public _invertVScale = false;\r\n /** @hidden */\r\n public _associatedChannel = -1;\r\n /** @hidden */\r\n public _source = InternalTextureSource.Unknown;\r\n /** @hidden */\r\n public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap> = null;\r\n /** @hidden */\r\n public _bufferView: Nullable<ArrayBufferView> = null;\r\n /** @hidden */\r\n public _bufferViewArray: Nullable<ArrayBufferView[]> = null;\r\n /** @hidden */\r\n public _bufferViewArrayArray: Nullable<ArrayBufferView[][]> = null;\r\n /** @hidden */\r\n public _size: number = 0;\r\n /** @hidden */\r\n public _extension: string = \"\";\r\n /** @hidden */\r\n public _files: Nullable<string[]> = null;\r\n /** @hidden */\r\n public _workingCanvas: Nullable<ICanvas> = null;\r\n /** @hidden */\r\n public _workingContext: Nullable<ICanvasRenderingContext> = null;\r\n /** @hidden */\r\n public _cachedCoordinatesMode: Nullable<number> = null;\r\n /** @hidden */\r\n public _isDisabled: boolean = false;\r\n /** @hidden */\r\n public _compression: Nullable<string> = null;\r\n /** @hidden */\r\n public _sphericalPolynomial: Nullable<SphericalPolynomial> = null;\r\n /** @hidden */\r\n public _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>> = null;\r\n /** @hidden */\r\n public _sphericalPolynomialComputed = false;\r\n /** @hidden */\r\n public _lodGenerationScale: number = 0;\r\n /** @hidden */\r\n public _lodGenerationOffset: number = 0;\r\n /** @hidden */\r\n public _useSRGBBuffer: boolean = false;\r\n\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @hidden */\r\n public _lodTextureHigh: Nullable<BaseTexture> = null;\r\n /** @hidden */\r\n public _lodTextureMid: Nullable<BaseTexture> = null;\r\n /** @hidden */\r\n public _lodTextureLow: Nullable<BaseTexture> = null;\r\n /** @hidden */\r\n public _isRGBD: boolean = false;\r\n\r\n /** @hidden */\r\n public _linearSpecularLOD: boolean = false;\r\n /** @hidden */\r\n public _irradianceTexture: Nullable<BaseTexture> = null;\r\n\r\n /** @hidden */\r\n public _hardwareTexture: Nullable<HardwareTextureWrapper> = null;\r\n\r\n /** @hidden */\r\n public _maxLodLevel: Nullable<number> = null;\r\n\r\n /** @hidden */\r\n public _references: number = 1;\r\n\r\n /** @hidden */\r\n public _gammaSpace: Nullable<boolean> = null;\r\n\r\n private _engine: ThinEngine;\r\n private _uniqueId: number;\r\n\r\n /** @hidden */\r\n public static _Counter = 0;\r\n\r\n /** Gets the unique id of the internal texture */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n public getEngine(): ThinEngine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n public get source(): InternalTextureSource {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation = false) {\r\n super();\r\n\r\n this._engine = engine;\r\n this._source = source;\r\n this._uniqueId = InternalTexture._Counter++;\r\n\r\n if (!delayAllocation) {\r\n this._hardwareTexture = engine._createHardwareTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n public incrementReferences(): void {\r\n this._references++;\r\n }\r\n\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n public updateSize(width: int, height: int, depth: int = 1): void {\r\n this._engine.updateTextureDimensions(this, width, height, depth);\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n\r\n this._size = width * height * depth;\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedWrapR = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n if (this.onRebuildCallback) {\r\n const data = this.onRebuildCallback(this);\r\n const swapAndSetIsReady = (proxyInternalTexture: InternalTexture) => {\r\n proxyInternalTexture._swapAndDie(this, false);\r\n this.isReady = data.isReady;\r\n };\r\n if (data.isAsync) {\r\n (data.proxy as Promise<InternalTexture>).then(swapAndSetIsReady);\r\n } else {\r\n swapAndSetIsReady(data.proxy as InternalTexture);\r\n }\r\n return;\r\n }\r\n\r\n let proxy: InternalTexture;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n break;\r\n\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(\r\n this._originalUrl ?? this.url,\r\n !this.generateMipMaps,\r\n this.invertY,\r\n null,\r\n this.samplingMode,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this._buffer,\r\n undefined,\r\n this.format,\r\n this._extension,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this, false);\r\n this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas()!, this.invertY, undefined, undefined, true);\r\n\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n break;\r\n\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(\r\n this.url,\r\n null,\r\n this._files,\r\n !this.generateMipMaps,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension,\r\n false,\r\n 0,\r\n 0,\r\n null,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(\r\n this._bufferViewArray!,\r\n this.width,\r\n this.format,\r\n this.type,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression\r\n );\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.CubeRawRGBD:\r\n // This case is being handeled by the environment texture tools and is not a part of the rebuild process.\r\n // To use CubeRawRGBD use updateRGBDAsync on the cube texture.\r\n return;\r\n\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(\r\n this.url,\r\n null,\r\n this._lodGenerationScale,\r\n this._lodGenerationOffset,\r\n (proxy) => {\r\n if (proxy) {\r\n proxy._swapAndDie(this, false);\r\n }\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension\r\n );\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * @param target\r\n * @param swapAll\r\n * @hidden\r\n */\r\n public _swapAndDie(target: InternalTexture, swapAll = true): void {\r\n // TODO what about refcount on target?\r\n\r\n this._hardwareTexture?.setUsage(target._source, this.generateMipMaps, this.isCube, this.width, this.height);\r\n\r\n target._hardwareTexture = this._hardwareTexture;\r\n if (swapAll) {\r\n target._isRGBD = this._isRGBD;\r\n }\r\n\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n\r\n const cache = this._engine.getLoadedTexturesCache();\r\n let index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n\r\n index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n public dispose(): void {\r\n this._references--;\r\n this.onLoadedObservable.clear();\r\n this.onErrorObservable.clear();\r\n if (this._references === 0) {\r\n this._engine._releaseTexture(this);\r\n this._hardwareTexture = null;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -20,6 +20,10 @@ export interface IMultiRenderTargetOptions {
|
|
|
20
20
|
* Define the sampling modes of all the draw buffers we want to create
|
|
21
21
|
*/
|
|
22
22
|
samplingModes?: number[];
|
|
23
|
+
/**
|
|
24
|
+
* Define if sRGB format should be used for each of the draw buffers we want to create
|
|
25
|
+
*/
|
|
26
|
+
useSRGBBuffers?: boolean[];
|
|
23
27
|
/**
|
|
24
28
|
* Define if a depth buffer is required
|
|
25
29
|
*/
|
|
@@ -38,7 +38,8 @@ var MultiRenderTarget = /** @class */ (function (_super) {
|
|
|
38
38
|
}
|
|
39
39
|
var types = [];
|
|
40
40
|
var samplingModes = [];
|
|
41
|
-
|
|
41
|
+
var useSRGBBuffers = [];
|
|
42
|
+
_this._initTypes(count, types, samplingModes, useSRGBBuffers, options);
|
|
42
43
|
var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
|
|
43
44
|
var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
|
|
44
45
|
_this._size = size;
|
|
@@ -51,6 +52,7 @@ var MultiRenderTarget = /** @class */ (function (_super) {
|
|
|
51
52
|
depthTextureFormat: depthTextureFormat,
|
|
52
53
|
types: types,
|
|
53
54
|
textureCount: count,
|
|
55
|
+
useSRGBBuffers: useSRGBBuffers,
|
|
54
56
|
};
|
|
55
57
|
_this._count = count;
|
|
56
58
|
_this._drawOnlyOnFirstAttachmentByDefault = drawOnlyOnFirstAttachmentByDefault;
|
|
@@ -131,7 +133,7 @@ var MultiRenderTarget = /** @class */ (function (_super) {
|
|
|
131
133
|
enumerable: false,
|
|
132
134
|
configurable: true
|
|
133
135
|
});
|
|
134
|
-
MultiRenderTarget.prototype._initTypes = function (count, types, samplingModes, options) {
|
|
136
|
+
MultiRenderTarget.prototype._initTypes = function (count, types, samplingModes, useSRGBBuffers, options) {
|
|
135
137
|
for (var i = 0; i < count; i++) {
|
|
136
138
|
if (options && options.types && options.types[i] !== undefined) {
|
|
137
139
|
types.push(options.types[i]);
|
|
@@ -145,6 +147,12 @@ var MultiRenderTarget = /** @class */ (function (_super) {
|
|
|
145
147
|
else {
|
|
146
148
|
samplingModes.push(Texture.BILINEAR_SAMPLINGMODE);
|
|
147
149
|
}
|
|
150
|
+
if (options && options.useSRGBBuffers && options.useSRGBBuffers[i] !== undefined) {
|
|
151
|
+
useSRGBBuffers.push(options.useSRGBBuffers[i]);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
useSRGBBuffers.push(false);
|
|
155
|
+
}
|
|
148
156
|
}
|
|
149
157
|
};
|
|
150
158
|
/**
|
|
@@ -222,6 +230,9 @@ var MultiRenderTarget = /** @class */ (function (_super) {
|
|
|
222
230
|
if (this._multiRenderTargetOptions.samplingModes) {
|
|
223
231
|
this._multiRenderTargetOptions.samplingModes[index] = texture.samplingMode;
|
|
224
232
|
}
|
|
233
|
+
if (this._multiRenderTargetOptions.useSRGBBuffers) {
|
|
234
|
+
this._multiRenderTargetOptions.useSRGBBuffers[index] = texture._useSRGBBuffer;
|
|
235
|
+
}
|
|
225
236
|
};
|
|
226
237
|
Object.defineProperty(MultiRenderTarget.prototype, "samples", {
|
|
227
238
|
/**
|
|
@@ -263,9 +274,11 @@ var MultiRenderTarget = /** @class */ (function (_super) {
|
|
|
263
274
|
this._count = count;
|
|
264
275
|
var types = [];
|
|
265
276
|
var samplingModes = [];
|
|
266
|
-
|
|
277
|
+
var useSRGBBuffers = [];
|
|
278
|
+
this._initTypes(count, types, samplingModes, useSRGBBuffers, options);
|
|
267
279
|
this._multiRenderTargetOptions.types = types;
|
|
268
280
|
this._multiRenderTargetOptions.samplingModes = samplingModes;
|
|
281
|
+
this._multiRenderTargetOptions.useSRGBBuffers = useSRGBBuffers;
|
|
269
282
|
this._rebuild(true, textureNames);
|
|
270
283
|
};
|
|
271
284
|
MultiRenderTarget.prototype._unbindFrameBuffer = function (engine, faceIndex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiRenderTarget.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Textures/multiRenderTarget.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAA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,EAAE;YAC/B,IAAI,CAAC,uBAAuB,EAAE,CAAC;SAClC;aAAM;YACH,oDAAoD;YACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;QACD,iBAAM,OAAO,WAAE,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,mDAAuB,GAA9B;;QACI,IAAM,gBAAgB,GAAG,MAAA,IAAI,CAAC,aAAa,0CAAE,QAAQ,CAAC;QAEtD,IAAI,CAAC,gBAAgB,EAAE;YACnB,OAAO;SACV;QAED,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YACnD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;SACrC;QAED,MAAA,IAAI,CAAC,aAAa,0CAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACL,wBAAC;AAAD,CAAC,AA9SD,CAAuC,mBAAmB,GA8SzD","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\n\r\nimport \"../../Engines/Extensions/engine.multiRender\";\r\nimport type { InternalTexture } from \"./internalTexture\";\r\n\r\n/**\r\n * Creation options of the multi render target texture.\r\n */\r\nexport interface IMultiRenderTargetOptions {\r\n /**\r\n * Define if the texture needs to create mip maps after render.\r\n */\r\n generateMipMaps?: boolean;\r\n /**\r\n * Define the types of all the draw buffers we want to create\r\n */\r\n types?: number[];\r\n /**\r\n * Define the sampling modes of all the draw buffers we want to create\r\n */\r\n samplingModes?: number[];\r\n /**\r\n * Define if a depth buffer is required\r\n */\r\n generateDepthBuffer?: boolean;\r\n /**\r\n * Define if a stencil buffer is required\r\n */\r\n generateStencilBuffer?: boolean;\r\n /**\r\n * Define if a depth texture is required instead of a depth buffer\r\n */\r\n generateDepthTexture?: boolean;\r\n /**\r\n * Define depth texture format to use\r\n */\r\n depthTextureFormat?: number;\r\n /**\r\n * Define the number of desired draw buffers\r\n */\r\n textureCount?: number;\r\n /**\r\n * Define if aspect ratio should be adapted to the texture or stay the scene one\r\n */\r\n doNotChangeAspectRatio?: boolean;\r\n /**\r\n * Define the default type of the buffers we are creating\r\n */\r\n defaultType?: number;\r\n /**\r\n * Define the default type of the buffers we are creating\r\n */\r\n drawOnlyOnFirstAttachmentByDefault?: boolean;\r\n}\r\n\r\n/**\r\n * A multi render target, like a render target provides the ability to render to a texture.\r\n * Unlike the render target, it can render to several draw buffers in one draw.\r\n * This is specially interesting in deferred rendering or for any effects requiring more than\r\n * just one color from a single pass.\r\n */\r\nexport class MultiRenderTarget extends RenderTargetTexture {\r\n private _textures: Texture[];\r\n private _multiRenderTargetOptions: IMultiRenderTargetOptions;\r\n private _count: number;\r\n private _drawOnlyOnFirstAttachmentByDefault: boolean;\r\n\r\n /**\r\n * Get if draw buffers are currently supported by the used hardware and browser.\r\n */\r\n public get isSupported(): boolean {\r\n return this._engine?.getCaps().drawBuffersExtension ?? false;\r\n }\r\n\r\n /**\r\n * Get the list of textures generated by the multi render target.\r\n */\r\n public get textures(): Texture[] {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.\r\n */\r\n public get count(): number {\r\n return this._count;\r\n }\r\n\r\n /**\r\n * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set\r\n */\r\n public get depthTexture(): Texture {\r\n return this._textures[this._textures.length - 1];\r\n }\r\n\r\n /**\r\n * Set the wrapping mode on U of all the textures we are rendering to.\r\n * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)\r\n */\r\n public set wrapU(wrap: number) {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; i++) {\r\n this._textures[i].wrapU = wrap;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Set the wrapping mode on V of all the textures we are rendering to.\r\n * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)\r\n */\r\n public set wrapV(wrap: number) {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; i++) {\r\n this._textures[i].wrapV = wrap;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Instantiate a new multi render target texture.\r\n * A multi render target, like a render target provides the ability to render to a texture.\r\n * Unlike the render target, it can render to several draw buffers in one draw.\r\n * This is specially interesting in deferred rendering or for any effects requiring more than\r\n * just one color from a single pass.\r\n * @param name Define the name of the texture\r\n * @param size Define the size of the buffers to render to\r\n * @param count Define the number of target we are rendering into\r\n * @param scene Define the scene the texture belongs to\r\n * @param options Define the options used to create the multi render target\r\n * @param textureNames Define the names to set to the textures (if count > 0 - optional)\r\n */\r\n constructor(name: string, size: any, count: number, scene?: Scene, options?: IMultiRenderTargetOptions, textureNames?: string[]) {\r\n const generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;\r\n const generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;\r\n const depthTextureFormat = options && options.depthTextureFormat ? options.depthTextureFormat : Constants.TEXTUREFORMAT_DEPTH16;\r\n const doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;\r\n const drawOnlyOnFirstAttachmentByDefault = options && options.drawOnlyOnFirstAttachmentByDefault ? options.drawOnlyOnFirstAttachmentByDefault : false;\r\n super(name, size, scene, generateMipMaps, doNotChangeAspectRatio, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);\r\n\r\n if (!this.isSupported) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n const types: number[] = [];\r\n const samplingModes: number[] = [];\r\n this._initTypes(count, types, samplingModes, options);\r\n\r\n const generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n const generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n\r\n this._size = size;\r\n this._multiRenderTargetOptions = {\r\n samplingModes: samplingModes,\r\n generateMipMaps: generateMipMaps,\r\n generateDepthBuffer: generateDepthBuffer,\r\n generateStencilBuffer: generateStencilBuffer,\r\n generateDepthTexture: generateDepthTexture,\r\n depthTextureFormat: depthTextureFormat,\r\n types: types,\r\n textureCount: count,\r\n };\r\n\r\n this._count = count;\r\n this._drawOnlyOnFirstAttachmentByDefault = drawOnlyOnFirstAttachmentByDefault;\r\n\r\n if (count > 0) {\r\n this._createInternalTextures();\r\n this._createTextures(textureNames);\r\n }\r\n }\r\n\r\n private _initTypes(count: number, types: number[], samplingModes: number[], options?: IMultiRenderTargetOptions) {\r\n for (let i = 0; i < count; i++) {\r\n if (options && options.types && options.types[i] !== undefined) {\r\n types.push(options.types[i]);\r\n } else {\r\n types.push(options && options.defaultType ? options.defaultType : Constants.TEXTURETYPE_UNSIGNED_INT);\r\n }\r\n\r\n if (options && options.samplingModes && options.samplingModes[i] !== undefined) {\r\n samplingModes.push(options.samplingModes[i]);\r\n } else {\r\n samplingModes.push(Texture.BILINEAR_SAMPLINGMODE);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @param forceFullRebuild\r\n * @param textureNames\r\n * @hidden\r\n */\r\n public _rebuild(forceFullRebuild: boolean = false, textureNames?: string[]): void {\r\n if (this._count < 1) {\r\n return;\r\n }\r\n\r\n this.releaseInternalTextures();\r\n this._createInternalTextures();\r\n\r\n if (forceFullRebuild) {\r\n this._releaseTextures();\r\n this._createTextures(textureNames);\r\n }\r\n\r\n const internalTextures = this._renderTarget!.textures!;\r\n for (let i = 0; i < internalTextures.length; i++) {\r\n const texture = this._textures[i];\r\n texture._texture = internalTextures[i];\r\n }\r\n\r\n if (this.samples !== 1) {\r\n this._renderTarget!.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, true);\r\n }\r\n }\r\n\r\n private _createInternalTextures(): void {\r\n this._renderTarget = this._getEngine()!.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault);\r\n this._texture = this._renderTarget.texture;\r\n }\r\n\r\n private _releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; i++) {\r\n this._textures[i]._texture = null; // internal textures are released by a call to releaseInternalTextures()\r\n this._textures[i].dispose();\r\n }\r\n }\r\n }\r\n\r\n private _createTextures(textureNames?: string[]): void {\r\n const internalTextures = this._renderTarget!.textures!;\r\n this._textures = [];\r\n for (let i = 0; i < internalTextures.length; i++) {\r\n const texture = new Texture(null, this.getScene());\r\n if (textureNames?.[i]) {\r\n texture.name = textureNames[i];\r\n }\r\n texture._texture = internalTextures[i];\r\n this._textures.push(texture);\r\n }\r\n }\r\n\r\n /**\r\n * Replaces an internal texture within the MRT. Useful to share textures between MultiRenderTarget.\r\n * @param texture The new texture to set in the MRT\r\n * @param index The index of the texture to replace\r\n * @param disposePrevious Set to true if the previous internal texture should be disposed\r\n */\r\n public setInternalTexture(texture: InternalTexture, index: number, disposePrevious: boolean = true) {\r\n if (!this.renderTarget) {\r\n return;\r\n }\r\n\r\n if (index === 0) {\r\n this._texture = texture;\r\n }\r\n\r\n this.renderTarget.setTexture(texture, index, disposePrevious);\r\n\r\n if (!this.textures[index]) {\r\n this.textures[index] = new Texture(null, this.getScene());\r\n }\r\n this.textures[index]._texture = texture;\r\n\r\n this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0;\r\n\r\n if (this._multiRenderTargetOptions.types) {\r\n this._multiRenderTargetOptions.types[index] = texture.type;\r\n }\r\n if (this._multiRenderTargetOptions.samplingModes) {\r\n this._multiRenderTargetOptions.samplingModes[index] = texture.samplingMode;\r\n }\r\n }\r\n\r\n /**\r\n * Define the number of samples used if MSAA is enabled.\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n public set samples(value: number) {\r\n if (this._renderTarget) {\r\n this._samples = this._renderTarget.setSamples(value);\r\n } else {\r\n // In case samples are set with 0 textures created, we must save the desired samples value\r\n this._samples = value;\r\n }\r\n }\r\n\r\n /**\r\n * Resize all the textures in the multi render target.\r\n * Be careful as it will recreate all the data in the new texture.\r\n * @param size Define the new size\r\n */\r\n public resize(size: any) {\r\n this._size = size;\r\n this._rebuild();\r\n }\r\n\r\n /**\r\n * Changes the number of render targets in this MRT\r\n * Be careful as it will recreate all the data in the new texture.\r\n * @param count new texture count\r\n * @param options Specifies texture types and sampling modes for new textures\r\n * @param textureNames Specifies the names of the textures (optional)\r\n */\r\n public updateCount(count: number, options?: IMultiRenderTargetOptions, textureNames?: string[]) {\r\n this._multiRenderTargetOptions.textureCount = count;\r\n this._count = count;\r\n\r\n const types: number[] = [];\r\n const samplingModes: number[] = [];\r\n\r\n this._initTypes(count, types, samplingModes, options);\r\n this._multiRenderTargetOptions.types = types;\r\n this._multiRenderTargetOptions.samplingModes = samplingModes;\r\n this._rebuild(true, textureNames);\r\n }\r\n\r\n protected _unbindFrameBuffer(engine: Engine, faceIndex: number): void {\r\n if (this._renderTarget) {\r\n engine.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, () => {\r\n this.onAfterRenderObservable.notifyObservers(faceIndex);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the render targets and their associated resources\r\n * @param doNotDisposeInternalTextures\r\n */\r\n public dispose(doNotDisposeInternalTextures = false): void {\r\n this._releaseTextures();\r\n if (!doNotDisposeInternalTextures) {\r\n this.releaseInternalTextures();\r\n } else {\r\n // Prevent internal texture dispose in super.dispose\r\n this._texture = null;\r\n }\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Release all the underlying texture used as draw buffers.\r\n */\r\n public releaseInternalTextures(): void {\r\n const internalTextures = this._renderTarget?.textures;\r\n\r\n if (!internalTextures) {\r\n return;\r\n }\r\n\r\n for (let i = internalTextures.length - 1; i >= 0; i--) {\r\n this._textures[i]._texture = null;\r\n }\r\n\r\n this._renderTarget?.dispose();\r\n this._renderTarget = null;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"multiRenderTarget.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Textures/multiRenderTarget.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,6CAA6C,CAAC;AAyDrD;;;;;GAKG;AACH;IAAuC,qCAAmB;IA0DtD;;;;;;;;;;;;OAYG;IACH,2BAAY,IAAY,EAAE,IAAS,EAAE,KAAa,EAAE,KAAa,EAAE,OAAmC,EAAE,YAAuB;QAA/H,iBAyCC;QAxCG,IAAM,eAAe,GAAG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7F,IAAM,oBAAoB,GAAG,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5G,IAAM,kBAAkB,GAAG,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC;QAChI,IAAM,sBAAsB,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,sBAAsB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC;QAChI,IAAM,kCAAkC,GAAG,OAAO,IAAI,OAAO,CAAC,kCAAkC,CAAC,CAAC,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC,CAAC,KAAK,CAAC;gBACtJ,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CAAC,EAAE,CAAC,EAAE,EAAE;YACnD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;SACrC;QAED,MAAA,IAAI,CAAC,aAAa,0CAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACL,wBAAC;AAAD,CAAC,AA3TD,CAAuC,mBAAmB,GA2TzD","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\n\r\nimport \"../../Engines/Extensions/engine.multiRender\";\r\nimport type { InternalTexture } from \"./internalTexture\";\r\n\r\n/**\r\n * Creation options of the multi render target texture.\r\n */\r\nexport interface IMultiRenderTargetOptions {\r\n /**\r\n * Define if the texture needs to create mip maps after render.\r\n */\r\n generateMipMaps?: boolean;\r\n /**\r\n * Define the types of all the draw buffers we want to create\r\n */\r\n types?: number[];\r\n /**\r\n * Define the sampling modes of all the draw buffers we want to create\r\n */\r\n samplingModes?: number[];\r\n /**\r\n * Define if sRGB format should be used for each of the draw buffers we want to create\r\n */\r\n useSRGBBuffers?: boolean[];\r\n /**\r\n * Define if a depth buffer is required\r\n */\r\n generateDepthBuffer?: boolean;\r\n /**\r\n * Define if a stencil buffer is required\r\n */\r\n generateStencilBuffer?: boolean;\r\n /**\r\n * Define if a depth texture is required instead of a depth buffer\r\n */\r\n generateDepthTexture?: boolean;\r\n /**\r\n * Define depth texture format to use\r\n */\r\n depthTextureFormat?: number;\r\n /**\r\n * Define the number of desired draw buffers\r\n */\r\n textureCount?: number;\r\n /**\r\n * Define if aspect ratio should be adapted to the texture or stay the scene one\r\n */\r\n doNotChangeAspectRatio?: boolean;\r\n /**\r\n * Define the default type of the buffers we are creating\r\n */\r\n defaultType?: number;\r\n /**\r\n * Define the default type of the buffers we are creating\r\n */\r\n drawOnlyOnFirstAttachmentByDefault?: boolean;\r\n}\r\n\r\n/**\r\n * A multi render target, like a render target provides the ability to render to a texture.\r\n * Unlike the render target, it can render to several draw buffers in one draw.\r\n * This is specially interesting in deferred rendering or for any effects requiring more than\r\n * just one color from a single pass.\r\n */\r\nexport class MultiRenderTarget extends RenderTargetTexture {\r\n private _textures: Texture[];\r\n private _multiRenderTargetOptions: IMultiRenderTargetOptions;\r\n private _count: number;\r\n private _drawOnlyOnFirstAttachmentByDefault: boolean;\r\n\r\n /**\r\n * Get if draw buffers are currently supported by the used hardware and browser.\r\n */\r\n public get isSupported(): boolean {\r\n return this._engine?.getCaps().drawBuffersExtension ?? false;\r\n }\r\n\r\n /**\r\n * Get the list of textures generated by the multi render target.\r\n */\r\n public get textures(): Texture[] {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.\r\n */\r\n public get count(): number {\r\n return this._count;\r\n }\r\n\r\n /**\r\n * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set\r\n */\r\n public get depthTexture(): Texture {\r\n return this._textures[this._textures.length - 1];\r\n }\r\n\r\n /**\r\n * Set the wrapping mode on U of all the textures we are rendering to.\r\n * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)\r\n */\r\n public set wrapU(wrap: number) {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; i++) {\r\n this._textures[i].wrapU = wrap;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Set the wrapping mode on V of all the textures we are rendering to.\r\n * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)\r\n */\r\n public set wrapV(wrap: number) {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; i++) {\r\n this._textures[i].wrapV = wrap;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Instantiate a new multi render target texture.\r\n * A multi render target, like a render target provides the ability to render to a texture.\r\n * Unlike the render target, it can render to several draw buffers in one draw.\r\n * This is specially interesting in deferred rendering or for any effects requiring more than\r\n * just one color from a single pass.\r\n * @param name Define the name of the texture\r\n * @param size Define the size of the buffers to render to\r\n * @param count Define the number of target we are rendering into\r\n * @param scene Define the scene the texture belongs to\r\n * @param options Define the options used to create the multi render target\r\n * @param textureNames Define the names to set to the textures (if count > 0 - optional)\r\n */\r\n constructor(name: string, size: any, count: number, scene?: Scene, options?: IMultiRenderTargetOptions, textureNames?: string[]) {\r\n const generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;\r\n const generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;\r\n const depthTextureFormat = options && options.depthTextureFormat ? options.depthTextureFormat : Constants.TEXTUREFORMAT_DEPTH16;\r\n const doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;\r\n const drawOnlyOnFirstAttachmentByDefault = options && options.drawOnlyOnFirstAttachmentByDefault ? options.drawOnlyOnFirstAttachmentByDefault : false;\r\n super(name, size, scene, generateMipMaps, doNotChangeAspectRatio, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);\r\n\r\n if (!this.isSupported) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n const types: number[] = [];\r\n const samplingModes: number[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n this._initTypes(count, types, samplingModes, useSRGBBuffers, options);\r\n\r\n const generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n const generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n\r\n this._size = size;\r\n this._multiRenderTargetOptions = {\r\n samplingModes: samplingModes,\r\n generateMipMaps: generateMipMaps,\r\n generateDepthBuffer: generateDepthBuffer,\r\n generateStencilBuffer: generateStencilBuffer,\r\n generateDepthTexture: generateDepthTexture,\r\n depthTextureFormat: depthTextureFormat,\r\n types: types,\r\n textureCount: count,\r\n useSRGBBuffers: useSRGBBuffers,\r\n };\r\n\r\n this._count = count;\r\n this._drawOnlyOnFirstAttachmentByDefault = drawOnlyOnFirstAttachmentByDefault;\r\n\r\n if (count > 0) {\r\n this._createInternalTextures();\r\n this._createTextures(textureNames);\r\n }\r\n }\r\n\r\n private _initTypes(count: number, types: number[], samplingModes: number[], useSRGBBuffers: boolean[], options?: IMultiRenderTargetOptions) {\r\n for (let i = 0; i < count; i++) {\r\n if (options && options.types && options.types[i] !== undefined) {\r\n types.push(options.types[i]);\r\n } else {\r\n types.push(options && options.defaultType ? options.defaultType : Constants.TEXTURETYPE_UNSIGNED_INT);\r\n }\r\n\r\n if (options && options.samplingModes && options.samplingModes[i] !== undefined) {\r\n samplingModes.push(options.samplingModes[i]);\r\n } else {\r\n samplingModes.push(Texture.BILINEAR_SAMPLINGMODE);\r\n }\r\n\r\n if (options && options.useSRGBBuffers && options.useSRGBBuffers[i] !== undefined) {\r\n useSRGBBuffers.push(options.useSRGBBuffers[i]);\r\n } else {\r\n useSRGBBuffers.push(false);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @param forceFullRebuild\r\n * @param textureNames\r\n * @hidden\r\n */\r\n public _rebuild(forceFullRebuild: boolean = false, textureNames?: string[]): void {\r\n if (this._count < 1) {\r\n return;\r\n }\r\n\r\n this.releaseInternalTextures();\r\n this._createInternalTextures();\r\n\r\n if (forceFullRebuild) {\r\n this._releaseTextures();\r\n this._createTextures(textureNames);\r\n }\r\n\r\n const internalTextures = this._renderTarget!.textures!;\r\n for (let i = 0; i < internalTextures.length; i++) {\r\n const texture = this._textures[i];\r\n texture._texture = internalTextures[i];\r\n }\r\n\r\n if (this.samples !== 1) {\r\n this._renderTarget!.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, true);\r\n }\r\n }\r\n\r\n private _createInternalTextures(): void {\r\n this._renderTarget = this._getEngine()!.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault);\r\n this._texture = this._renderTarget.texture;\r\n }\r\n\r\n private _releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; i++) {\r\n this._textures[i]._texture = null; // internal textures are released by a call to releaseInternalTextures()\r\n this._textures[i].dispose();\r\n }\r\n }\r\n }\r\n\r\n private _createTextures(textureNames?: string[]): void {\r\n const internalTextures = this._renderTarget!.textures!;\r\n this._textures = [];\r\n for (let i = 0; i < internalTextures.length; i++) {\r\n const texture = new Texture(null, this.getScene());\r\n if (textureNames?.[i]) {\r\n texture.name = textureNames[i];\r\n }\r\n texture._texture = internalTextures[i];\r\n this._textures.push(texture);\r\n }\r\n }\r\n\r\n /**\r\n * Replaces an internal texture within the MRT. Useful to share textures between MultiRenderTarget.\r\n * @param texture The new texture to set in the MRT\r\n * @param index The index of the texture to replace\r\n * @param disposePrevious Set to true if the previous internal texture should be disposed\r\n */\r\n public setInternalTexture(texture: InternalTexture, index: number, disposePrevious: boolean = true) {\r\n if (!this.renderTarget) {\r\n return;\r\n }\r\n\r\n if (index === 0) {\r\n this._texture = texture;\r\n }\r\n\r\n this.renderTarget.setTexture(texture, index, disposePrevious);\r\n\r\n if (!this.textures[index]) {\r\n this.textures[index] = new Texture(null, this.getScene());\r\n }\r\n this.textures[index]._texture = texture;\r\n\r\n this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0;\r\n\r\n if (this._multiRenderTargetOptions.types) {\r\n this._multiRenderTargetOptions.types[index] = texture.type;\r\n }\r\n if (this._multiRenderTargetOptions.samplingModes) {\r\n this._multiRenderTargetOptions.samplingModes[index] = texture.samplingMode;\r\n }\r\n if (this._multiRenderTargetOptions.useSRGBBuffers) {\r\n this._multiRenderTargetOptions.useSRGBBuffers[index] = texture._useSRGBBuffer;\r\n }\r\n }\r\n\r\n /**\r\n * Define the number of samples used if MSAA is enabled.\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n public set samples(value: number) {\r\n if (this._renderTarget) {\r\n this._samples = this._renderTarget.setSamples(value);\r\n } else {\r\n // In case samples are set with 0 textures created, we must save the desired samples value\r\n this._samples = value;\r\n }\r\n }\r\n\r\n /**\r\n * Resize all the textures in the multi render target.\r\n * Be careful as it will recreate all the data in the new texture.\r\n * @param size Define the new size\r\n */\r\n public resize(size: any) {\r\n this._size = size;\r\n this._rebuild();\r\n }\r\n\r\n /**\r\n * Changes the number of render targets in this MRT\r\n * Be careful as it will recreate all the data in the new texture.\r\n * @param count new texture count\r\n * @param options Specifies texture types and sampling modes for new textures\r\n * @param textureNames Specifies the names of the textures (optional)\r\n */\r\n public updateCount(count: number, options?: IMultiRenderTargetOptions, textureNames?: string[]) {\r\n this._multiRenderTargetOptions.textureCount = count;\r\n this._count = count;\r\n\r\n const types: number[] = [];\r\n const samplingModes: number[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n this._initTypes(count, types, samplingModes, useSRGBBuffers, options);\r\n this._multiRenderTargetOptions.types = types;\r\n this._multiRenderTargetOptions.samplingModes = samplingModes;\r\n this._multiRenderTargetOptions.useSRGBBuffers = useSRGBBuffers;\r\n this._rebuild(true, textureNames);\r\n }\r\n\r\n protected _unbindFrameBuffer(engine: Engine, faceIndex: number): void {\r\n if (this._renderTarget) {\r\n engine.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, () => {\r\n this.onAfterRenderObservable.notifyObservers(faceIndex);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the render targets and their associated resources\r\n * @param doNotDisposeInternalTextures\r\n */\r\n public dispose(doNotDisposeInternalTextures = false): void {\r\n this._releaseTextures();\r\n if (!doNotDisposeInternalTextures) {\r\n this.releaseInternalTextures();\r\n } else {\r\n // Prevent internal texture dispose in super.dispose\r\n this._texture = null;\r\n }\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Release all the underlying texture used as draw buffers.\r\n */\r\n public releaseInternalTextures(): void {\r\n const internalTextures = this._renderTarget?.textures;\r\n\r\n if (!internalTextures) {\r\n return;\r\n }\r\n\r\n for (let i = internalTextures.length - 1; i >= 0; i--) {\r\n this._textures[i]._texture = null;\r\n }\r\n\r\n this._renderTarget?.dispose();\r\n this._renderTarget = null;\r\n }\r\n}\r\n"]}
|
|
@@ -28,12 +28,13 @@ export declare class RawTexture extends Texture {
|
|
|
28
28
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
29
29
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
30
30
|
* @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
|
|
31
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
31
32
|
*/
|
|
32
33
|
constructor(data: Nullable<ArrayBufferView>, width: number, height: number,
|
|
33
34
|
/**
|
|
34
35
|
* Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
|
|
35
36
|
*/
|
|
36
|
-
format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, creationFlags?: number);
|
|
37
|
+
format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, creationFlags?: number, useSRGBBuffer?: boolean);
|
|
37
38
|
/**
|
|
38
39
|
* Updates the texture underlying data.
|
|
39
40
|
* @param data Define the new data of the texture
|
|
@@ -85,9 +86,11 @@ export declare class RawTexture extends Texture {
|
|
|
85
86
|
* @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
86
87
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
87
88
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
89
|
+
* @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
|
|
90
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
88
91
|
* @returns the RGB alpha texture
|
|
89
92
|
*/
|
|
90
|
-
static CreateRGBTexture(data: Nullable<ArrayBufferView>, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
|
|
93
|
+
static CreateRGBTexture(data: Nullable<ArrayBufferView>, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, creationFlags?: number, useSRGBBuffer?: boolean): RawTexture;
|
|
91
94
|
/**
|
|
92
95
|
* Creates a RGBA texture from some data.
|
|
93
96
|
* @param data Define the texture data
|
|
@@ -98,9 +101,11 @@ export declare class RawTexture extends Texture {
|
|
|
98
101
|
* @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
99
102
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
100
103
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
104
|
+
* @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
|
|
105
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
101
106
|
* @returns the RGBA texture
|
|
102
107
|
*/
|
|
103
|
-
static CreateRGBATexture(data: Nullable<ArrayBufferView>, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
|
|
108
|
+
static CreateRGBATexture(data: Nullable<ArrayBufferView>, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, creationFlags?: number, useSRGBBuffer?: boolean): RawTexture;
|
|
104
109
|
/**
|
|
105
110
|
* Creates a RGBA storage texture from some data.
|
|
106
111
|
* @param data Define the texture data
|
|
@@ -111,9 +116,10 @@ export declare class RawTexture extends Texture {
|
|
|
111
116
|
* @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
112
117
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
113
118
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
119
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
114
120
|
* @returns the RGBA texture
|
|
115
121
|
*/
|
|
116
|
-
static CreateRGBAStorageTexture(data: Nullable<ArrayBufferView>, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
|
|
122
|
+
static CreateRGBAStorageTexture(data: Nullable<ArrayBufferView>, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, useSRGBBuffer?: boolean): RawTexture;
|
|
117
123
|
/**
|
|
118
124
|
* Creates a R texture from some data.
|
|
119
125
|
* @param data Define the texture data
|
|
@@ -24,12 +24,13 @@ var RawTexture = /** @class */ (function (_super) {
|
|
|
24
24
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
25
25
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
26
26
|
* @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
|
|
27
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
27
28
|
*/
|
|
28
29
|
function RawTexture(data, width, height,
|
|
29
30
|
/**
|
|
30
31
|
* Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
|
|
31
32
|
*/
|
|
32
|
-
format, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags) {
|
|
33
|
+
format, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer) {
|
|
33
34
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
34
35
|
if (invertY === void 0) { invertY = false; }
|
|
35
36
|
if (samplingMode === void 0) { samplingMode = 3; }
|
|
@@ -45,7 +46,7 @@ var RawTexture = /** @class */ (function (_super) {
|
|
|
45
46
|
if (!_this._engine._caps.textureHalfFloatLinearFiltering && type === 2) {
|
|
46
47
|
samplingMode = 1;
|
|
47
48
|
}
|
|
48
|
-
_this._texture = _this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags !== null && creationFlags !== void 0 ? creationFlags : 0);
|
|
49
|
+
_this._texture = _this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags !== null && creationFlags !== void 0 ? creationFlags : 0, useSRGBBuffer !== null && useSRGBBuffer !== void 0 ? useSRGBBuffer : false);
|
|
49
50
|
_this.wrapU = Texture.CLAMP_ADDRESSMODE;
|
|
50
51
|
_this.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
51
52
|
return _this;
|
|
@@ -55,7 +56,7 @@ var RawTexture = /** @class */ (function (_super) {
|
|
|
55
56
|
* @param data Define the new data of the texture
|
|
56
57
|
*/
|
|
57
58
|
RawTexture.prototype.update = function (data) {
|
|
58
|
-
this._getEngine().updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
|
|
59
|
+
this._getEngine().updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type, this._texture._useSRGBBuffer);
|
|
59
60
|
};
|
|
60
61
|
/**
|
|
61
62
|
* Creates a luminance texture from some data.
|
|
@@ -118,14 +119,18 @@ var RawTexture = /** @class */ (function (_super) {
|
|
|
118
119
|
* @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
119
120
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
120
121
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
122
|
+
* @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
|
|
123
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
121
124
|
* @returns the RGB alpha texture
|
|
122
125
|
*/
|
|
123
|
-
RawTexture.CreateRGBTexture = function (data, width, height, sceneOrEngine, generateMipMaps, invertY, samplingMode, type) {
|
|
126
|
+
RawTexture.CreateRGBTexture = function (data, width, height, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer) {
|
|
124
127
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
125
128
|
if (invertY === void 0) { invertY = false; }
|
|
126
129
|
if (samplingMode === void 0) { samplingMode = 3; }
|
|
127
130
|
if (type === void 0) { type = 0; }
|
|
128
|
-
|
|
131
|
+
if (creationFlags === void 0) { creationFlags = 0; }
|
|
132
|
+
if (useSRGBBuffer === void 0) { useSRGBBuffer = false; }
|
|
133
|
+
return new RawTexture(data, width, height, 4, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);
|
|
129
134
|
};
|
|
130
135
|
/**
|
|
131
136
|
* Creates a RGBA texture from some data.
|
|
@@ -137,14 +142,18 @@ var RawTexture = /** @class */ (function (_super) {
|
|
|
137
142
|
* @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
138
143
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
139
144
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
145
|
+
* @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
|
|
146
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
140
147
|
* @returns the RGBA texture
|
|
141
148
|
*/
|
|
142
|
-
RawTexture.CreateRGBATexture = function (data, width, height, sceneOrEngine, generateMipMaps, invertY, samplingMode, type) {
|
|
149
|
+
RawTexture.CreateRGBATexture = function (data, width, height, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer) {
|
|
143
150
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
144
151
|
if (invertY === void 0) { invertY = false; }
|
|
145
152
|
if (samplingMode === void 0) { samplingMode = 3; }
|
|
146
153
|
if (type === void 0) { type = 0; }
|
|
147
|
-
|
|
154
|
+
if (creationFlags === void 0) { creationFlags = 0; }
|
|
155
|
+
if (useSRGBBuffer === void 0) { useSRGBBuffer = false; }
|
|
156
|
+
return new RawTexture(data, width, height, 5, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);
|
|
148
157
|
};
|
|
149
158
|
/**
|
|
150
159
|
* Creates a RGBA storage texture from some data.
|
|
@@ -156,14 +165,16 @@ var RawTexture = /** @class */ (function (_super) {
|
|
|
156
165
|
* @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
157
166
|
* @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
158
167
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
168
|
+
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
159
169
|
* @returns the RGBA texture
|
|
160
170
|
*/
|
|
161
|
-
RawTexture.CreateRGBAStorageTexture = function (data, width, height, sceneOrEngine, generateMipMaps, invertY, samplingMode, type) {
|
|
171
|
+
RawTexture.CreateRGBAStorageTexture = function (data, width, height, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, useSRGBBuffer) {
|
|
162
172
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
163
173
|
if (invertY === void 0) { invertY = false; }
|
|
164
174
|
if (samplingMode === void 0) { samplingMode = 3; }
|
|
165
175
|
if (type === void 0) { type = 0; }
|
|
166
|
-
|
|
176
|
+
if (useSRGBBuffer === void 0) { useSRGBBuffer = false; }
|
|
177
|
+
return new RawTexture(data, width, height, 5, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, 1, useSRGBBuffer);
|
|
167
178
|
};
|
|
168
179
|
/**
|
|
169
180
|
* Creates a R texture from some data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawTexture.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Textures/rawTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,4CAA4C,CAAC;AAMpD;;;;GAIG;AACH;IAAgC,8BAAO;IACnC;;;;;;;;;;;;;;;OAeG;IACH,oBACI,IAA+B,EAC/B,KAAa,EACb,MAAc;IACd;;OAEG;IACI,MAAc,EACrB,aAA2C,EAC3C,eAA+B,EAC/B,OAAwB,EACxB,YAA+D,EAC/D,IAAiD,EACjD,aAAsB;QAJtB,gCAAA,EAAA,sBAA+B;QAC/B,wBAAA,EAAA,eAAwB;QACxB,6BAAA,EAAA,eAAuB,SAAS,CAAC,8BAA8B;QAC/D,qBAAA,EAAA,OAAe,SAAS,CAAC,wBAAwB;QAZrD,YAeI,kBAAM,IAAI,EAAE,aAAa,EAAE,CAAC,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC,SAiB/J;QAzBU,YAAM,GAAN,MAAM,CAAQ;QAUrB,IAAI,CAAC,KAAI,CAAC,OAAO,EAAE;;SAElB;QAED,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,KAAK,CAAC,2BAA2B,IAAI,IAAI,KAAK,SAAS,CAAC,iBAAiB,EAAE;YACzF,YAAY,GAAG,SAAS,CAAC,4BAA4B,CAAC;SACzD;QACD,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,KAAK,CAAC,+BAA+B,IAAI,IAAI,KAAK,SAAS,CAAC,sBAAsB,EAAE;YAClG,YAAY,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EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACvI,CAAC;IAED;;;;;;;;;;;OAWG;IACW,gCAAqB,GAAnC,UACI,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA2C,EAC3C,eAA+B,EAC/B,OAAwB,EACxB,YAAqD,EACrD,IAA0C;QAH1C,gCAAA,EAAA,sBAA+B;QAC/B,wBAAA,EAAA,eAAwB;QACxB,6BAAA,EAAA,eAAuB,OAAO,CAAC,sBAAsB;QACrD,qBAAA,EAAA,OAAe,SAAS,CAAC,iBAAiB;QAE1C,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,4BAA4B,CAAC,CAAC;IAC/K,CAAC;IACL,iBAAC;AAAD,CAAC,AAvQD,CAAgC,OAAO,GAuQtC","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport \"../../Engines/Extensions/engine.rawTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\n\r\ndeclare type Scene = import(\"../../scene\").Scene;\r\n\r\n/**\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n */\r\nexport class RawTexture extends Texture {\r\n /**\r\n * Instantiates a new RawTexture.\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n * @param data define the array of data to use to create the texture (null to create an empty texture)\r\n * @param width define the width of the texture\r\n * @param height define the height of the texture\r\n * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps define whether mip maps should be generated or not\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n */\r\n constructor(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n /**\r\n * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n */\r\n public format: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n creationFlags?: number\r\n ) {\r\n super(null, sceneOrEngine, !generateMipMaps, invertY, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, creationFlags);\r\n\r\n if (!this._engine) {\r\n return;\r\n }\r\n\r\n if (!this._engine._caps.textureFloatLinearFiltering && type === Constants.TEXTURETYPE_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n if (!this._engine._caps.textureHalfFloatLinearFiltering && type === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n this._texture = this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags ?? 0);\r\n\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n /**\r\n * Updates the texture underlying data.\r\n * @param data Define the new data of the texture\r\n */\r\n public update(data: ArrayBufferView): void {\r\n this._getEngine()!.updateRawTexture(this._texture, data, this._texture!.format, this._texture!.invertY, null, this._texture!.type);\r\n }\r\n\r\n /**\r\n * Creates a luminance texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance texture\r\n */\r\n public static CreateLuminanceTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a luminance alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance alpha texture\r\n */\r\n public static CreateLuminanceAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates an alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the alpha texture\r\n */\r\n public static CreateAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a RGB texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the RGB alpha texture\r\n */\r\n public static CreateRGBTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_RGB, sceneOrEngine, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n\r\n /**\r\n * Creates a RGBA texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBATexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, sceneOrEngine, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n\r\n /**\r\n * Creates a RGBA storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBAStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): RawTexture {\r\n return new RawTexture(\r\n data,\r\n width,\r\n height,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n sceneOrEngine,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n type,\r\n Constants.TEXTURE_CREATIONFLAG_STORAGE\r\n );\r\n }\r\n\r\n /**\r\n * Creates a R texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n public static CreateRTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n\r\n /**\r\n * Creates a R storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n public static CreateRStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, Constants.TEXTURE_CREATIONFLAG_STORAGE);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"rawTexture.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Textures/rawTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,4CAA4C,CAAC;AAMpD;;;;GAIG;AACH;IAAgC,8BAAO;IACnC;;;;;;;;;;;;;;;;OAgBG;IACH,oBACI,IAA+B,EAC/B,KAAa,EACb,MAAc;IACd;;OAEG;IACI,MAAc,EACrB,aAA2C,EAC3C,eAA+B,EAC/B,OAAwB,EACxB,YAA+D,EAC/D,IAAiD,EACjD,aAAsB,EACtB,aAAuB;QALvB,gCAAA,EAAA,sBAA+B;QAC/B,wBAAA,EAAA,eAAwB;QACxB,6BAAA,EAAA,eAAuB,SAAS,CAAC,8BAA8B;QAC/D,qBAAA,EAAA,OAAe,SAAS,CAAC,wBAAwB;QAZrD,YAgBI,kBAAM,IAAI,EAAE,aAAa,EAAE,CAAC,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC,SAiB/J;QA1BU,YAAM,GAAN,MAAM,CAAQ;QAWrB,IAAI,CAAC,KAAI,CAAC,OAAO,EAAE;;SAElB;QAED,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,KAAK,CAAC,2BAA2B,IAAI,IAAI,KAAK,SAAS,CAAC,iBAAiB,EAAE;YACzF,YAAY,GAAG,SAAS,CAAC,4BAA4B,CAAC;SACzD;QACD,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,KAAK,CAAC,+BAA+B,IAAI,IAAI,KAAK,SAAS,CAAC,sBAAsB,EAAE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A5B,UACI,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA2C,EAC3C,eAA+B,EAC/B,OAAwB,EACxB,YAAqD,EACrD,IAA0C;QAH1C,gCAAA,EAAA,sBAA+B;QAC/B,wBAAA,EAAA,eAAwB;QACxB,6BAAA,EAAA,eAAuB,OAAO,CAAC,sBAAsB;QACrD,qBAAA,EAAA,OAAe,SAAS,CAAC,iBAAiB;QAE1C,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACvI,CAAC;IAED;;;;;;;;;;;OAWG;IACW,gCAAqB,GAAnC,UACI,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA2C,EAC3C,eAA+B,EAC/B,OAAwB,EACxB,YAAqD,EACrD,IAA0C;QAH1C,gCAAA,EAAA,sBAA+B;QAC/B,wBAAA,EAAA,eAAwB;QACxB,6BAAA,EAAA,eAAuB,OAAO,CAAC,sBAAsB;QACrD,qBAAA,EAAA,OAAe,SAAS,CAAC,iBAAiB;QAE1C,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,4BAA4B,CAAC,CAAC;IAC/K,CAAC;IACL,iBAAC;AAAD,CAAC,AApRD,CAAgC,OAAO,GAoRtC","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport \"../../Engines/Extensions/engine.rawTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\n\r\ndeclare type Scene = import(\"../../scene\").Scene;\r\n\r\n/**\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n */\r\nexport class RawTexture extends Texture {\r\n /**\r\n * Instantiates a new RawTexture.\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n * @param data define the array of data to use to create the texture (null to create an empty texture)\r\n * @param width define the width of the texture\r\n * @param height define the height of the texture\r\n * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps define whether mip maps should be generated or not\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n */\r\n constructor(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n /**\r\n * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n */\r\n public format: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n creationFlags?: number,\r\n useSRGBBuffer?: boolean\r\n ) {\r\n super(null, sceneOrEngine, !generateMipMaps, invertY, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, creationFlags);\r\n\r\n if (!this._engine) {\r\n return;\r\n }\r\n\r\n if (!this._engine._caps.textureFloatLinearFiltering && type === Constants.TEXTURETYPE_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n if (!this._engine._caps.textureHalfFloatLinearFiltering && type === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n this._texture = this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags ?? 0, useSRGBBuffer ?? false);\r\n\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n /**\r\n * Updates the texture underlying data.\r\n * @param data Define the new data of the texture\r\n */\r\n public update(data: ArrayBufferView): void {\r\n this._getEngine()!.updateRawTexture(this._texture, data, this._texture!.format, this._texture!.invertY, null, this._texture!.type, this._texture!._useSRGBBuffer);\r\n }\r\n\r\n /**\r\n * Creates a luminance texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance texture\r\n */\r\n public static CreateLuminanceTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a luminance alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance alpha texture\r\n */\r\n public static CreateLuminanceAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates an alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the alpha texture\r\n */\r\n public static CreateAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a RGB texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGB alpha texture\r\n */\r\n public static CreateRGBTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_RGB, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);\r\n }\r\n\r\n /**\r\n * Creates a RGBA texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBATexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);\r\n }\r\n\r\n /**\r\n * Creates a RGBA storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBAStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(\r\n data,\r\n width,\r\n height,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n sceneOrEngine,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n type,\r\n Constants.TEXTURE_CREATIONFLAG_STORAGE,\r\n useSRGBBuffer\r\n );\r\n }\r\n\r\n /**\r\n * Creates a R texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n public static CreateRTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n\r\n /**\r\n * Creates a R storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n public static CreateRStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | ThinEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, Constants.TEXTURE_CREATIONFLAG_STORAGE);\r\n }\r\n}\r\n"]}
|
|
@@ -10,6 +10,7 @@ import { EffectFallbacks } from "./effectFallbacks.js";
|
|
|
10
10
|
import { WebRequest } from "../Misc/webRequest.js";
|
|
11
11
|
import { PushMaterial } from "./pushMaterial.js";
|
|
12
12
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
13
|
+
|
|
13
14
|
var onCreatedEffectParameters = { effect: null, subMesh: null };
|
|
14
15
|
/**
|
|
15
16
|
* The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
|
|
@@ -1347,7 +1348,7 @@ var ShaderMaterial = /** @class */ (function (_super) {
|
|
|
1347
1348
|
});
|
|
1348
1349
|
};
|
|
1349
1350
|
/** Define the Url to load snippets */
|
|
1350
|
-
ShaderMaterial.SnippetUrl =
|
|
1351
|
+
ShaderMaterial.SnippetUrl = `https://snippet.babylonjs.com`;
|
|
1351
1352
|
return ShaderMaterial;
|
|
1352
1353
|
}(PushMaterial));
|
|
1353
1354
|
export { ShaderMaterial };
|