Skip to content

Commit

Permalink
[V3.8.5 pipeline] Simplify post-process settings and fix fsr bug of P…
Browse files Browse the repository at this point in the history
…ostProcess pipeline (#17210)

* move builtin-pipeline-settings to internal

* revert fsr to fix cyberpunk render problem

* simplify settings

* fix builtin-pipeline fsr
  • Loading branch information
star-e authored Jun 26, 2024
1 parent 937adbc commit 564d4f5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 44 deletions.
19 changes: 0 additions & 19 deletions cocos/rendering/custom/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,19 @@ import { PipelineSettings } from './settings';
// Editor preview begin
//-----------------------------------------------------------------
let editorPipelineSettings: PipelineSettings | null = null;
let pipelineCamera: Camera | null = null;
let pipelineCameraUsePostProcess = false;
let forceResize = false;

export function setEditorPipelineSettings (
settings: PipelineSettings | null,
camera: Camera | null | undefined,
): void {
editorPipelineSettings = settings;
if (settings && camera) {
pipelineCamera = camera;
pipelineCameraUsePostProcess = camera.usePostProcess;
} else if (!settings) {
pipelineCamera = null;
}
forceResize = true;
}

export function getEditorPipelineSettings (): PipelineSettings | null {
return editorPipelineSettings;
}

export function getEditorPipelineCamera (): Camera | null {
return pipelineCamera;
}

//-----------------------------------------------------------------
// Editor preview end
//-----------------------------------------------------------------
Expand All @@ -85,12 +72,6 @@ export function dispatchResizeEvents (cameras: Camera[], builder: PipelineBuilde
return;
}

// For editor preview
if (pipelineCamera && pipelineCamera.usePostProcess !== pipelineCameraUsePostProcess) {
pipelineCameraUsePostProcess = pipelineCamera.usePostProcess;
forceResize = true;
}

for (const camera of cameras) {
if (!camera.window.isRenderWindowResized() && !forceResize) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions cocos/rendering/post-process/passes/fsr-pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export class FSRPass extends SettingPass {
const input0 = this.lastPass!.slotName(camera, 0);
const easu = `FSR_EASU${cameraID}`;
passContext
.addRenderPass('fsr-easu', `CameraFSR_EASU_Pass${cameraID}`)
.addRenderPass('post-process', `CameraFSR_EASU_Pass${cameraID}`)
.setPassInput(input0, 'outputResultMap')
.addRasterView(easu, Format.RGBA8)
.blitScreen(0)
.version();

const slot0 = this.slotName(camera, 0);
passContext
.addRenderPass('fsr-rcas', `CameraFSR_RCAS_Pass${cameraID}`)
.addRenderPass('post-process', `CameraFSR_RCAS_Pass${cameraID}`)
.setPassInput(easu, 'outputResultMap')
.addRasterView(slot0, Format.RGBA8)
.blitScreen(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ export class BuiltinPipelineSettings extends Component {
return;
}
if (this._editorPreview) {
const camera = this.getComponent(Camera)!.camera;
rendering.setEditorPipelineSettings(this._settings, camera);
rendering.setEditorPipelineSettings(this._settings);
} else {
this._disableEditorPreview();
}
Expand All @@ -102,7 +101,7 @@ export class BuiltinPipelineSettings extends Component {
}
const current = rendering.getEditorPipelineSettings();
if (current === this._settings) {
rendering.setEditorPipelineSettings(null, null);
rendering.setEditorPipelineSettings(null);
}
}

Expand Down
30 changes: 12 additions & 18 deletions editor/assets/default_renderpipeline/builtin-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,24 @@ class CameraConfigs {

function setupPostProcessConfigs(
pipelineConfigs: PipelineConfigs,
camera: renderer.scene.Camera,
settings: PipelineSettings,
cameraConfigs: CameraConfigs,
) {
cameraConfigs.enableDOF = camera.usePostProcess
&& pipelineConfigs.supportDepthSample
cameraConfigs.enableDOF = pipelineConfigs.supportDepthSample
&& settings.depthOfField.enabled
&& settings.depthOfField.material !== null;

cameraConfigs.enableBloom = camera.usePostProcess
&& settings.bloom.enabled
cameraConfigs.enableBloom = settings.bloom.enabled
&& settings.bloom.material !== null;

cameraConfigs.enableColorGrading = camera.usePostProcess
&& settings.colorGrading.enabled
cameraConfigs.enableColorGrading = settings.colorGrading.enabled
&& settings.colorGrading.material !== null
&& settings.colorGrading.colorGradingMap !== null;

cameraConfigs.enableFXAA = camera.usePostProcess
&& settings.fxaa.enabled
cameraConfigs.enableFXAA = settings.fxaa.enabled
&& settings.fxaa.material !== null;

cameraConfigs.enablePostProcess = camera.usePostProcess
&& pipelineConfigs.useFloatOutput
cameraConfigs.enablePostProcess = pipelineConfigs.useFloatOutput
&& (cameraConfigs.enableDOF
|| cameraConfigs.enableBloom
|| cameraConfigs.enableColorGrading
Expand All @@ -185,14 +179,13 @@ function setupCameraConfigs(
cameraConfigs.settings = camera.pipelineSettings
? camera.pipelineSettings : defaultSettings;

setupPostProcessConfigs(pipelineConfigs, camera, cameraConfigs.settings, cameraConfigs);
setupPostProcessConfigs(pipelineConfigs, cameraConfigs.settings, cameraConfigs);

if (isEditorView) {
const editorSettings = rendering.getEditorPipelineSettings();
const pipelineCamera = rendering.getEditorPipelineCamera();
if (editorSettings && pipelineCamera) {
if (editorSettings) {
cameraConfigs.settings = editorSettings;
setupPostProcessConfigs(pipelineConfigs, pipelineCamera,
setupPostProcessConfigs(pipelineConfigs,
cameraConfigs.settings, cameraConfigs);
}
}
Expand Down Expand Up @@ -472,7 +465,7 @@ if (rendering) {
}

// Radiance
if (this._cameraConfigs.enableHDR) {
if (this._configs.useFloatOutput) {
ppl.addRenderTarget(`Radiance${id}`, Format.RGBA16F, width, height);
} else if (this._cameraConfigs.enableShadingScale) {
ppl.addRenderTarget(`Radiance${id}`, Format.RGBA8, width, height);
Expand Down Expand Up @@ -1100,15 +1093,15 @@ if (rendering) {

const fsrColorName = `FsrColor${id}`;

const easuPass = ppl.addRenderPass(nativeWidth, nativeHeight, 'fsr-easu');
const easuPass = ppl.addRenderPass(nativeWidth, nativeHeight, 'post-process');
easuPass.addRenderTarget(fsrColorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
easuPass.addTexture(ldrColorName, 'outputResultMap');
easuPass.setVec4('cc_cameraPos', this._configs.platform); // We only use cc_cameraPos.w
easuPass
.addQueue(QueueHint.OPAQUE)
.addFullscreenQuad(fsrMaterial, 0);

const rcasPass = ppl.addRenderPass(nativeWidth, nativeHeight, 'fsr-rcas');
const rcasPass = ppl.addRenderPass(nativeWidth, nativeHeight, 'post-process');
rcasPass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
rcasPass.addTexture(fsrColorName, 'outputResultMap');
rcasPass.setVec4('cc_cameraPos', this._configs.platform); // We only use cc_cameraPos.w
Expand Down Expand Up @@ -1308,3 +1301,4 @@ if (rendering) {
rendering.setCustomPipeline('Builtin', new BuiltinPipelineBuilder());

} // if (rendering)

4 changes: 2 additions & 2 deletions editor/assets/effects/pipeline/post-process/fsr.effect
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ CCEffect %{
- passes:
- vert: vs
frag: fs-easu
pass: fsr-easu
pass: post-process
rasterizerState:
cullMode: none
depthStencilState:
depthTest: false
depthWrite: false
- vert: vs
frag: fs-rcas
pass: fsr-rcas
pass: post-process
rasterizerState:
cullMode: none
depthStencilState:
Expand Down

0 comments on commit 564d4f5

Please sign in to comment.