mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
fix hbao in post process pipeline (#15077)
This commit is contained in:
committed by
GitHub
parent
4c2bed1c76
commit
92bf626ea6
@@ -24,7 +24,7 @@
|
||||
|
||||
import { CCBoolean, CCFloat, CCInteger } from '../../../core';
|
||||
import { ccclass, disallowMultiple, editable, executeInEditMode, menu, range,
|
||||
serializable, slide, tooltip, type } from '../../../core/data/decorators';
|
||||
serializable, slide, tooltip, type, visible } from '../../../core/data/decorators';
|
||||
import { PostProcessSetting } from './post-process-setting';
|
||||
|
||||
@ccclass('cc.HBAO')
|
||||
@@ -55,6 +55,7 @@ export class HBAO extends PostProcessSetting {
|
||||
return this._radiusScale;
|
||||
}
|
||||
|
||||
@visible(false)
|
||||
@slide
|
||||
@tooltip('i18n:hbao.angleBiasDegree')
|
||||
@range([0, 100, 0.1])
|
||||
@@ -67,6 +68,7 @@ export class HBAO extends PostProcessSetting {
|
||||
return this._angleBiasDegree;
|
||||
}
|
||||
|
||||
@visible(false)
|
||||
@slide
|
||||
@tooltip('i18n:hbao.blurSharpness')
|
||||
@range([0, 10, 1])
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { cclegacy, toRadian, Vec2, Vec4 } from '../../../core';
|
||||
import { Address, ClearFlagBit, Filter, Format } from '../../../gfx';
|
||||
import { Camera } from '../../../render-scene/scene';
|
||||
import { Camera, CameraUsage } from '../../../render-scene/scene';
|
||||
import { Pipeline, QueueHint } from '../../custom';
|
||||
import { getCameraUniqueID } from '../../custom/define';
|
||||
import { passContext } from '../utils/pass-context';
|
||||
@@ -34,6 +34,7 @@ import { HBAO } from '../components';
|
||||
import { Texture2D } from '../../../asset/assets/texture-2d';
|
||||
import { ImageAsset } from '../../../asset/assets/image-asset';
|
||||
import { DebugViewCompositeType, DebugViewSingleType } from '../../debug-view';
|
||||
import { ClearFlagBit, Format } from '../../../gfx';
|
||||
|
||||
const vec2 = new Vec2();
|
||||
|
||||
@@ -177,7 +178,8 @@ export class HBAOPass extends SettingPass {
|
||||
private HBAO_BLUR_X_PASS_INDEX = 1;
|
||||
private HBAO_BLUR_Y_PASS_INDEX = 2;
|
||||
private HBAO_COMBINED_PASS_INDEX = 3;
|
||||
private _hbaoParams: HBAOParams;
|
||||
private _hbaoParams: HBAOParams = new HBAOParams();
|
||||
private _initialize = false;
|
||||
|
||||
get setting () { return getSetting(HBAO); }
|
||||
|
||||
@@ -186,15 +188,11 @@ export class HBAOPass extends SettingPass {
|
||||
outputNames = ['hbaoRTName', 'hbaoBluredRTName']
|
||||
|
||||
checkEnable (camera: Camera) {
|
||||
const enable = super.checkEnable(camera);
|
||||
const setting = this.setting;
|
||||
return enable && !!setting && setting.enabledInHierarchy;
|
||||
}
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this._hbaoParams = new HBAOParams();
|
||||
this.material.setProperty('RandomTex', this._hbaoParams.randomTexture, 0);
|
||||
let enable = super.checkEnable(camera);
|
||||
if (EDITOR && camera.cameraUsage === CameraUsage.PREVIEW) {
|
||||
enable = false;
|
||||
}
|
||||
return enable;
|
||||
}
|
||||
|
||||
public render (camera: Camera, ppl: Pipeline): void {
|
||||
@@ -203,6 +201,10 @@ export class HBAOPass extends SettingPass {
|
||||
const height = passContext.passViewport.height;
|
||||
|
||||
const setting = this.setting;
|
||||
if (!this._initialize) {
|
||||
passContext.material = this.material;
|
||||
this.material.setProperty('RandomTex', this._hbaoParams.randomTexture, 0);
|
||||
}
|
||||
|
||||
// params
|
||||
const aoStrength = 1.0;
|
||||
@@ -232,7 +234,7 @@ export class HBAOPass extends SettingPass {
|
||||
}
|
||||
|
||||
const inputRT = this.lastPass!.slotName(camera, 0);
|
||||
const inputDS = passContext.forwardPass.slotName(camera, 1);
|
||||
const inputDS = this.lastPass!.slotName(camera, 1);
|
||||
const hbaoInfo = this._renderHBAOPass(camera, inputDS);
|
||||
let hbaoCombinedInputRTName = hbaoInfo.rtName;
|
||||
if (this.setting.needBlur) {
|
||||
@@ -247,7 +249,6 @@ export class HBAOPass extends SettingPass {
|
||||
const cameraID = getCameraUniqueID(camera);
|
||||
|
||||
const passIdx = this.HBAO_PASS_INDEX;
|
||||
passContext.material = this.material;
|
||||
this.material.setProperty('uvDepthToEyePosParams', this._hbaoParams.uvDepthToEyePosParams, passIdx);
|
||||
this.material.setProperty('radiusParam', this._hbaoParams.radiusParam, passIdx);
|
||||
this.material.setProperty('miscParam', this._hbaoParams.miscParam, passIdx);
|
||||
@@ -331,7 +332,7 @@ export class HBAOPass extends SettingPass {
|
||||
passIdx);
|
||||
this.material.setProperty('blurParam', this._hbaoParams.blurParam, passIdx);
|
||||
|
||||
passContext.clearBlack();
|
||||
passContext.clearFlag = ClearFlagBit.NONE;
|
||||
|
||||
const layoutName = 'combine-pass';
|
||||
const passName = `CameraHBAOCombinedPass${cameraID}`;
|
||||
|
||||
Reference in New Issue
Block a user