Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
61d082e
Fix lighting volume when light direction changes
Popov72 Dec 1, 2025
f88d2e5
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into…
Popov72 Dec 1, 2025
c91cb09
Fix ts
Popov72 Dec 1, 2025
ac096ba
Fix ts (2)
Popov72 Dec 1, 2025
d189cfd
Fix visu test
Popov72 Dec 1, 2025
4309fa9
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into…
Popov72 Dec 4, 2025
0629cd9
Fix wrong compute shader being used when having multiple entry points…
Popov72 Dec 4, 2025
66d8ac1
Switch compute shaders to fast mode to optimize performance
Popov72 Dec 4, 2025
79fbe92
Allow smaller texture sizes for the lighting volume texture
Popov72 Dec 4, 2025
ffb1f04
Add getClassName to FrameGraphTask and improve WebGPU debug groups
Popov72 Dec 4, 2025
ec44284
Support depth texture copy
Popov72 Dec 4, 2025
dda7b99
Improve performance of lighting volume updates
Popov72 Dec 4, 2025
ca9c683
Allow totalVertices to be passed to the Geometry constructor
Popov72 Dec 4, 2025
ad8d205
Improve backward compatibility
Popov72 Dec 4, 2025
243d557
Fix usage of copyDepthTexture
Popov72 Dec 4, 2025
e5f9cf0
Fix crash in WebGPU
Popov72 Dec 4, 2025
65a1050
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into…
Popov72 Dec 4, 2025
6788d2f
Allow more connection types to dependencies
Popov72 Dec 5, 2025
a415439
Remove the static imports
Popov72 Dec 5, 2025
7181b38
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into…
Popov72 Dec 5, 2025
6946e70
Better typing
Popov72 Dec 8, 2025
a79620e
Remove dynamic import
Popov72 Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/dev/core/src/FrameGraph/Node/nodeRenderGraphBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ export class NodeRenderGraphBlock {
NodeRenderGraphBlockConnectionPointTypes.TextureAllButBackBuffer |
NodeRenderGraphBlockConnectionPointTypes.ResourceContainer |
NodeRenderGraphBlockConnectionPointTypes.ShadowGenerator |
NodeRenderGraphBlockConnectionPointTypes.ObjectList |
NodeRenderGraphBlockConnectionPointTypes.ShadowLight |
NodeRenderGraphBlockConnectionPointTypes.Camera |
NodeRenderGraphBlockConnectionPointTypes.Object |
additionalAllowedTypes
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class FrameGraphLightingVolumeTask extends FrameGraphTask {

/**
* The output object list containing the lighting volume mesh.
* You can get the mesh by doing outputMeshLightingVolume.meshes[0]
*/
public readonly outputMeshLightingVolume: FrameGraphObjectList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { Constants } from "core/Engines/constants";
import { ThinPassPostProcess } from "core/PostProcesses/thinPassPostProcess";
import { FrameGraphPostProcessTask } from "./postProcessTask";

import "core/Shaders/volumetricLightingBlendVolume.fragment";
import "core/ShadersWGSL/volumetricLightingBlendVolume.fragment";

/**
* @internal
*/
Expand All @@ -23,6 +20,17 @@ class VolumetricLightingBlendVolumeThinPostProcess extends ThinPassPostProcess {

private _invProjection: Matrix;

protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {
if (useWebGPU) {
this._webGPUReady = true;
list.push(Promise.all([import("../../../ShadersWGSL/pass.fragment"), import("../../../ShadersWGSL/volumetricLightingBlendVolume.fragment")]));
} else {
list.push(Promise.all([import("../../../Shaders/pass.fragment"), import("../../../Shaders/volumetricLightingBlendVolume.fragment")]));
}

super._gatherImports(useWebGPU, list);
}

constructor(name: string, engine: Nullable<AbstractEngine> = null, enableExtinction = false, options?: EffectWrapperCreationOptions) {
super(name, engine, {
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import { FrameGraphObjectRendererTask } from "../Rendering/objectRendererTask";
import { ShaderMaterial } from "core/Materials/shaderMaterial";
import { ShaderLanguage } from "core/Materials/shaderLanguage";

import "core/Shaders/volumetricLightingRenderVolume.vertex";
import "core/Shaders/volumetricLightingRenderVolume.fragment";
import "core/ShadersWGSL/volumetricLightingRenderVolume.vertex";
import "core/ShadersWGSL/volumetricLightingRenderVolume.fragment";

const InvViewProjectionMatrix = new Matrix();

/**
Expand Down Expand Up @@ -187,6 +182,15 @@ export class FrameGraphVolumetricLightingTask extends FrameGraphTask {
this.lightPower = this._lightPower;
}

// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
public override initAsync(): Promise<unknown> {
if (this._frameGraph.engine.isWebGPU) {
return Promise.all([import("../../../ShadersWGSL/volumetricLightingRenderVolume.vertex"), import("../../../ShadersWGSL/volumetricLightingRenderVolume.fragment")]);
}

return Promise.all([import("../../../Shaders/volumetricLightingRenderVolume.vertex"), import("../../../Shaders/volumetricLightingRenderVolume.fragment")]);
}

public override isReady() {
return (
this._renderLightingVolumeMaterial.isReady() &&
Expand Down
9 changes: 5 additions & 4 deletions packages/dev/core/src/FrameGraph/frameGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { _RetryWithInterval } from "core/Misc/timingTools";
import { Logger } from "core/Misc/logger";
import { UniqueIdGenerator } from "core/Misc/uniqueIdGenerator";

import "core/Engines/Extensions/engine.multiRender";
import "core/Engines/WebGPU/Extensions/engine.multiRender";

enum FrameGraphPassType {
Normal = 0,
Render = 1,
Expand All @@ -34,9 +31,10 @@ export class FrameGraph implements IDisposable {
private readonly _tasks: FrameGraphTask[] = [];
private readonly _passContext: FrameGraphContext;
private readonly _renderContext: FrameGraphRenderContext;
private readonly _initAsyncPromises: Promise<void>[] = [];
private readonly _initAsyncPromises: Promise<unknown>[] = [];
private _currentProcessedTask: FrameGraphTask | null = null;
private _whenReadyAsyncCancel: Nullable<() => void> = null;
private _importPromise: Promise<any>;

/**
* Name of the frame graph
Expand Down Expand Up @@ -105,6 +103,7 @@ export class FrameGraph implements IDisposable {
) {
this._scene = scene;
this._engine = scene.getEngine();
this._importPromise = this._engine.isWebGPU ? import("../Engines/WebGPU/Extensions/engine.multiRender") : import("../Engines/Extensions/engine.multiRender");
this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);
this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);
this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);
Expand Down Expand Up @@ -234,6 +233,8 @@ export class FrameGraph implements IDisposable {
this._built = false;

try {
await this._importPromise;

await this._whenAsynchronousInitializationDoneAsync();

for (const task of this._tasks) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/FrameGraph/frameGraphTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export abstract class FrameGraphTask {
* @returns A promise that resolves when the initialization is complete.
*/
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
public initAsync(): Promise<void> {
public initAsync(): Promise<unknown> {
return Promise.resolve();
}

Expand Down
29 changes: 16 additions & 13 deletions packages/dev/core/src/Lights/lightingVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ export class LightingVolume {
this._createFallbackTextures();
}

const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;
if (this._engine.isWebGPU && depthTexture) {
this._cs!.setInternalTexture("shadowMap", depthTexture);
this._cs2!.setInternalTexture("shadowMap", depthTexture);
}
this._setComputeShaderInputs();
}

private _tesselation = 0;
Expand Down Expand Up @@ -300,21 +296,29 @@ export class LightingVolume {
entryPoint: "updatePlaneVertices",
});

this._setComputeShaderInputs();
}

private _setComputeShaderInputs() {
if (!this._engine.isWebGPU) {
return;
}

if (this._shadowGenerator) {
const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;
if (depthTexture) {
this._cs.setInternalTexture("shadowMap", depthTexture);
this._cs2.setInternalTexture("shadowMap", depthTexture);
this._cs?.setInternalTexture("shadowMap", depthTexture);
this._cs2?.setInternalTexture("shadowMap", depthTexture);
}
}

if (this._uBuffer) {
this._cs.setUniformBuffer("params", this._uBuffer);
this._cs2.setUniformBuffer("params", this._uBuffer);
this._cs?.setUniformBuffer("params", this._uBuffer);
this._cs2?.setUniformBuffer("params", this._uBuffer);
}
if (this._storageBuffer) {
this._cs.setStorageBuffer("positions", this._storageBuffer);
this._cs2.setStorageBuffer("positions", this._storageBuffer);
this._cs?.setStorageBuffer("positions", this._storageBuffer);
this._cs2?.setStorageBuffer("positions", this._storageBuffer);
}
}

Expand Down Expand Up @@ -490,8 +494,7 @@ export class LightingVolume {

this._mesh.setVerticesBuffer(new VertexBuffer(webGPUEngine, this._storageBuffer.getBuffer(), "position", { takeBufferOwnership: false }), true, vertexNumber);

this._cs!.setStorageBuffer("positions", this._storageBuffer);
this._cs2!.setStorageBuffer("positions", this._storageBuffer);
this._setComputeShaderInputs();

this._cs!.triggerContextRebuild = true;
this._cs2!.triggerContextRebuild = true;
Expand Down