fix post processing shader flip Y (#15205)

This commit is contained in:
jk20012001
2023-05-26 18:00:31 +08:00
committed by GitHub
parent df1d7ee221
commit 2bbaebf30f
12 changed files with 50 additions and 80 deletions
+6 -6
View File
@@ -52,11 +52,11 @@ export enum AntiAliasing {
FXAAHQ,
}
function GetRTFormatBeforeToneMapping (ppl: BasicPipeline) {
function getRTFormatBeforeToneMapping (ppl: BasicPipeline) {
const useFloatOutput = ppl.getMacroBool('CC_USE_FLOAT_OUTPUT');
return ppl.pipelineSceneData.isHDR && useFloatOutput && supportsRGBA16FloatTexture(ppl.device) ? Format.RGBA16F : Format.RGBA8;
}
function ForceEnableFloatOutput (ppl: BasicPipeline) {
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);
@@ -539,7 +539,7 @@ export function buildForwardPass (camera: Camera,
if (!isOffScreen) {
ppl.addRenderWindow(forwardPassRTName, Format.BGRA8, width, height, camera.window);
} else {
ppl.addRenderTarget(forwardPassRTName, GetRTFormatBeforeToneMapping(ppl), width, height, ResourceResidency.PERSISTENT);
ppl.addRenderTarget(forwardPassRTName, getRTFormatBeforeToneMapping(ppl), width, height, ResourceResidency.PERSISTENT);
}
ppl.addDepthStencil(forwardPassDSName, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED);
}
@@ -1459,7 +1459,7 @@ function _buildSSSSBlurPass (camera: Camera,
const ssssBlurRTName = `dsSSSSBlurColor${cameraName}`;
const ssssBlurDSName = `dsSSSSBlurDSColor${cameraName}`;
if (!ppl.containsResource(ssssBlurRTName)) {
ppl.addRenderTarget(ssssBlurRTName, GetRTFormatBeforeToneMapping(ppl), width, height, ResourceResidency.MANAGED);
ppl.addRenderTarget(ssssBlurRTName, getRTFormatBeforeToneMapping(ppl), width, height, ResourceResidency.MANAGED);
ppl.addRenderTarget(ssssBlurDSName, Format.RGBA8, width, height, ResourceResidency.MANAGED);
}
ppl.updateRenderTarget(ssssBlurRTName, width, height);
@@ -1782,7 +1782,7 @@ export function buildSSSSPass (camera: Camera,
inputRT: string,
inputDS: string) {
if (hasSkinObject(ppl)) {
ForceEnableFloatOutput(ppl);
forceEnableFloatOutput(ppl);
const blurInfo = _buildSSSSBlurPass(camera, ppl, inputRT, inputDS);
const specularInfo = _buildSpecularPass(camera, ppl, blurInfo.rtName, blurInfo.dsName);
return { rtName: specularInfo.rtName, dsName: specularInfo.dsName };
@@ -2079,7 +2079,7 @@ function _buildHBAOCombinedPass (camera: Camera,
const outputRTName = outputRT;
if (!ppl.containsResource(outputRTName)) {
ppl.addRenderTarget(outputRTName, GetRTFormatBeforeToneMapping(ppl), width, height, ResourceResidency.MANAGED);
ppl.addRenderTarget(outputRTName, getRTFormatBeforeToneMapping(ppl), width, height, ResourceResidency.MANAGED);
}
ppl.updateRenderTarget(outputRTName, width, height);
const hbaoPass = ppl.addRenderPass(width, height, 'combine-pass');
@@ -7,15 +7,15 @@ import { BasicPipeline, Pipeline } from '../../custom/pipeline';
import { passContext } from '../utils/pass-context';
import { Format } from '../../../gfx';
import { supportsRGBA16FloatTexture } from '../../define';
import { macro } from '../../../core';
import { cclegacy, macro } from '../../../core';
let _BasePassID = 0;
export function GetRTFormatBeforeToneMapping (ppl: BasicPipeline) {
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) {
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);
@@ -23,6 +23,11 @@ export function ForceEnableFloatOutput (ppl: BasicPipeline) {
}
}
export function disablePostProcessForDebugView () {
const debugView = cclegacy.director.root.debugView;
return debugView.singleMode as number > 0;
}
export abstract class BasePass {
abstract name: string;
effectName = 'pipeline/post-process/blit-screen';
@@ -7,6 +7,7 @@ import { passContext } from '../utils/pass-context';
import { getSetting, SettingPass } from './setting-pass';
import { Bloom } from '../components';
import { disablePostProcessForDebugView } from './base-pass';
const MAX_BLOOM_FILTER_PASS_NUM = 6;
const BLOOM_DOWNSAMPLEPASS_INDEX = 1;
@@ -15,6 +16,14 @@ const BLOOM_COMBINEPASS_INDEX = BLOOM_UPSAMPLEPASS_INDEX + MAX_BLOOM_FILTER_PASS
export class BloomPass extends SettingPass {
get setting () { return getSetting(Bloom); }
checkEnable (camera: Camera) {
let enable = super.checkEnable(camera);
if (disablePostProcessForDebugView()) {
enable = false;
}
return enable;
}
name = 'BloomPass'
effectName = 'pipeline/post-process/bloom';
outputNames = ['BloomColor']
@@ -7,10 +7,19 @@ import { passContext } from '../utils/pass-context';
import { getSetting, SettingPass } from './setting-pass';
import { ColorGrading } from '../components';
import { disablePostProcessForDebugView } from './base-pass';
export class ColorGradingPass extends SettingPass {
get setting () { return getSetting(ColorGrading); }
checkEnable (camera: Camera) {
let enable = super.checkEnable(camera);
if (disablePostProcessForDebugView()) {
enable = false;
}
return enable;
}
name = 'ColorGradingPass'
effectName = 'pipeline/post-process/color-grading';
outputNames = ['ColorGrading']
@@ -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, GetRTFormatBeforeToneMapping } from './base-pass';
import { BasePass, getRTFormatBeforeToneMapping } from './base-pass';
import { ShadowPass } from './shadow-pass';
export class ForwardPass extends BasePass {
@@ -53,7 +53,7 @@ export class ForwardPass extends BasePass {
passContext
.updatePassViewPort()
.addRenderPass('default', `${this.name}_${cameraID}`)
.addRasterView(slot0, GetRTFormatBeforeToneMapping(ppl), isOffScreen)
.addRasterView(slot0, getRTFormatBeforeToneMapping(ppl), isOffScreen)
.addRasterView(slot1, Format.DEPTH_STENCIL, isOffScreen)
.version();
@@ -28,7 +28,7 @@ import { LightInfo, QueueHint, SceneFlags } from '../../custom';
import { getCameraUniqueID } from '../../custom/define';
import { Pipeline } from '../../custom/pipeline';
import { passContext } from '../utils/pass-context';
import { BasePass, GetRTFormatBeforeToneMapping } from './base-pass';
import { BasePass, getRTFormatBeforeToneMapping } from './base-pass';
import { ShadowPass } from './shadow-pass';
export class ForwardTransparencyPass extends BasePass {
@@ -52,7 +52,7 @@ export class ForwardTransparencyPass extends BasePass {
passContext
.updatePassViewPort()
.addRenderPass('default', `${this.name}_${cameraID}`)
.addRasterView(output, GetRTFormatBeforeToneMapping(ppl), isOffScreen)
.addRasterView(output, getRTFormatBeforeToneMapping(ppl), isOffScreen)
.addRasterView(outputDS, Format.DEPTH_STENCIL, isOffScreen)
.version();
@@ -32,7 +32,7 @@ import { MeshRenderer } from '../../../3d';
import { ShadowPass } from './shadow-pass';
import { SettingPass } from './setting-pass';
import { ForceEnableFloatOutput, GetRTFormatBeforeToneMapping } from './base-pass';
import { forceEnableFloatOutput, getRTFormatBeforeToneMapping } from './base-pass';
export const COPY_INPUT_DS_PASS_INDEX = 0;
export const SSSS_BLUR_X_PASS_INDEX = 1;
@@ -197,7 +197,7 @@ export class SkinPass extends SettingPass {
const inputRT = this.lastPass?.slotName(camera, 0);
const inputDS = this.lastPass?.slotName(camera, 1);
if (hasSkinObject(ppl)) {
ForceEnableFloatOutput(ppl);
forceEnableFloatOutput(ppl);
const blurInfo = this._buildSSSSBlurPass(camera, ppl, inputRT!, inputDS!);
this._buildSpecularPass(camera, ppl, blurInfo.rtName, blurInfo.dsName);
} else {
@@ -248,7 +248,7 @@ export class SkinPass extends SettingPass {
.setPassInput(ssssBlurDSName, 'depthTex')
.setClearFlag(ClearFlagBit.COLOR)
.setClearColor(0, 0, 0, 1)
.addRasterView(ssssBlurRTName, GetRTFormatBeforeToneMapping(ppl))
.addRasterView(ssssBlurRTName, getRTFormatBeforeToneMapping(ppl))
.setClearFlag(ClearFlagBit.NONE)
.setClearDepthColor(camera.clearDepth, camera.clearStencil, 0, 0)
.addRasterView(inputDS, Format.DEPTH_STENCIL)
@@ -268,7 +268,7 @@ export class SkinPass extends SettingPass {
.setPassInput(ssssBlurDSName, 'depthTex')
.setClearFlag(ClearFlagBit.NONE)
.setClearColor(0, 0, 0, 1)
.addRasterView(inputRT, GetRTFormatBeforeToneMapping(ppl))
.addRasterView(inputRT, getRTFormatBeforeToneMapping(ppl))
.setClearFlag(ClearFlagBit.NONE)
.setClearDepthColor(camera.clearDepth, camera.clearStencil, 0, 0)
.addRasterView(inputDS, Format.DEPTH_STENCIL)
@@ -289,7 +289,7 @@ export class SkinPass extends SettingPass {
.addRenderPass(layoutName, passName)
.setClearFlag(ClearFlagBit.NONE)
.setClearColor(0, 0, 0, 1)
.addRasterView(inputRT, GetRTFormatBeforeToneMapping(ppl), true)
.addRasterView(inputRT, getRTFormatBeforeToneMapping(ppl), true)
.setClearFlag(ClearFlagBit.NONE)
.setClearDepthColor(camera.clearDepth, camera.clearStencil, 0, 1)
.addRasterView(inputDS, Format.DEPTH_STENCIL, true)
@@ -7,6 +7,7 @@ import { Pipeline, ResourceResidency } from '../../custom';
import { getCameraUniqueID } from '../../custom/define';
import { TAA } from '../components/taa';
import { passContext } from '../utils/pass-context';
import { disablePostProcessForDebugView } from './base-pass';
import { getSetting, SettingPass } from './setting-pass';
const tempVec4 = new Vec4();
@@ -98,6 +99,9 @@ export class TAAPass extends SettingPass {
if (EDITOR && camera.cameraUsage === CameraUsage.PREVIEW) {
enable = false;
}
if (disablePostProcessForDebugView()) {
enable = false;
}
return enable;
}
@@ -146,10 +150,6 @@ export class TAAPass extends SettingPass {
firstRender = true;
public render (camera: Camera, ppl: Pipeline): void {
if (!this.checkEnable(camera)) {
return;
}
const cameraID = getCameraUniqueID(camera);
passContext.clearFlag = ClearFlagBit.COLOR;
@@ -3,7 +3,7 @@ CCEffect %{
techniques:
- name: fxaa
passes:
- vert: fxaa-vs:vert
- vert: fxaa-vs
frag: fxaa-edge-fs:frag
pass: fxaa
depthStencilState:
@@ -14,18 +14,7 @@ CCEffect %{
}%
CCProgram fxaa-vs %{
precision highp float;
#include <builtin/uniforms/cc-global>
in vec2 a_position;
in vec2 a_texCoord;
out vec2 v_uv;
vec4 vert () {
vec4 pos = vec4(a_position, 0.0, 1.0);
v_uv = a_texCoord;
return pos;
}
#include <./chunks/vs>
}%
CCProgram fxaa-edge-fs %{
@@ -44,21 +44,7 @@ CCEffect %{
}%
CCProgram hbao-vs %{
precision highp float;
#include <legacy/decode-standard>
#include <builtin/uniforms/cc-global>
#include <common/common-define>
out vec2 v_uv;
void main () {
StandardVertInput In;
CCDecode(In);
CC_HANDLE_GET_CLIP_FLIP(In.position.xy);
gl_Position = In.position;
gl_Position.y = gl_Position.y;
v_uv = a_texCoord;
}
#include <./chunks/vs>
}%
CCProgram hbao-fs %{
@@ -29,21 +29,7 @@ CCEffect %{
}%
CCProgram blur-vs %{
precision highp float;
#include <legacy/input-standard>
#include <builtin/uniforms/cc-global>
#include <common/common-define>
out vec2 v_uv;
void main () {
StandardVertInput In;
CCVertInput(In);
CC_HANDLE_GET_CLIP_FLIP(In.position.xy);
gl_Position = In.position;
gl_Position.y = gl_Position.y;
v_uv = a_texCoord;
}
#include <./post-process/chunks/vs>
}%
CCProgram copy-fs %{
@@ -14,21 +14,7 @@ CCEffect %{
}%
CCProgram tonemap-vs %{
precision highp float;
#include <legacy/decode-standard>
#include <builtin/uniforms/cc-global>
#include <common/common-define>
out vec2 v_uv;
void main () {
StandardVertInput In;
CCDecode(In);
CC_HANDLE_GET_CLIP_FLIP(In.position.xy);
gl_Position = In.position;
gl_Position.y = gl_Position.y;
v_uv = a_texCoord;
}
#include <./post-process/chunks/vs>
}%
CCProgram tonemap-fs %{