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

refine post process #15566

Merged
merged 1 commit into from
Jun 29, 2023
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
2 changes: 2 additions & 0 deletions cocos/misc/camera-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
*/
@type(FOVAxis)
@displayOrder(7)
@visible(function (this: Camera) {

Check warning on line 315 in cocos/misc/camera-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
return this._projection === ProjectionType.PERSPECTIVE;
})
@tooltip('i18n:camera.fov_axis')
Expand All @@ -334,7 +334,7 @@
* @zh 相机的视角大小。
*/
@displayOrder(8)
@visible(function (this: Camera) {

Check warning on line 337 in cocos/misc/camera-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
return this._projection === ProjectionType.PERSPECTIVE;
})
@range([1, 180, 1])
Expand All @@ -353,7 +353,7 @@
* @zh 正交模式下的相机视角高度。
*/
@displayOrder(9)
@visible(function (this: Camera) {

Check warning on line 356 in cocos/misc/camera-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
return this._projection === ProjectionType.ORTHO;
})
@rangeMin(1)
Expand Down Expand Up @@ -490,6 +490,7 @@
this.node.emit(Camera.TARGET_TEXTURE_CHANGE, this);
}

@tooltip('i18n:camera.use_postprocess')
@property
get usePostProcess () {
return this._usePostProcess;
Expand All @@ -501,6 +502,7 @@
}
}

@tooltip('i18n:camera.postprocess')
@type(PostProcess)
get postProcess () {
return this._postProcess;
Expand Down
15 changes: 15 additions & 0 deletions cocos/rendering/post-process/components/blit-screen.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EDITOR } from 'internal:constants';
import { Material } from '../../../asset/assets';
import { property } from '../../../core/data/class-decorator';
import { ccclass, disallowMultiple, executeInEditMode, menu } from '../../../core/data/decorators';
Expand Down Expand Up @@ -33,6 +34,15 @@ export class BlitScreen extends PostProcessSetting {
}
set activeMaterials (v) {
this._activeMaterials = v;
for (let i = 0; i < this._materials.length; i++) {
for (let j = 0; j < v.length; j++) {
if (this._materials[i] && v[j]) {
if (this._materials[i].material?.uuid === v[j].uuid) {
this._materials[i].material = v[j];
}
}
}
}
}

@property(BlitScreenMaterial)
Expand All @@ -44,6 +54,11 @@ export class BlitScreen extends PostProcessSetting {
}
set materials (v) {
this._materials = v;
if (EDITOR) {
setTimeout(() => {
globalThis.cce.Engine.repaintInEditMode();
}, 50);
}
this.updateActiveMateirals();
}

Expand Down
7 changes: 4 additions & 3 deletions cocos/rendering/post-process/components/fsr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CCFloat } from '../../../core';
import { type } from '../../../core/data/class-decorator';
import { ccclass, disallowMultiple, executeInEditMode, menu, range, serializable, slide } from '../../../core/data/decorators';
import { ccclass, disallowMultiple, executeInEditMode, menu, range, serializable, slide, tooltip } from '../../../core/data/decorators';
import { PostProcessSetting } from './post-process-setting';

