@babylonjs/core 5.32.2 → 5.33.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/Bones/boneIKController.d.ts +2 -1
- package/Bones/boneIKController.js +27 -10
- package/Bones/boneIKController.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +11 -3
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Culling/boundingInfo.d.ts +5 -0
- package/Culling/boundingInfo.js +5 -0
- package/Culling/boundingInfo.js.map +1 -1
- package/Engines/Extensions/engine.videoTexture.d.ts +2 -1
- package/Engines/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js +21 -9
- package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +6 -0
- package/Engines/WebGPU/webgpuTextureHelper.js +157 -0
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Layers/effectLayer.js +7 -28
- package/Layers/effectLayer.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +9 -28
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +4 -8
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +9 -8
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +4 -8
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.d.ts +1 -0
- package/Materials/Textures/htmlElementTexture.js +3 -1
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +1 -0
- package/Materials/Textures/videoTexture.js +5 -1
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.d.ts +8 -0
- package/Materials/clipPlaneMaterialHelper.js +78 -0
- package/Materials/clipPlaneMaterialHelper.js.map +1 -0
- package/Materials/index.d.ts +1 -1
- package/Materials/index.js +1 -1
- package/Materials/index.js.map +1 -1
- package/Materials/material.d.ts +27 -1
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.d.ts +3 -7
- package/Materials/materialHelper.js +5 -45
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/shaderMaterial.js +5 -36
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +4 -8
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/linesMesh.js +1 -1
- package/Meshes/linesMesh.js.map +1 -1
- package/Misc/dumpTools.d.ts +49 -0
- package/Misc/dumpTools.js +145 -0
- package/Misc/dumpTools.js.map +1 -0
- package/Misc/environmentTextureTools.js +2 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/screenshotTools.js +17 -13
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/tools.d.ts +2 -6
- package/Misc/tools.js +7 -64
- package/Misc/tools.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +31 -6
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.js +5 -37
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js +5 -36
- package/Particles/particleSystem.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +30 -0
- package/PostProcesses/postProcess.js +48 -2
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +10 -28
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +26 -45
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/imageProcessingFunctions.js +4 -1
- package/Shaders/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/Shaders/circleOfConfusion.fragment.js +3 -1
- package/Shaders/circleOfConfusion.fragment.js.map +1 -1
- package/package.json +1 -1
- package/Materials/thinMaterialHelper.d.ts +0 -17
- package/Materials/thinMaterialHelper.js +0 -41
- package/Materials/thinMaterialHelper.js.map +0 -1
|
@@ -3,6 +3,7 @@ import type { Nullable } from "../../types";
|
|
|
3
3
|
import type { InternalTexture } from "../../Materials/Textures/internalTexture";
|
|
4
4
|
import { WebGPUHardwareTexture } from "./webgpuHardwareTexture";
|
|
5
5
|
import type { WebGPUTintWASM } from "./webgpuTintWASM";
|
|
6
|
+
import type { ExternalTexture } from "../../Materials/Textures/externalTexture";
|
|
6
7
|
/**
|
|
7
8
|
* Map a (renderable) texture format (GPUTextureFormat) to an index for fast lookup (in caches for eg)
|
|
8
9
|
*/
|
|
@@ -16,14 +17,18 @@ export declare class WebGPUTextureHelper {
|
|
|
16
17
|
private _tintWASM;
|
|
17
18
|
private _bufferManager;
|
|
18
19
|
private _mipmapSampler;
|
|
20
|
+
private _videoSampler;
|
|
19
21
|
private _ubCopyWithOfst;
|
|
20
22
|
private _pipelines;
|
|
21
23
|
private _compiledShaders;
|
|
24
|
+
private _videoPipelines;
|
|
25
|
+
private _videoCompiledShaders;
|
|
22
26
|
private _deferredReleaseTextures;
|
|
23
27
|
private _commandEncoderForCreation;
|
|
24
28
|
static ComputeNumMipmapLevels(width: number, height: number): number;
|
|
25
29
|
constructor(device: GPUDevice, glslang: any, tintWASM: Nullable<WebGPUTintWASM>, bufferManager: WebGPUBufferManager);
|
|
26
30
|
private _getPipeline;
|
|
31
|
+
private _getVideoPipeline;
|
|
27
32
|
private static _GetTextureTypeFromFormat;
|
|
28
33
|
private static _GetBlockInformationFromFormat;
|
|
29
34
|
private static _IsHardwareTexture;
|
|
@@ -42,6 +47,7 @@ export declare class WebGPUTextureHelper {
|
|
|
42
47
|
static GetNumChannelsFromWebGPUTextureFormat(format: GPUTextureFormat): number;
|
|
43
48
|
static HasStencilAspect(format: GPUTextureFormat): boolean;
|
|
44
49
|
static HasDepthAndStencilAspects(format: GPUTextureFormat): boolean;
|
|
50
|
+
copyVideoToTexture(video: ExternalTexture, texture: InternalTexture, format: GPUTextureFormat, invertY?: boolean, commandEncoder?: GPUCommandEncoder): void;
|
|
45
51
|
invertYPreMultiplyAlpha(gpuOrHdwTexture: GPUTexture | WebGPUHardwareTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, mipLevel?: number, layers?: number, ofstX?: number, ofstY?: number, rectWidth?: number, rectHeight?: number, commandEncoder?: GPUCommandEncoder, allowGPUOptimization?: boolean): void;
|
|
46
52
|
copyWithInvertY(srcTextureView: GPUTextureView, format: GPUTextureFormat, renderPassDescriptor: GPURenderPassDescriptor, commandEncoder?: GPUCommandEncoder): void;
|
|
47
53
|
createTexture(imageBitmap: ImageBitmap | {
|
|
@@ -141,6 +141,59 @@ const clearFragmentSource = `
|
|
|
141
141
|
outColor = color;
|
|
142
142
|
}
|
|
143
143
|
`;
|
|
144
|
+
const copyVideoToTextureVertexSource = `
|
|
145
|
+
struct VertexOutput {
|
|
146
|
+
@builtin(position) Position : vec4<f32>,
|
|
147
|
+
@location(0) fragUV : vec2<f32>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@vertex
|
|
151
|
+
fn main(
|
|
152
|
+
@builtin(vertex_index) VertexIndex : u32
|
|
153
|
+
) -> VertexOutput {
|
|
154
|
+
var pos = array<vec2<f32>, 4>(
|
|
155
|
+
vec2(-1.0, 1.0),
|
|
156
|
+
vec2( 1.0, 1.0),
|
|
157
|
+
vec2(-1.0, -1.0),
|
|
158
|
+
vec2( 1.0, -1.0)
|
|
159
|
+
);
|
|
160
|
+
var tex = array<vec2<f32>, 4>(
|
|
161
|
+
vec2(0.0, 0.0),
|
|
162
|
+
vec2(1.0, 0.0),
|
|
163
|
+
vec2(0.0, 1.0),
|
|
164
|
+
vec2(1.0, 1.0)
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
var output: VertexOutput;
|
|
168
|
+
|
|
169
|
+
output.Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
|
170
|
+
output.fragUV = tex[VertexIndex];
|
|
171
|
+
|
|
172
|
+
return output;
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
175
|
+
const copyVideoToTextureFragmentSource = `
|
|
176
|
+
@group(0) @binding(0) var videoSampler: sampler;
|
|
177
|
+
@group(0) @binding(1) var videoTexture: texture_external;
|
|
178
|
+
|
|
179
|
+
@fragment
|
|
180
|
+
fn main(
|
|
181
|
+
@location(0) fragUV: vec2<f32>
|
|
182
|
+
) -> @location(0) vec4<f32> {
|
|
183
|
+
return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
const copyVideoToTextureInvertYFragmentSource = `
|
|
187
|
+
@group(0) @binding(0) var videoSampler: sampler;
|
|
188
|
+
@group(0) @binding(1) var videoTexture: texture_external;
|
|
189
|
+
|
|
190
|
+
@fragment
|
|
191
|
+
fn main(
|
|
192
|
+
@location(0) fragUV: vec2<f32>
|
|
193
|
+
) -> @location(0) vec4<f32> {
|
|
194
|
+
return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
144
197
|
var PipelineType;
|
|
145
198
|
(function (PipelineType) {
|
|
146
199
|
PipelineType[PipelineType["MipMap"] = 0] = "MipMap";
|
|
@@ -148,6 +201,11 @@ var PipelineType;
|
|
|
148
201
|
PipelineType[PipelineType["Clear"] = 2] = "Clear";
|
|
149
202
|
PipelineType[PipelineType["InvertYPremultiplyAlphaWithOfst"] = 3] = "InvertYPremultiplyAlphaWithOfst";
|
|
150
203
|
})(PipelineType || (PipelineType = {}));
|
|
204
|
+
var VideoPipelineType;
|
|
205
|
+
(function (VideoPipelineType) {
|
|
206
|
+
VideoPipelineType[VideoPipelineType["DontInvertY"] = 0] = "DontInvertY";
|
|
207
|
+
VideoPipelineType[VideoPipelineType["InvertY"] = 1] = "InvertY";
|
|
208
|
+
})(VideoPipelineType || (VideoPipelineType = {}));
|
|
151
209
|
const shadersForPipelineType = [
|
|
152
210
|
{ vertex: mipmapVertexSource, fragment: mipmapFragmentSource },
|
|
153
211
|
{ vertex: invertYPreMultiplyAlphaVertexSource, fragment: invertYPreMultiplyAlphaFragmentSource },
|
|
@@ -206,14 +264,18 @@ export class WebGPUTextureHelper {
|
|
|
206
264
|
constructor(device, glslang, tintWASM, bufferManager) {
|
|
207
265
|
this._pipelines = {};
|
|
208
266
|
this._compiledShaders = [];
|
|
267
|
+
this._videoPipelines = {};
|
|
268
|
+
this._videoCompiledShaders = [];
|
|
209
269
|
this._deferredReleaseTextures = [];
|
|
210
270
|
this._device = device;
|
|
211
271
|
this._glslang = glslang;
|
|
212
272
|
this._tintWASM = tintWASM;
|
|
213
273
|
this._bufferManager = bufferManager;
|
|
214
274
|
this._mipmapSampler = device.createSampler({ minFilter: WebGPUConstants.FilterMode.Linear });
|
|
275
|
+
this._videoSampler = device.createSampler({ minFilter: WebGPUConstants.FilterMode.Linear });
|
|
215
276
|
this._ubCopyWithOfst = this._bufferManager.createBuffer(4 * 4, WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst).underlyingResource;
|
|
216
277
|
this._getPipeline(WebGPUConstants.TextureFormat.RGBA8Unorm);
|
|
278
|
+
this._getVideoPipeline(WebGPUConstants.TextureFormat.RGBA8Unorm);
|
|
217
279
|
}
|
|
218
280
|
static ComputeNumMipmapLevels(width, height) {
|
|
219
281
|
return Scalar.ILog2(Math.max(width, height)) + 1;
|
|
@@ -282,6 +344,48 @@ export class WebGPUTextureHelper {
|
|
|
282
344
|
}
|
|
283
345
|
return pipelineAndBGL;
|
|
284
346
|
}
|
|
347
|
+
_getVideoPipeline(format, type = VideoPipelineType.DontInvertY) {
|
|
348
|
+
const index = type === VideoPipelineType.InvertY ? 1 << 0 : 0;
|
|
349
|
+
if (!this._videoPipelines[format]) {
|
|
350
|
+
this._videoPipelines[format] = [];
|
|
351
|
+
}
|
|
352
|
+
let pipelineAndBGL = this._videoPipelines[format][index];
|
|
353
|
+
if (!pipelineAndBGL) {
|
|
354
|
+
let modules = this._videoCompiledShaders[index];
|
|
355
|
+
if (!modules) {
|
|
356
|
+
const vertexModule = this._device.createShaderModule({
|
|
357
|
+
code: copyVideoToTextureVertexSource,
|
|
358
|
+
});
|
|
359
|
+
const fragmentModule = this._device.createShaderModule({
|
|
360
|
+
code: index === 0 ? copyVideoToTextureFragmentSource : copyVideoToTextureInvertYFragmentSource,
|
|
361
|
+
});
|
|
362
|
+
modules = this._videoCompiledShaders[index] = [vertexModule, fragmentModule];
|
|
363
|
+
}
|
|
364
|
+
const pipeline = this._device.createRenderPipeline({
|
|
365
|
+
label: `CopyVideoToTexture_${format}_${index === 0 ? "DontInvertY" : "InvertY"}`,
|
|
366
|
+
layout: WebGPUConstants.AutoLayoutMode.Auto,
|
|
367
|
+
vertex: {
|
|
368
|
+
module: modules[0],
|
|
369
|
+
entryPoint: "main",
|
|
370
|
+
},
|
|
371
|
+
fragment: {
|
|
372
|
+
module: modules[1],
|
|
373
|
+
entryPoint: "main",
|
|
374
|
+
targets: [
|
|
375
|
+
{
|
|
376
|
+
format,
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
primitive: {
|
|
381
|
+
topology: WebGPUConstants.PrimitiveTopology.TriangleStrip,
|
|
382
|
+
stripIndexFormat: WebGPUConstants.IndexFormat.Uint16,
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
pipelineAndBGL = this._videoPipelines[format][index] = [pipeline, pipeline.getBindGroupLayout(0)];
|
|
386
|
+
}
|
|
387
|
+
return pipelineAndBGL;
|
|
388
|
+
}
|
|
285
389
|
static _GetTextureTypeFromFormat(format) {
|
|
286
390
|
switch (format) {
|
|
287
391
|
// One Component = 8 bits
|
|
@@ -915,6 +1019,59 @@ export class WebGPUTextureHelper {
|
|
|
915
1019
|
}
|
|
916
1020
|
return false;
|
|
917
1021
|
}
|
|
1022
|
+
copyVideoToTexture(video, texture, format, invertY = false, commandEncoder) {
|
|
1023
|
+
var _a, _b, _c, _d;
|
|
1024
|
+
const useOwnCommandEncoder = commandEncoder === undefined;
|
|
1025
|
+
const [pipeline, bindGroupLayout] = this._getVideoPipeline(format, invertY ? VideoPipelineType.InvertY : VideoPipelineType.DontInvertY);
|
|
1026
|
+
if (useOwnCommandEncoder) {
|
|
1027
|
+
commandEncoder = this._device.createCommandEncoder({});
|
|
1028
|
+
}
|
|
1029
|
+
(_b = (_a = commandEncoder).pushDebugGroup) === null || _b === void 0 ? void 0 : _b.call(_a, `copy video to texture - invertY=${invertY}`);
|
|
1030
|
+
const webgpuHardwareTexture = texture._hardwareTexture;
|
|
1031
|
+
const renderPassDescriptor = {
|
|
1032
|
+
colorAttachments: [
|
|
1033
|
+
{
|
|
1034
|
+
view: webgpuHardwareTexture.underlyingResource.createView({
|
|
1035
|
+
format,
|
|
1036
|
+
dimension: WebGPUConstants.TextureViewDimension.E2d,
|
|
1037
|
+
mipLevelCount: 1,
|
|
1038
|
+
baseArrayLayer: 0,
|
|
1039
|
+
baseMipLevel: 0,
|
|
1040
|
+
arrayLayerCount: 1,
|
|
1041
|
+
aspect: WebGPUConstants.TextureAspect.All,
|
|
1042
|
+
}),
|
|
1043
|
+
loadOp: WebGPUConstants.LoadOp.Load,
|
|
1044
|
+
storeOp: WebGPUConstants.StoreOp.Store,
|
|
1045
|
+
},
|
|
1046
|
+
],
|
|
1047
|
+
};
|
|
1048
|
+
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
1049
|
+
const descriptor = {
|
|
1050
|
+
layout: bindGroupLayout,
|
|
1051
|
+
entries: [
|
|
1052
|
+
{
|
|
1053
|
+
binding: 0,
|
|
1054
|
+
resource: this._videoSampler,
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
binding: 1,
|
|
1058
|
+
resource: this._device.importExternalTexture({
|
|
1059
|
+
source: video.underlyingResource,
|
|
1060
|
+
}),
|
|
1061
|
+
},
|
|
1062
|
+
],
|
|
1063
|
+
};
|
|
1064
|
+
const bindGroup = this._device.createBindGroup(descriptor);
|
|
1065
|
+
passEncoder.setPipeline(pipeline);
|
|
1066
|
+
passEncoder.setBindGroup(0, bindGroup);
|
|
1067
|
+
passEncoder.draw(4, 1, 0, 0);
|
|
1068
|
+
passEncoder.end();
|
|
1069
|
+
(_d = (_c = commandEncoder).popDebugGroup) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
1070
|
+
if (useOwnCommandEncoder) {
|
|
1071
|
+
this._device.queue.submit([commandEncoder.finish()]);
|
|
1072
|
+
commandEncoder = null;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
918
1075
|
invertYPreMultiplyAlpha(gpuOrHdwTexture, width, height, format, invertY = false, premultiplyAlpha = false, faceIndex = 0, mipLevel = 0, layers = 1, ofstX = 0, ofstY = 0, rectWidth = 0, rectHeight = 0, commandEncoder,
|
|
919
1076
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
920
1077
|
allowGPUOptimization) {
|