Skip to content

Commit

Permalink
[V3.8.5 pipeline] Export RenderWindow (#17003)
Browse files Browse the repository at this point in the history
  • Loading branch information
star-e committed May 17, 2024
1 parent 65992d0 commit 73a43bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 73 deletions.
1 change: 1 addition & 0 deletions cocos/render-scene/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export * from './core/material-instance';
export * from './core/pass-instance';
export * from './core/memory-pools';
export * from './core/render-scene';
export { RenderWindow } from './core/render-window';
export * from './deprecated';

export { scene };
79 changes: 6 additions & 73 deletions cocos/rendering/custom/builtin-forward-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class ForwardLighting {
}
}
}
// Notice: ForwardLighting cannot handle a lot of lights.
// If there are too many lights, the performance will be very poor.
// If many lights are needed, please implement a forward+ or deferred rendering pipeline.
public addLightPasses (
colorName: string,
depthStencilName: string,
Expand Down Expand Up @@ -233,11 +236,7 @@ export class BuiltinForwardPipeline implements PipelineBuilder {
if (camera.scene === null || camera.window === null) {
continue;
}
if (camera.cameraUsage === CameraUsage.EDITOR) {
this._buildEditor(ppl, camera);
} else {
this._buildForward(ppl, camera);
}
this._buildForward(ppl, camera);
}
}
private _resetPipelineStates (camera: Camera, width: number, height: number): void {
Expand All @@ -255,10 +254,7 @@ export class BuiltinForwardPipeline implements PipelineBuilder {
}

// build forward lighting ppl
private _buildForward (
ppl: BasicPipeline,
camera: Camera,
): void {
private _buildForward (ppl: BasicPipeline, camera: Camera): void {
if (!camera.scene) {
return;
}
Expand Down Expand Up @@ -290,7 +286,7 @@ export class BuiltinForwardPipeline implements PipelineBuilder {
}

//----------------------------------------------------------------
// Forward Lighting (Directional Light)
// Forward Lighting (Main Directional Light)
//----------------------------------------------------------------
const pass = ppl.addRenderPass(width, height, 'default');
// set viewport
Expand Down Expand Up @@ -363,69 +359,6 @@ export class BuiltinForwardPipeline implements PipelineBuilder {
);
}

private _buildEditor (
ppl: BasicPipeline,
camera: Camera,
): void {
if (!camera.scene) {
return;
}
//----------------------------------------------------------------
// Init
// ---------------------------------------------------------------
const width = Math.max(Math.floor(camera.window.width), 1);
const height = Math.max(Math.floor(camera.window.height), 1);
const colorName = camera.window.colorName;
const depthStencilName = camera.window.depthStencilName;
const scene = camera.scene;
const mainLight = scene.mainLight;
this._resetPipelineStates(camera, width, height);
//----------------------------------------------------------------
// Forward Lighting (Directional Light)
//----------------------------------------------------------------
const pass = ppl.addRenderPass(width, height, 'default');
// Set viewport
pass.setViewport(this._viewport);
// Bind output render target
if (forwardNeedClearColor(camera)) {
pass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColor);
} else {
pass.addRenderTarget(colorName, LoadOp.LOAD);
}
// Bind depth stencil buffer
if (camera.clearFlag & ClearFlagBit.DEPTH_STENCIL) {
pass.addDepthStencil(
depthStencilName,
LoadOp.CLEAR,
StoreOp.STORE,
camera.clearDepth,
camera.clearStencil,
camera.clearFlag & ClearFlagBit.DEPTH_STENCIL,
);
} else {
pass.addDepthStencil(depthStencilName, LoadOp.LOAD);
}
// Add opaque and mask queue
pass.addQueue(QueueHint.NONE) // Currently we put OPAQUE and MASK into one queue, so QueueHint is NONE
.addScene(
camera,
SceneFlags.OPAQUE | SceneFlags.MASK,
mainLight || undefined,
);

// TODO(zhouzhenglong): Separate OPAQUE and MASK queue

//----------------------------------------------------------------
// Forward Lighting (Blend)
//----------------------------------------------------------------
pass.addQueue(QueueHint.BLEND)
.addScene(
camera,
SceneFlags.BLEND,
mainLight || undefined,
);
}

// Internal cached resources
readonly _clearColor = new Color(0, 0, 0, 1);
readonly _viewport = new Viewport();
Expand Down

0 comments on commit 73a43bb

Please sign in to comment.