Skip to content

Commit

Permalink
add 4s skin to post-process pipeline (cocos#15135)
Browse files Browse the repository at this point in the history
  • Loading branch information
troublemaker52025 authored May 23, 2023
1 parent ae01a2e commit c21e560
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 20 deletions.
25 changes: 18 additions & 7 deletions cocos/rendering/post-process/passes/base-pass.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { EDITOR } from 'internal:constants';
import { builtinResMgr } from '../../../asset/asset-manager';

import { Material, RenderTexture } from '../../../asset/assets';
import { director } from '../../../game';
import { Rect } from '../../../gfx';
import { MaterialInstance } from '../../../render-scene';
import { Material } from '../../../asset/assets';
import { Camera } from '../../../render-scene/scene';
import { getCameraUniqueID, getRenderArea } from '../../custom/define';
import { Pipeline } from '../../custom/pipeline';
import { getCameraUniqueID } from '../../custom/define';
import { BasicPipeline, Pipeline } from '../../custom/pipeline';
import { passContext } from '../utils/pass-context';
import { Format } from '../../../gfx';
import { supportsRGBA16FloatTexture } from '../../define';
import { macro } from '../../../core';

let _BasePassID = 0;

export function GetRTFormatBeforeToneMapping (ppl: BasicPipeline) {
const useFloatOutput = ppl.getMacroBool('CC_USE_FLOAT_OUTPUT');
return ppl.pipelineSceneData.isHDR && useFloatOutput && supportsRGBA16FloatTexture(ppl.device) ? Format.RGBA16F : Format.RGBA8;
}
export function ForceEnableFloatOutput (ppl: BasicPipeline) {
if (ppl.pipelineSceneData.isHDR && !ppl.getMacroBool('CC_USE_FLOAT_OUTPUT')) {
const supportFloatOutput = supportsRGBA16FloatTexture(ppl.device);
ppl.setMacroBool('CC_USE_FLOAT_OUTPUT', supportFloatOutput);
macro.ENABLE_FLOAT_OUTPUT = supportFloatOutput;
}
}

export abstract class BasePass {
abstract name: string;
effectName = 'pipeline/post-process/blit-screen';
Expand Down
4 changes: 2 additions & 2 deletions cocos/rendering/post-process/passes/forward-pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AccessType, LightInfo, QueueHint, ResourceResidency, SceneFlags } from
import { getCameraUniqueID } from '../../custom/define';
import { Pipeline } from '../../custom/pipeline';
import { passContext } from '../utils/pass-context';
import { BasePass } from './base-pass';
import { BasePass, GetRTFormatBeforeToneMapping } from './base-pass';
import { ShadowPass } from './shadow-pass';

export class ForwardPass extends BasePass {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class ForwardPass extends BasePass {
passContext
.updatePassViewPort()
.addRenderPass('default', `${this.name}_${cameraID}`)
.addRasterView(slot0, Format.RGBA16F, isOffScreen)
.addRasterView(slot0, GetRTFormatBeforeToneMapping(ppl), isOffScreen)
.addRasterView(slot1, Format.DEPTH_STENCIL, isOffScreen)
.version();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ import { LightInfo, QueueHint, SceneFlags } from '../../custom';
import { getCameraUniqueID } from '../../custom/define';
import { Pipeline } from '../../custom/pipeline';
import { passContext } from '../utils/pass-context';
import { BasePass } from './base-pass';
import { BasePass, GetRTFormatBeforeToneMapping } from './base-pass';
import { ShadowPass } from './shadow-pass';

export class ForwardTransparencyPass extends BasePass {
name = 'ForwardTransparencyPass';

enableInAllEditorCamera = true;
depthBufferShadingScale = 1;
enable = true;
checkEnable (camera: Camera) {
return true;
}

slotName (camera: Camera, index = 0) {
return this.lastPass!.slotName(camera, index);
Expand All @@ -52,7 +56,7 @@ export class ForwardTransparencyPass extends BasePass {
passContext
.updatePassViewPort()
.addRenderPass('default', `${this.name}_${cameraID}`)
.addRasterView(output, Format.RGBA16F, isOffScreen)
.addRasterView(output, GetRTFormatBeforeToneMapping(ppl), isOffScreen)
.addRasterView(outputDS, Format.DEPTH_STENCIL, isOffScreen)
.version();

Expand Down
1 change: 1 addition & 0 deletions cocos/rendering/post-process/passes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './shadow-pass';
export * from './tone-mapping-pass';
export * from './forward-transparency-pass';
export * from './forward-transparency-simple-pass';
export * from './skin-pass';
Loading

0 comments on commit c21e560

Please sign in to comment.