Skip to content

Commit

Permalink
fixed fsr input/output size (#15798)
Browse files Browse the repository at this point in the history
  • Loading branch information
2youyou2 authored Jul 26, 2023
1 parent b9c259e commit 2e2b7ec
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions cocos/rendering/post-process/passes/fsr-pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { FSR } from '../components/fsr';
import { getSetting, SettingPass } from './setting-pass';
import { game } from '../../../game';

const tempVec4 = new Vec4();

export class FSRPass extends SettingPass {
get setting (): FSR { return getSetting(FSR); }

name = 'FSRPass'
name = 'FSRPass';
effectName = 'pipeline/post-process/fsr';
outputNames = ['FSRColor']
outputNames = ['FSRColor'];

checkEnable (camera: Camera): boolean {
let enable = super.checkEnable(camera);
Expand All @@ -31,20 +33,16 @@ export class FSRPass extends SettingPass {
passContext.material = this.material;
passContext.clearBlack();

passContext.updatePassViewPort(1 / passContext.shadingScale);
passContext.updatePassViewPort(1 / passContext.shadingScale, 0);

const inputWidth = Math.floor(game.canvas!.width * passContext.shadingScale);
const inputHeight = Math.floor(game.canvas!.height * passContext.shadingScale);
const outWidth = Math.floor(game.canvas!.width);
const outHeight = Math.floor(game.canvas!.height);
const inputWidth = Math.floor(passContext.passViewport.width * passContext.shadingScale);
const inputHeight = Math.floor(passContext.passViewport.height * passContext.shadingScale);
const outWidth = Math.floor(passContext.passViewport.width);
const outHeight = Math.floor(passContext.passViewport.height);

const setting = this.setting;
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,
outWidth, outHeight,
));
this.material.setProperty('fsrParams', tempVec4.set(clamp(1.0 - setting.sharpness, 0.02, 0.98), 0, 0, 0));
this.material.setProperty('texSize', tempVec4.set(inputWidth, inputHeight, outWidth, outHeight));

const input0 = this.lastPass!.slotName(camera, 0);
const easu = `FSR_EASU${cameraID}`;
Expand Down

0 comments on commit 2e2b7ec

Please sign in to comment.