@ccclass('cc.FSR')
Expand All @@ -9,10 +9,11 @@ import { PostProcessSetting } from './post-process-setting';
@executeInEditMode
export class FSR extends PostProcessSetting {
@serializable
_sharpness = 0.2
_sharpness = 0.8

@tooltip('i18n:fsr.sharpness')
@slide
@range([0.05, 1, 0.01])
@range([0.0, 1, 0.01])
@type(CCFloat)
get sharpness () {
return this._sharpness;
Expand Down
5 changes: 4 additions & 1 deletion cocos/rendering/post-process/components/post-process.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EDITOR } from 'internal:constants';
import { property } from '../../../core/data/class-decorator';
import { ccclass, disallowMultiple, executeInEditMode, range, slide } from '../../../core/data/decorators';
import { ccclass, disallowMultiple, executeInEditMode, range, slide, tooltip } from '../../../core/data/decorators';
import { Director, director } from '../../../game';
import { Component } from '../../../scene-graph';
import { PostProcessSetting } from './post-process-setting';
Expand All @@ -11,11 +11,13 @@ import { PostProcessSetting } from './post-process-setting';
export class PostProcess extends Component {
static all: PostProcess[] = []

@tooltip('i18n:postprocess.global')
@property
global = true;

@property
_shadingScale = 1
@tooltip('i18n:postprocess.shadingScale')
@slide
@range([0.01, 1, 0.01])
@property
Expand All @@ -31,6 +33,7 @@ export class PostProcess extends Component {
}
}

@tooltip('i18n:postprocess.enableShadingScaleInEditor')
@property
enableShadingScaleInEditor = false;

Expand Down
27 changes: 24 additions & 3 deletions cocos/rendering/post-process/components/taa.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { property } from '../../../core/data/class-decorator';
import { ccclass, disallowMultiple, executeInEditMode, menu } from '../../../core/data/decorators';
import { ccclass, disallowMultiple, executeInEditMode, menu, range, slide, tooltip } from '../../../core/data/decorators';
import { PostProcessSetting } from './post-process-setting';

@ccclass('cc.TAA')
Expand All @@ -8,8 +8,29 @@ import { PostProcessSetting } from './post-process-setting';
@executeInEditMode
export class TAA extends PostProcessSetting {
@property
sampleScale = 1
_sampleScale = 1

@tooltip('i18n:taa.sampleScale')
@slide
@range([0.01, 5, 0.01])
@property
feedback = 0.95
get sampleScale () {
return this._sampleScale;
}
set sampleScale (v) {
this._sampleScale = v;
}

@property
_feedback = 0.95
@tooltip('i18n:taa.feedback')
@slide
@range([0.0, 1, 0.01])
@property
get feedback () {
return this._feedback;
}
set feedback (v) {
this._feedback = v;
}
}
4 changes: 2 additions & 2 deletions cocos/rendering/post-process/passes/fsr-pass.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EDITOR } from 'internal:constants';
import { Vec4 } from '../../../core';
import { clamp, Vec4 } from '../../../core';
import { Format } from '../../../gfx';
import { Camera, CameraUsage } from '../../../render-scene/scene';
import { Pipeline } from '../../custom/pipeline';
Expand Down Expand Up @@ -39,7 +39,7 @@ export class FSRPass extends SettingPass {
const outHeight = Math.floor(game.canvas!.height);

const setting = this.setting;
this.material.setProperty('fsrParams', new Vec4(setting.sharpness, 0, 0, 0));
this.material.setProperty('fsrParams', new Vec4(clamp(1.0 - setting.sharpness, 0.02, 0.98), 0, 0, 0));
this.material.setProperty('texSize',
new Vec4(
inputWidth, inputHeight,
Expand Down
14 changes: 14 additions & 0 deletions editor/i18n/en/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ module.exports = link(mixin({
ISO: 'Camera ISO, controls the exposure parameter',
rect: 'The size of the viewport that this camera will eventually render to the screen.',
target_texture: 'Output render texture of the camera. Default to null, which outputs directly to screen',
use_postprocess: 'Whether this camera should use post process.',
postprocess: 'If camera post process is not specified, will use the global post process.',
},
lights: {
color: 'Color of the light',
Expand Down Expand Up @@ -1279,6 +1281,18 @@ module.exports = link(mixin({
color_grading: {
originalMap: 'Support arbitary LUT for Nx1 blocks or 8x8 blocks automatically. The builtin lut texture path is internal/dependencies/textures/lut/.',
},
taa: {
sampleScale: 'TAA sample range.',
feedback: 'History frame blend value.',
},
fsr: {
sharpness: 'Sharpness',
},
postprocess: {
global: 'Whether the post process is enabled for all post process camera.',
shadingScale: 'Rendering resolution.',
enableShadingScaleInEditor: 'Enable Shading Scale In Editor',
},
},

require('./animation'),
Expand Down
14 changes: 14 additions & 0 deletions editor/i18n/zh/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ module.exports = link(mixin({
ISO: '相机感光度,影响相机的曝光参数',
rect: '此相机最终渲染到屏幕上的视口位置和大小',
target_texture: '指定此相机的渲染输出目标贴图,默认为空,直接渲染到屏幕',
use_postprocess: '此相机是否需要使用后效。',
postprocess: '如果后效没有被指定,将使用全局后效。',
},
lights: {
color: '光源颜色',
Expand Down Expand Up @@ -1260,6 +1262,18 @@ module.exports = link(mixin({
color_grading: {
originalMap: '支持任意Nx1的长条图和8x8的方块图,系统自动适配。内置lut贴图路径internal/dependencies/textures/lut/',
},
taa: {
sampleScale: 'TAA 采样范围。',
feedback: '历史帧混合值。',
},
fsr: {
sharpness: '画面锐化度',
},
postprocess: {
global: '是否对所有后效摄像机开启此后效流程',
shadingScale: '渲染分辨率',
enableShadingScaleInEditor: '是否在编辑器中缩放渲染分辨率',
},
},

require('./animation'),
Expand Down
Loading