Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CDF explicit render option. #16022

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class _IblShadowsVoxelTracingPass {
uniforms: ["sizeParams"],
samplers: ["debugSampler"],
engine: this._engine,
reusable: false,
reusable: true,
shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,
extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {
if (useWebGPU) {
Expand Down
33 changes: 32 additions & 1 deletion packages/dev/core/src/Rendering/iblCdfGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class IblCdfGenerator {
/** Enable the debug view for this pass */
public debugEnabled: boolean = false;
private _debugPass: PostProcess;
private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);
private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);

/**
* Sets params that control the position and scaling of the debug display on the screen.
Expand Down Expand Up @@ -338,6 +338,37 @@ export class IblCdfGenerator {
);
}

/**
* Explicitly trigger generation of CDF maps when they are ready to render.
* @returns Promise that resolves when the CDF maps are rendered.
*/
public renderWhenReady(): Promise<void> {
// Once the textures are generated, notify that they are ready to use.
this._icdfPT.onGeneratedObservable.addOnce(() => {
this.onGeneratedObservable.notifyObservers();
});
const promises: Array<Promise<void>> = [];
const renderTargets: Array<ProceduralTexture> = [this._cdfyPT, this._cdfxPT, this._scaledLuminancePT, this._icdfPT];
renderTargets.forEach((target) => {
promises.push(
new Promise((resolve) => {
if (target.isReady()) {
resolve();
} else {
target.getEffect().executeWhenCompiled(() => {
resolve();
});
}
})
);
});
return Promise.all(promises).then(() => {
renderTargets.forEach((target) => {
target.render();
});
});
}

/**
* Disposes the CDF renderer and associated resources
*/
Expand Down