@babylonjs/core 7.45.0 → 7.47.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/Buffers/bufferUtils.d.ts +28 -1
- package/Buffers/bufferUtils.js +104 -1
- package/Buffers/bufferUtils.js.map +1 -1
- package/Cameras/arcRotateCamera.d.ts +13 -0
- package/Cameras/arcRotateCamera.js +28 -12
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Decorators/nodeDecorator.js +1 -1
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +2 -1
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuSnapshotRendering.d.ts +2 -0
- package/Engines/WebGPU/webgpuSnapshotRendering.js +22 -6
- package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +1 -1
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.functions.d.ts +1 -0
- package/Engines/thinEngine.functions.js +1 -1
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.js +4 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +5 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +7 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +13 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +0 -3
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +0 -13
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +3 -0
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +9 -5
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +11 -0
- package/FrameGraph/Passes/renderPass.js +40 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +3 -2
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js +1 -1
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +2 -2
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +2 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js +1 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +5 -5
- package/FrameGraph/frameGraph.js +31 -21
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +8 -2
- package/FrameGraph/frameGraphTask.js +12 -12
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +33 -2
- package/FrameGraph/frameGraphTextureManager.js +368 -27
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Lights/LTC/ltcTextureTool.d.ts +20 -0
- package/Lights/LTC/ltcTextureTool.js +24 -0
- package/Lights/LTC/ltcTextureTool.js.map +1 -0
- package/Lights/Shadows/shadowGenerator.d.ts +10 -0
- package/Lights/Shadows/shadowGenerator.js +5 -0
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGeneratorSceneComponent.js +6 -0
- package/Lights/Shadows/shadowGeneratorSceneComponent.js.map +1 -1
- package/Lights/areaLight.d.ts +39 -0
- package/Lights/areaLight.js +81 -0
- package/Lights/areaLight.js.map +1 -0
- package/Lights/index.d.ts +2 -0
- package/Lights/index.js +2 -0
- package/Lights/index.js.map +1 -1
- package/Lights/light.d.ts +8 -0
- package/Lights/light.js +10 -0
- package/Lights/light.js.map +1 -1
- package/Lights/lightConstants.d.ts +4 -0
- package/Lights/lightConstants.js +4 -0
- package/Lights/lightConstants.js.map +1 -1
- package/Lights/rectAreaLight.d.ts +61 -0
- package/Lights/rectAreaLight.js +127 -0
- package/Lights/rectAreaLight.js.map +1 -0
- package/Loading/loadingScreen.d.ts +21 -1
- package/Loading/loadingScreen.js +125 -52
- package/Loading/loadingScreen.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +2 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/debugBlock.d.ts +38 -0
- package/Materials/Node/Blocks/debugBlock.js +92 -0
- package/Materials/Node/Blocks/debugBlock.js.map +1 -0
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -0
- package/Materials/Node/nodeMaterial.js +20 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +8 -1
- package/Materials/Node/nodeMaterialBlock.js +13 -1
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/PBR/index.d.ts +1 -0
- package/Materials/PBR/index.js +1 -0
- package/Materials/PBR/index.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +13 -0
- package/Materials/PBR/pbrBaseMaterial.js +60 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +8 -0
- package/Materials/PBR/pbrMaterial.js +12 -0
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +0 -18
- package/Materials/Textures/internalTexture.js +0 -46
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +6 -2
- package/Materials/Textures/rawTexture.js +10 -3
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/textureHelper.functions.d.ts +18 -0
- package/Materials/Textures/textureHelper.functions.js +47 -0
- package/Materials/Textures/textureHelper.functions.js.map +1 -0
- package/Materials/effect.d.ts +6 -1
- package/Materials/effect.functions.d.ts +5 -0
- package/Materials/effect.functions.js +6 -2
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +3 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.js +1 -0
- package/Materials/effect.webgl.functions.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.js +4 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -0
- package/Materials/standardMaterial.js +14 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js +0 -1
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +12 -0
- package/Misc/snapshotRenderingHelper.js +74 -20
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/timingTools.d.ts +2 -2
- package/Misc/timingTools.js +15 -10
- package/Misc/timingTools.js.map +1 -1
- package/Particles/gpuParticleSystem.js +8 -2
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +4 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +66 -16
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +8 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +16 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +9 -0
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +28 -11
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +19 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +14 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/ltcHelperFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/ltcHelperFunctions.js +31 -0
- package/Shaders/ShadersInclude/ltcHelperFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +11 -2
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +6 -0
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +18 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +6 -3
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +4 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +5 -2
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/iblShadowAccumulation.fragment.js +6 -5
- package/Shaders/iblShadowAccumulation.fragment.js.map +1 -1
- package/Shaders/iblShadowSpatialBlur.fragment.js +3 -3
- package/Shaders/iblShadowSpatialBlur.fragment.js.map +1 -1
- package/Shaders/iblShadowVoxelTracing.fragment.js +26 -8
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/pbr.fragment.js +11 -3
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +19 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +4 -0
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +4 -0
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +12 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js +35 -0
- package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.js +10 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +4 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +18 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +4 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/iblShadowAccumulation.fragment.js +4 -3
- package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js +3 -3
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +26 -8
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +10 -2
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +2 -0
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +1 -0
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,12 +22,13 @@ export class RawTexture extends Texture {
|
|
|
22
22
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
23
23
|
* @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
|
|
24
24
|
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
25
|
+
* @param waitDataToBeReady If set to true Rawtexture will wait data to be set in order to be flaged as ready.
|
|
25
26
|
*/
|
|
26
27
|
constructor(data, width, height,
|
|
27
28
|
/**
|
|
28
29
|
* Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
|
|
29
30
|
*/
|
|
30
|
-
format, sceneOrEngine, generateMipMaps = true, invertY = false, samplingMode = 3, type = 0, creationFlags, useSRGBBuffer) {
|
|
31
|
+
format, sceneOrEngine, generateMipMaps = true, invertY = false, samplingMode = 3, type = 0, creationFlags, useSRGBBuffer, waitDataToBeReady) {
|
|
31
32
|
super(null, sceneOrEngine, !generateMipMaps, invertY, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, creationFlags);
|
|
32
33
|
this.format = format;
|
|
33
34
|
if (!this._engine) {
|
|
@@ -42,6 +43,7 @@ export class RawTexture extends Texture {
|
|
|
42
43
|
this._texture = this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags ?? 0, useSRGBBuffer ?? false);
|
|
43
44
|
this.wrapU = Texture.CLAMP_ADDRESSMODE;
|
|
44
45
|
this.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
46
|
+
this._waitingForData = !!waitDataToBeReady && !data;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Updates the texture underlying data.
|
|
@@ -49,6 +51,7 @@ export class RawTexture extends Texture {
|
|
|
49
51
|
*/
|
|
50
52
|
update(data) {
|
|
51
53
|
this._getEngine().updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type, this._texture._useSRGBBuffer);
|
|
54
|
+
this._waitingForData = false;
|
|
52
55
|
}
|
|
53
56
|
/**
|
|
54
57
|
* Clones the texture.
|
|
@@ -63,6 +66,9 @@ export class RawTexture extends Texture {
|
|
|
63
66
|
this._texture.incrementReferences();
|
|
64
67
|
return rawTexture;
|
|
65
68
|
}
|
|
69
|
+
isReady() {
|
|
70
|
+
return super.isReady() && !this._waitingForData;
|
|
71
|
+
}
|
|
66
72
|
/**
|
|
67
73
|
* Creates a luminance texture from some data.
|
|
68
74
|
* @param data Define the texture data
|
|
@@ -134,10 +140,11 @@ export class RawTexture extends Texture {
|
|
|
134
140
|
* @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
135
141
|
* @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
|
|
136
142
|
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
143
|
+
* @param waitDataToBeReady if set to true this will force texture to wait for data to be set before it is considered ready.
|
|
137
144
|
* @returns the RGBA texture
|
|
138
145
|
*/
|
|
139
|
-
static CreateRGBATexture(data, width, height, sceneOrEngine, generateMipMaps = true, invertY = false, samplingMode = 3, type = 0, creationFlags = 0, useSRGBBuffer = false) {
|
|
140
|
-
return new RawTexture(data, width, height, 5, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);
|
|
146
|
+
static CreateRGBATexture(data, width, height, sceneOrEngine, generateMipMaps = true, invertY = false, samplingMode = 3, type = 0, creationFlags = 0, useSRGBBuffer = false, waitDataToBeReady = false) {
|
|
147
|
+
return new RawTexture(data, width, height, 5, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer, waitDataToBeReady);
|
|
141
148
|
}
|
|
142
149
|
/**
|
|
143
150
|
* Creates a RGBA storage texture from some data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/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,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;IACI,MAAM,CAAC,qBAAqB,CAC/B,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA+C,EAC/C,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,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;CACJ","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../../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 | AbstractEngine>,\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_BYTE,\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 * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): Texture {\r\n if (!this._texture) {\r\n return super.clone();\r\n }\r\n\r\n const rawTexture = new RawTexture(\r\n null,\r\n this.getSize().width,\r\n this.getSize().height,\r\n this.format,\r\n this.getScene(),\r\n this._texture.generateMipMaps,\r\n this._invertY,\r\n this.samplingMode,\r\n this._texture.type,\r\n this._texture._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n\r\n rawTexture._texture = this._texture;\r\n this._texture.incrementReferences();\r\n\r\n return rawTexture;\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 | AbstractEngine>,\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 | AbstractEngine>,\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 | AbstractEngine>,\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 | AbstractEngine>,\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_BYTE,\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 | AbstractEngine>,\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_BYTE,\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 | AbstractEngine>,\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_BYTE,\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 | AbstractEngine>,\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 | AbstractEngine>,\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":["../../../../../dev/core/src/Materials/Textures/rawTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMpD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ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,eAAuB,OAAO,CAAC,sBAAsB,EACrD,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;IACI,MAAM,CAAC,qBAAqB,CAC/B,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA+C,EAC/C,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,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;CACJ","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../../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 private _waitingForData: boolean;\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 * @param waitDataToBeReady If set to true Rawtexture will wait data to be set in order to be flaged as ready.\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 | AbstractEngine>,\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_BYTE,\r\n creationFlags?: number,\r\n useSRGBBuffer?: boolean,\r\n waitDataToBeReady?: 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 this._waitingForData = !!waitDataToBeReady && !data;\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 this._waitingForData = false;\r\n }\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): Texture {\r\n if (!this._texture) {\r\n return super.clone();\r\n }\r\n\r\n const rawTexture = new RawTexture(\r\n null,\r\n this.getSize().width,\r\n this.getSize().height,\r\n this.format,\r\n this.getScene(),\r\n this._texture.generateMipMaps,\r\n this._invertY,\r\n this.samplingMode,\r\n this._texture.type,\r\n this._texture._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n\r\n rawTexture._texture = this._texture;\r\n this._texture.incrementReferences();\r\n\r\n return rawTexture;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return super.isReady() && !this._waitingForData;\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 | AbstractEngine>,\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 | AbstractEngine>,\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 | AbstractEngine>,\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 | AbstractEngine>,\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_BYTE,\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 * @param waitDataToBeReady if set to true this will force texture to wait for data to be set before it is considered ready.\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 | AbstractEngine>,\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_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false,\r\n waitDataToBeReady: 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 creationFlags,\r\n useSRGBBuffer,\r\n waitDataToBeReady\r\n );\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 | AbstractEngine>,\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_BYTE,\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 | AbstractEngine>,\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 | AbstractEngine>,\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"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a given format is a depth texture format
|
|
3
|
+
* @param format Format to check
|
|
4
|
+
* @returns True if the format is a depth texture format
|
|
5
|
+
*/
|
|
6
|
+
export declare function IsDepthTexture(format: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the type of a depth texture for a given format
|
|
9
|
+
* @param format Format of the texture
|
|
10
|
+
* @returns The type of the depth texture
|
|
11
|
+
*/
|
|
12
|
+
export declare function GetTypeForDepthTexture(format: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a given format has a stencil aspect
|
|
15
|
+
* @param format Format to check
|
|
16
|
+
* @returns True if the format has a stencil aspect
|
|
17
|
+
*/
|
|
18
|
+
export declare function HasStencilAspect(format: number): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a given format is a depth texture format
|
|
4
|
+
* @param format Format to check
|
|
5
|
+
* @returns True if the format is a depth texture format
|
|
6
|
+
*/
|
|
7
|
+
export function IsDepthTexture(format) {
|
|
8
|
+
return (format === 13 ||
|
|
9
|
+
format === 14 ||
|
|
10
|
+
format === 15 ||
|
|
11
|
+
format === 16 ||
|
|
12
|
+
format === 17 ||
|
|
13
|
+
format === 18 ||
|
|
14
|
+
format === 19);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Gets the type of a depth texture for a given format
|
|
18
|
+
* @param format Format of the texture
|
|
19
|
+
* @returns The type of the depth texture
|
|
20
|
+
*/
|
|
21
|
+
export function GetTypeForDepthTexture(format) {
|
|
22
|
+
switch (format) {
|
|
23
|
+
case 13:
|
|
24
|
+
case 17:
|
|
25
|
+
case 18:
|
|
26
|
+
case 14:
|
|
27
|
+
case 16:
|
|
28
|
+
return 1;
|
|
29
|
+
case 15:
|
|
30
|
+
return 5;
|
|
31
|
+
case 19:
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a given format has a stencil aspect
|
|
38
|
+
* @param format Format to check
|
|
39
|
+
* @returns True if the format has a stencil aspect
|
|
40
|
+
*/
|
|
41
|
+
export function HasStencilAspect(format) {
|
|
42
|
+
return (format === 13 ||
|
|
43
|
+
format === 17 ||
|
|
44
|
+
format === 18 ||
|
|
45
|
+
format === 19);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=textureHelper.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textureHelper.functions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/textureHelper.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAEnD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IACzC,OAAO,CACH,MAAM,KAAK,SAAS,CAAC,8BAA8B;QACnD,MAAM,KAAK,SAAS,CAAC,2BAA2B;QAChD,MAAM,KAAK,SAAS,CAAC,qBAAqB;QAC1C,MAAM,KAAK,SAAS,CAAC,qBAAqB;QAC1C,MAAM,KAAK,SAAS,CAAC,mCAAmC;QACxD,MAAM,KAAK,SAAS,CAAC,mCAAmC;QACxD,MAAM,KAAK,SAAS,CAAC,sBAAsB,CAC9C,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACjD,QAAQ,MAAM,EAAE,CAAC;QACb,KAAK,SAAS,CAAC,8BAA8B,CAAC;QAC9C,KAAK,SAAS,CAAC,mCAAmC,CAAC;QACnD,KAAK,SAAS,CAAC,mCAAmC,CAAC;QACnD,KAAK,SAAS,CAAC,2BAA2B,CAAC;QAC3C,KAAK,SAAS,CAAC,qBAAqB;YAChC,OAAO,SAAS,CAAC,iBAAiB,CAAC;QACvC,KAAK,SAAS,CAAC,qBAAqB;YAChC,OAAO,SAAS,CAAC,0BAA0B,CAAC;QAChD,KAAK,SAAS,CAAC,sBAAsB;YACjC,OAAO,SAAS,CAAC,yBAAyB,CAAC;IACnD,CAAC;IAED,OAAO,SAAS,CAAC,yBAAyB,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC3C,OAAO,CACH,MAAM,KAAK,SAAS,CAAC,8BAA8B;QACnD,MAAM,KAAK,SAAS,CAAC,mCAAmC;QACxD,MAAM,KAAK,SAAS,CAAC,mCAAmC;QACxD,MAAM,KAAK,SAAS,CAAC,sBAAsB,CAC9C,CAAC;AACN,CAAC","sourcesContent":["import { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Checks if a given format is a depth texture format\r\n * @param format Format to check\r\n * @returns True if the format is a depth texture format\r\n */\r\nexport function IsDepthTexture(format: number): boolean {\r\n return (\r\n format === Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 ||\r\n format === Constants.TEXTUREFORMAT_DEPTH32_FLOAT ||\r\n format === Constants.TEXTUREFORMAT_DEPTH16 ||\r\n format === Constants.TEXTUREFORMAT_DEPTH24 ||\r\n format === Constants.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 ||\r\n format === Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 ||\r\n format === Constants.TEXTUREFORMAT_STENCIL8\r\n );\r\n}\r\n\r\n/**\r\n * Gets the type of a depth texture for a given format\r\n * @param format Format of the texture\r\n * @returns The type of the depth texture\r\n */\r\nexport function GetTypeForDepthTexture(format: number): number {\r\n switch (format) {\r\n case Constants.TEXTUREFORMAT_DEPTH24_STENCIL8:\r\n case Constants.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8:\r\n case Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8:\r\n case Constants.TEXTUREFORMAT_DEPTH32_FLOAT:\r\n case Constants.TEXTUREFORMAT_DEPTH24:\r\n return Constants.TEXTURETYPE_FLOAT;\r\n case Constants.TEXTUREFORMAT_DEPTH16:\r\n return Constants.TEXTURETYPE_UNSIGNED_SHORT;\r\n case Constants.TEXTUREFORMAT_STENCIL8:\r\n return Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n }\r\n\r\n return Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n}\r\n\r\n/**\r\n * Checks if a given format has a stencil aspect\r\n * @param format Format to check\r\n * @returns True if the format has a stencil aspect\r\n */\r\nexport function HasStencilAspect(format: number): boolean {\r\n return (\r\n format === Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 ||\r\n format === Constants.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 ||\r\n format === Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 ||\r\n format === Constants.TEXTUREFORMAT_STENCIL8\r\n );\r\n}\r\n"]}
|
package/Materials/effect.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface IEffectCreationOptions {
|
|
|
66
66
|
/**
|
|
67
67
|
* Uniform buffer variable names that will be set in the shader.
|
|
68
68
|
*/
|
|
69
|
-
uniformBuffersNames
|
|
69
|
+
uniformBuffersNames?: string[];
|
|
70
70
|
/**
|
|
71
71
|
* Sampler texture variable names that will be set in the shader.
|
|
72
72
|
*/
|
|
@@ -123,6 +123,10 @@ export interface IEffectCreationOptions {
|
|
|
123
123
|
* Additional async code to run before preparing the effect
|
|
124
124
|
*/
|
|
125
125
|
extraInitializationsAsync?: () => Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* If set to true the shader will not be compiles asynchronously, even if the engine allows it.
|
|
128
|
+
*/
|
|
129
|
+
disableParallelShaderCompilation?: boolean;
|
|
126
130
|
}
|
|
127
131
|
/**
|
|
128
132
|
* Effect containing vertex and fragment shader that can be executed on an object.
|
|
@@ -233,6 +237,7 @@ export declare class Effect implements IDisposable {
|
|
|
233
237
|
private _fragmentSourceCodeOverride;
|
|
234
238
|
private _transformFeedbackVaryings;
|
|
235
239
|
private _shaderLanguage;
|
|
240
|
+
private _disableParallelShaderCompilation;
|
|
236
241
|
/**
|
|
237
242
|
* Compiled shader to webGL program.
|
|
238
243
|
* @internal
|
|
@@ -49,6 +49,10 @@ export interface IPipelineGenerationOptions {
|
|
|
49
49
|
* If true, generating a new pipeline will return when the pipeline is ready to be used
|
|
50
50
|
*/
|
|
51
51
|
waitForIsReady?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* If true, the pipeline will be created synchronously, even if parallel shader compilation is available
|
|
54
|
+
*/
|
|
55
|
+
disableParallelCompilation?: boolean;
|
|
52
56
|
}
|
|
53
57
|
/**
|
|
54
58
|
* @internal
|
|
@@ -68,6 +72,7 @@ export interface ICreateAndPreparePipelineContextOptions {
|
|
|
68
72
|
fragment: string;
|
|
69
73
|
defines: Nullable<string>;
|
|
70
74
|
transformFeedbackVaryings: Nullable<string[]>;
|
|
75
|
+
disableParallelCompilation?: boolean;
|
|
71
76
|
}
|
|
72
77
|
/**
|
|
73
78
|
* Get a cached pipeline context
|
|
@@ -166,10 +166,14 @@ function _useFinalCode(migratedVertexCode, migratedFragmentCode, baseName, shade
|
|
|
166
166
|
*/
|
|
167
167
|
export const createAndPreparePipelineContext = (options, createPipelineContext, _preparePipelineContext, _executeWhenRenderingStateIsCompiled) => {
|
|
168
168
|
try {
|
|
169
|
+
const stateObject = options.context ? getStateObject(options.context) : null;
|
|
170
|
+
if (stateObject) {
|
|
171
|
+
// will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation
|
|
172
|
+
stateObject.disableParallelShaderCompile = options.disableParallelCompilation;
|
|
173
|
+
}
|
|
169
174
|
const pipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);
|
|
170
175
|
pipelineContext._name = options.name;
|
|
171
|
-
if (options.name &&
|
|
172
|
-
const stateObject = getStateObject(options.context);
|
|
176
|
+
if (options.name && stateObject) {
|
|
173
177
|
stateObject.cachedPipelines[options.name] = pipelineContext;
|
|
174
178
|
}
|
|
175
179
|
// Flagged as async as we may need to delay load some processing tools
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iCAAgC;AAIjF,OAAO,EAAE,cAAc,EAAE,2CAA0C;AACnE,OAAO,EAAE,WAAW,EAAE,kCAAiC;AAIvD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,iDAAgD;AACxF,OAAO,EAAE,SAAS,EAAE,+CAA8C;AAyElE;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAqB;IACjE,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA0B;IAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC5B,MAAM,OAAO,GAAI,QAAiC,CAAC,OAAO,CAAC;IAC3D,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;QAClB,MAAM,WAAW,GAAG,cAAc,CAAC,OAAQ,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACzD,cAAc,EAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAC9B,gBAAmC,EACnC,QAAa,EAC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,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,CAAC,CAAC,OAAO,CAAC,WAAW,EACrB,EAAE,EACF,EAAE,EACF,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,yBAAyB,EACjC,EAAE,EACF,GAAG,EAAE;YACD,oCAAoC,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { ProcessingOptions, ShaderCustomProcessingFunction, ShaderProcessingContext } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"core/Misc/domManagement\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport type { WebGLContext } from \"core/Engines/thinEngine.functions\";\r\nimport { getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { Effect, IShaderPath } from \"./effect\";\r\nimport type { IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"core/Engines/Processors/shaderProcessor\";\r\nimport { _loadFile } from \"core/Engines/abstractEngine.functions\";\r\nimport type { WebGLPipelineContext } from \"core/Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<ProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<ShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context!);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function _processShaderCode(\r\n processorOptions: ProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n processorOptions.isFragment = true;\r\n const [migratedVertexCode, fragmentCode] = shaderCodes;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = _useFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n _loadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n shaderCodes[0] = migratedVertexCode;\r\n shadersLoaded();\r\n },\r\n engine\r\n );\r\n },\r\n shaderLanguage\r\n );\r\n _loadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction _loadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _loadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _loadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction _useFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContext,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && options.context) {\r\n const stateObject = getStateObject(options.context);\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iCAAgC;AAIjF,OAAO,EAAE,cAAc,EAAE,2CAA0C;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;YACD,oCAAoC,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { ProcessingOptions, ShaderCustomProcessingFunction, ShaderProcessingContext } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"core/Misc/domManagement\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport type { WebGLContext } from \"core/Engines/thinEngine.functions\";\r\nimport { getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { Effect, IShaderPath } from \"./effect\";\r\nimport type { IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"core/Engines/Processors/shaderProcessor\";\r\nimport { _loadFile } from \"core/Engines/abstractEngine.functions\";\r\nimport type { WebGLPipelineContext } from \"core/Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<ProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<ShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context!);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function _processShaderCode(\r\n processorOptions: ProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n processorOptions.isFragment = true;\r\n const [migratedVertexCode, fragmentCode] = shaderCodes;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = _useFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n _loadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n shaderCodes[0] = migratedVertexCode;\r\n shadersLoaded();\r\n },\r\n engine\r\n );\r\n },\r\n shaderLanguage\r\n );\r\n _loadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction _loadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _loadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _loadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction _useFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContext,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
|
package/Materials/effect.js
CHANGED
|
@@ -112,6 +112,7 @@ export class Effect {
|
|
|
112
112
|
this._vertexSourceCodeOverride = "";
|
|
113
113
|
this._fragmentSourceCodeOverride = "";
|
|
114
114
|
this._transformFeedbackVaryings = null;
|
|
115
|
+
this._disableParallelShaderCompilation = false;
|
|
115
116
|
/**
|
|
116
117
|
* Compiled shader to webGL program.
|
|
117
118
|
* @internal
|
|
@@ -149,6 +150,7 @@ export class Effect {
|
|
|
149
150
|
this._transformFeedbackVaryings = options.transformFeedbackVaryings || null;
|
|
150
151
|
this._multiTarget = !!options.multiTarget;
|
|
151
152
|
this._shaderLanguage = options.shaderLanguage ?? 0 /* ShaderLanguage.GLSL */;
|
|
153
|
+
this._disableParallelShaderCompilation = !!options.disableParallelShaderCompilation;
|
|
152
154
|
if (options.uniformBuffersNames) {
|
|
153
155
|
this._uniformBuffersNamesList = options.uniformBuffersNames.slice();
|
|
154
156
|
for (let i = 0; i < options.uniformBuffersNames.length; i++) {
|
|
@@ -530,7 +532,7 @@ export class Effect {
|
|
|
530
532
|
transformFeedbackVaryings: this._transformFeedbackVaryings,
|
|
531
533
|
name: this._key.replace(/\r/g, "").replace(/\n/g, "|"),
|
|
532
534
|
createAsRaw: overrides,
|
|
533
|
-
|
|
535
|
+
disableParallelCompilation: this._disableParallelShaderCompilation,
|
|
534
536
|
shaderProcessingContext: this._processingContext,
|
|
535
537
|
onRenderingStateCompiled: (pipelineContext) => {
|
|
536
538
|
if (previousPipelineContext && !keepExistingPipelineContext) {
|