From 9a4693e8f2a114bc59bd79a17b0ed971b2211f27 Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Thu, 29 Aug 2024 11:29:55 +0800 Subject: [PATCH 1/5] Fix the issue where post-processing modifications after rendering are ineffective. (#17586) * Fix the issue where post-processing modifications after rendering are ineffective. * Removes the intensity edit slot for bloom effect --- cocos/rendering/custom/define.ts | 27 +++++-------------- cocos/rendering/custom/executor.ts | 2 +- .../builtin-pipeline-settings.ts | 6 ----- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/cocos/rendering/custom/define.ts b/cocos/rendering/custom/define.ts index 57d6f8ce916..d1fab1136e6 100644 --- a/cocos/rendering/custom/define.ts +++ b/cocos/rendering/custom/define.ts @@ -448,16 +448,7 @@ export function getDescBindingFromName (bindingName: string): number { return -1; } -const uniformMap: Map = new Map(); -const buffHashMap: Map = new Map(); -function numsHash (arr: number[]): number { - let hash = 0; - for (let i = 0; i < arr.length; i++) { - hash = hashCombineNum(arr[i], hash); - } - return hash; -} - +const uniformMap: Map = new Map(); class DescBuffManager { private buffers: Buffer[] = []; private currBuffIdx: number = 0; @@ -484,20 +475,14 @@ class DescBuffManager { updateBuffer (bindId: number, vals: number[], layout: string, setData: DescriptorSetData): void { const descriptorSet = setData.descriptorSet!; const buffer = this.getCurrentBuffer(); - const uniformKey = `${layout}${bindId}${this.currBuffIdx}`; - let currUniform = uniformMap.get(uniformKey); - const currHash = numsHash(vals); + let currUniform = uniformMap.get(buffer); if (!currUniform) { currUniform = new Float32Array(vals); - uniformMap.set(uniformKey, currUniform); - } - const destHash = buffHashMap.get(buffer); - if (destHash !== currHash) { - currUniform.set(vals); - buffer.update(currUniform); - bindGlobalDesc(descriptorSet, bindId, buffer); - buffHashMap.set(buffer, currHash); + uniformMap.set(buffer, currUniform); } + currUniform.set(vals); + buffer.update(currUniform); + bindGlobalDesc(descriptorSet, bindId, buffer); } } diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index 2f0f5d06214..3ee34800fce 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -1995,7 +1995,7 @@ class PreRenderVisitor extends BaseRenderVisitor implements RenderGraphVisitor { if (!this.rg.getValid(this.sceneID)) return; const renderQueue = this.currQueue as DeviceRenderQueue; const graphScene = context.pools.addGraphScene(); - graphScene.init(null, value, -1); + graphScene.init(null, value, this.sceneID); const renderScene = renderQueue.addScene(graphScene); renderScene.preRecord(); } diff --git a/editor/assets/default_renderpipeline/builtin-pipeline-settings.ts b/editor/assets/default_renderpipeline/builtin-pipeline-settings.ts index 8b02a4affa5..2f3fd0e0e12 100644 --- a/editor/assets/default_renderpipeline/builtin-pipeline-settings.ts +++ b/editor/assets/default_renderpipeline/builtin-pipeline-settings.ts @@ -327,12 +327,6 @@ export class BuiltinPipelineSettings extends Component { return this._settings.bloom.threshold; } - @property({ - tooltip: 'i18n:bloom.intensity', - group: { id: 'Bloom', name: 'Bloom (PostProcessing)', style: 'section' }, - type: CCFloat, - min: 0, - }) set bloomIntensity(value: number) { this._settings.bloom.intensity = value; } From 6fe9ff7261bf2d3f61e6312d76c90cf07a32f156 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Thu, 29 Aug 2024 11:30:41 +0800 Subject: [PATCH 2/5] fix reflection probe bake and planar reflection error in editor (#17584) --- cocos/rendering/custom/executor.ts | 1 + cocos/rendering/custom/scene-culling.ts | 2 +- cocos/rendering/custom/web-pipeline-types.ts | 20 +++++++++++-------- .../builtin-pipeline.ts | 6 ++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index 3ee34800fce..8338a7985f4 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -1446,6 +1446,7 @@ class DeviceRenderScene implements RecordingInterface { const renderQueueDesc = sceneCulling.renderQueueIndex.get(this.graphScene.sceneID)!; const renderQueue = sceneCulling.renderQueues[renderQueueDesc.renderQueueTarget]; const graphSceneData = this.graphScene.scene!; + if (bool(graphSceneData.flags & SceneFlags.REFLECTION_PROBE)) renderQueue.probeQueue.applyMacro(); renderQueue.recordCommands(context.commandBuffer, this._renderPass); if (bool(graphSceneData.flags & SceneFlags.REFLECTION_PROBE)) renderQueue.probeQueue.removeMacro(); if (graphSceneData.flags & SceneFlags.GEOMETRY) { diff --git a/cocos/rendering/custom/scene-culling.ts b/cocos/rendering/custom/scene-culling.ts index 8a0ceeeaaf5..40354f01797 100644 --- a/cocos/rendering/custom/scene-culling.ts +++ b/cocos/rendering/custom/scene-culling.ts @@ -254,7 +254,7 @@ function addRenderObject ( ): void { const probeQueue = queue.probeQueue; if (isDrawProbe) { - probeQueue.applyMacro(model, phaseLayoutId); + probeQueue.addToProbeQueue(model, phaseLayoutId); } const subModels = model.subModels; const subModelCount = subModels.length; diff --git a/cocos/rendering/custom/web-pipeline-types.ts b/cocos/rendering/custom/web-pipeline-types.ts index 66a357cc1e3..7bbc9be648a 100644 --- a/cocos/rendering/custom/web-pipeline-types.ts +++ b/cocos/rendering/custom/web-pipeline-types.ts @@ -225,6 +225,17 @@ export class ProbeHelperQueue { this.probeMap.length = 0; } + applyMacro (): void { + for (const subModel of this.probeMap) { + let patches: IMacroPatch[] = [ + { name: CC_USE_RGBE_OUTPUT, value: true }, + ]; + if (subModel.patches) { + patches = patches.concat(subModel.patches); + } + subModel.onMacroPatchesStateChanged(patches); + } + } removeMacro (): void { for (const subModel of this.probeMap) { if (!subModel.patches) continue; @@ -238,7 +249,7 @@ export class ProbeHelperQueue { } } } - applyMacro (model: Model, probeLayoutId: number): void { + addToProbeQueue (model: Model, probeLayoutId: number): void { const subModels = model.subModels; for (let j = 0; j < subModels.length; j++) { const subModel: SubModel = subModels[j]; @@ -258,13 +269,6 @@ export class ProbeHelperQueue { } if (passIdx < 0) { continue; } if (!bUseReflectPass) { - let patches: IMacroPatch[] = []; - patches = patches.concat(subModel.patches!); - const useRGBEPatchs: IMacroPatch[] = [ - { name: CC_USE_RGBE_OUTPUT, value: true }, - ]; - patches = patches.concat(useRGBEPatchs); - subModel.onMacroPatchesStateChanged(patches); this.probeMap.push(subModel); } } diff --git a/editor/assets/default_renderpipeline/builtin-pipeline.ts b/editor/assets/default_renderpipeline/builtin-pipeline.ts index 25e82886d65..1ee29f85794 100644 --- a/editor/assets/default_renderpipeline/builtin-pipeline.ts +++ b/editor/assets/default_renderpipeline/builtin-pipeline.ts @@ -154,6 +154,7 @@ class CameraConfigs { enableFXAA = false; enableFSR = false; enableHDR = false; + enablePlanarReflectionProbe = false; useFullPipeline = false; singleForwardRadiancePass = false; radianceFormat = gfx.Format.RGBA8; @@ -212,6 +213,8 @@ function setupCameraConfigs( && !!camera.scene.mainLight && camera.scene.mainLight.shadowEnabled; + cameraConfigs.enablePlanarReflectionProbe = isMainGameWindow || camera.cameraUsage === CameraUsage.SCENE_VIEW; + cameraConfigs.enableProfiler = DEBUG && isMainGameWindow; cameraConfigs.settings = camera.pipelineSettings @@ -1506,6 +1509,9 @@ if (rendering) { const height = Math.max(Math.floor(area.y), 1); if (probe.probeType === renderer.scene.ProbeType.PLANAR) { + if (!this._cameraConfigs.enablePlanarReflectionProbe) { + continue; + } const window: renderer.RenderWindow = probe.realtimePlanarTexture!.window!; const colorName = `PlanarProbeRT${probeID}`; const depthStencilName = `PlanarProbeDS${probeID}`; From 3ad291ac10da1b2189687385176dd3ced065e823 Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Tue, 3 Sep 2024 14:01:38 +0800 Subject: [PATCH 3/5] [Optimized] upload buffer (#17595) * [Optimized] upload buffer * Dual buffer --- cocos/rendering/custom/define.ts | 65 +++++++++++++++++------------- cocos/rendering/custom/executor.ts | 11 ++++- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/cocos/rendering/custom/define.ts b/cocos/rendering/custom/define.ts index d1fab1136e6..119dd7eccdd 100644 --- a/cocos/rendering/custom/define.ts +++ b/cocos/rendering/custom/define.ts @@ -448,15 +448,17 @@ export function getDescBindingFromName (bindingName: string): number { return -1; } -const uniformMap: Map = new Map(); class DescBuffManager { private buffers: Buffer[] = []; private currBuffIdx: number = 0; private device: Device; + public currUniform: Float32Array; + private _root; constructor (bufferSize: number, numBuffers: number = 2) { - const root = cclegacy.director.root; + const root = this._root = cclegacy.director.root; const device = root.device; this.device = device; + this.currUniform = new Float32Array(bufferSize / 4); for (let i = 0; i < numBuffers; i++) { const bufferInfo: BufferInfo = new BufferInfo( BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST, @@ -468,36 +470,33 @@ class DescBuffManager { } } getCurrentBuffer (): Buffer { - const root = cclegacy.director.root; - this.currBuffIdx = root.frameCount % this.buffers.length; + this.currBuffIdx = this._root.frameCount % this.buffers.length; return this.buffers[this.currBuffIdx]; } - updateBuffer (bindId: number, vals: number[], layout: string, setData: DescriptorSetData): void { + updateData (vals: number[]): void { + this.currUniform.set(vals); + } + updateBuffer (bindId: number, setData: DescriptorSetData): void { const descriptorSet = setData.descriptorSet!; const buffer = this.getCurrentBuffer(); - let currUniform = uniformMap.get(buffer); - if (!currUniform) { - currUniform = new Float32Array(vals); - uniformMap.set(buffer, currUniform); - } - currUniform.set(vals); - buffer.update(currUniform); + buffer.update(this.currUniform); bindGlobalDesc(descriptorSet, bindId, buffer); } } const buffsMap: Map = new Map(); - -function updateGlobalDescBuffer (blockId: number, sceneId: number, vals: number[], layout: string, setData: DescriptorSetData): void { +const currBindBuffs: Map = new Map(); +function updateGlobalDescBuffer (blockId: number, sceneId: number, idxRD: number, vals: number[], setData: DescriptorSetData): void { const bindId = getDescBinding(blockId, setData); if (bindId === -1) { return; } - const descKey = `${blockId}${bindId}${sceneId}`; + const descKey = `${blockId}${bindId}${idxRD}${sceneId}`; + currBindBuffs.set(descKey, bindId); let currDescBuff = buffsMap.get(descKey); if (!currDescBuff) { - buffsMap.set(descKey, new DescBuffManager(vals.length * 4)); + buffsMap.set(descKey, new DescBuffManager(vals.length * 4, 2)); currDescBuff = buffsMap.get(descKey); } - currDescBuff!.updateBuffer(bindId, vals, layout, setData); + currDescBuff!.updateData(vals); } const layouts: Map = new Map(); @@ -522,8 +521,8 @@ export function getDescriptorSetDataFromLayoutId (id: number): DescriptorSetData return layoutData; } -export function updateGlobalDescBinding (data: RenderData, sceneId: number, layoutName = 'default'): void { - updatePerPassUBO(layoutName, sceneId, data); +export function updateGlobalDescBinding (data: RenderData, sceneId: number, idxRD: number, layoutName = 'default'): void { + updatePerPassUBO(layoutName, sceneId, idxRD, data); } function getUniformBlock (block: string, layoutName: string): UniformBlock | undefined { @@ -557,15 +556,20 @@ class ConstantBlockInfo { blockId: number = -1; } const constantBlockMap: Map = new Map(); -function copyToConstantBuffer (target: number[], val: number[], offset: number): void { +function copyToConstantBuffer (target: number[], val: number[], offset: number): boolean { + let isImparity = false; if (offset < 0 || offset > target.length) { - throw new Error('Offset is out of the bounds of the target array.'); + return isImparity; } const length = Math.min(val.length, target.length - offset); for (let i = 0; i < length; i++) { - target[offset + i] = val[i]; + if (target[offset + i] !== val[i]) { + target[offset + i] = val[i]; + isImparity = true; + } } + return isImparity; } function addConstantBuffer (block: string, layout: string): number[] | null { @@ -587,7 +591,7 @@ function addConstantBuffer (block: string, layout: string): number[] | null { uniformBlockMap.set(block, buffers); return buffers; } -export function updatePerPassUBO (layout: string, sceneId: number, user: RenderData): void { +export function updatePerPassUBO (layout: string, sceneId: number, idxRD: number, user: RenderData): void { const constantMap = user.constants; const samplers = user.samplers; const textures = user.textures; @@ -595,6 +599,7 @@ export function updatePerPassUBO (layout: string, sceneId: number, user: RenderD const webPip = cclegacy.director.root.pipeline as WebPipeline; const lg = webPip.layoutGraph; const descriptorSetData = getDescriptorSetDataFromLayout(layout)!; + currBindBuffs.clear(); for (const [key, data] of constantMap) { let constantBlock = constantBlockMap.get(key); if (!constantBlock) { @@ -607,7 +612,7 @@ export function updatePerPassUBO (layout: string, sceneId: number, user: RenderD if (offset === -1) { // Although the current uniformMem does not belong to the current uniform block, // it does not mean that it should not be bound to the corresponding descriptor. - updateGlobalDescBuffer(blockId, sceneId, constantBuff, layout, descriptorSetData); + updateGlobalDescBuffer(blockId, sceneId, idxRD, constantBuff, descriptorSetData); continue; } constantBlockMap.set(key, new ConstantBlockInfo()); @@ -615,12 +620,12 @@ export function updatePerPassUBO (layout: string, sceneId: number, user: RenderD constantBlock.buffer = constantBuff; constantBlock.blockId = blockId; constantBlock.offset = offset; - copyToConstantBuffer(constantBuff, data, offset); - updateGlobalDescBuffer(blockId, sceneId, constantBuff, layout, descriptorSetData); + const isImparity = copyToConstantBuffer(constantBuff, data, offset); + if (isImparity) updateGlobalDescBuffer(blockId, sceneId, idxRD, constantBuff, descriptorSetData); } } else { - copyToConstantBuffer(constantBlock.buffer, data, constantBlock.offset); - updateGlobalDescBuffer(constantBlock.blockId, sceneId, constantBlock.buffer, layout, descriptorSetData); + const isImparity = copyToConstantBuffer(constantBlock.buffer, data, constantBlock.offset); + if (isImparity) updateGlobalDescBuffer(constantBlock.blockId, sceneId, idxRD, constantBlock.buffer, descriptorSetData); } } @@ -643,6 +648,10 @@ export function updatePerPassUBO (layout: string, sceneId: number, user: RenderD bindGlobalDesc(descriptorSet, bindId, value); } } + for (const [key, value] of currBindBuffs) { + const buffManager = buffsMap.get(key)!; + buffManager.updateBuffer(value, descriptorSetData); + } for (const [key, value] of buffers) { const bindId = getDescBinding(key, descriptorSetData); if (bindId === -1) { continue; } diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index 8338a7985f4..ce2fbf3efb2 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -808,6 +808,7 @@ class DeviceRenderPass implements RecordingInterface { protected _viewport: Viewport | null = null; private _rasterInfo: RasterPassInfo; private _layout: RenderPassLayoutInfo | null = null; + private _idxOfRenderData: number = 0; constructor (passInfo: RasterPassInfo) { this._rasterInfo = passInfo; const device = context.device; @@ -909,6 +910,7 @@ class DeviceRenderPass implements RecordingInterface { swapchain ? swapchain.depthStencilTexture : depthTex, )); } + get indexOfRD (): number { return this._idxOfRenderData; } get layoutName (): string { return this._layoutName; } get passID (): number { return this._passID; } get renderLayout (): RenderPassLayoutInfo | null { return this._layout; } @@ -920,6 +922,9 @@ class DeviceRenderPass implements RecordingInterface { get deviceQueues (): Map { return this._deviceQueues; } get rasterPassInfo (): RasterPassInfo { return this._rasterInfo; } get viewport (): Viewport | null { return this._viewport; } + addIdxOfRD (): void { + this._idxOfRenderData++; + } visitResource (resName: string): void { const resourceGraph = context.resourceGraph; const vertId = resourceGraph.vertex(resName); @@ -1040,6 +1045,7 @@ class DeviceRenderPass implements RecordingInterface { this._layoutName = context.renderGraph.getLayout(id); this._passID = cclegacy.rendering.getPassID(this._layoutName); this._deviceQueues.clear(); + this._idxOfRenderData = 0; let framebuffer: Framebuffer | null = null; const colTextures: Texture[] = []; const currFramebuffer = this._framebuffer; @@ -1234,7 +1240,7 @@ class DeviceComputePass implements RecordingInterface { queue.record(); } const renderData = context.renderGraph.getData(this._computeInfo.id); - updateGlobalDescBinding(renderData, -1, context.renderGraph.getLayout(this._computeInfo.id)); + updateGlobalDescBinding(renderData, -1, 0, context.renderGraph.getLayout(this._computeInfo.id)); } resetResource (id: number, pass: ComputePass): void { @@ -1392,7 +1398,8 @@ class DeviceRenderScene implements RecordingInterface { protected _updateGlobal (data: RenderData, sceneId: number): void { const devicePass = this._currentQueue.devicePass; - updateGlobalDescBinding(data, sceneId, context.renderGraph.getLayout(devicePass.rasterPassInfo.id)); + devicePass.addIdxOfRD(); + updateGlobalDescBinding(data, sceneId, devicePass.indexOfRD, context.renderGraph.getLayout(devicePass.rasterPassInfo.id)); } protected _updateRenderData (): void { From a900c7cb568d16fac8db93a007912257fbb0bf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AA=9B=E5=AA=9B?= Date: Tue, 3 Sep 2024 14:03:04 +0800 Subject: [PATCH 4/5] update i18n for render pipeline (#17596) --- editor/i18n/en/localization.js | 12 ++++++------ editor/i18n/zh/localization.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index 9d5c57fdf69..7dc087d9334 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -1105,16 +1105,16 @@ module.exports = link(mixin({ description: "Enable the XR function system", }, custom_pipeline: { - label: "Custom Render Pipeline (Beta)", - description: "Enable custom render pipeline", + label: "Render Pipeline (New)", + description: "The new render pipeline is based on data-oriented render graph. Users can write cross platform render pipelines and optimize for the specific platform.", }, custom_pipeline_post_process: { - label: "Custom Render Pipeline Post Process (Deprecated)", - description: "Enable custom render pipeline post process", + label: "Post Process Module (Deprecated)", + description: "The render pipeline used in previous versions. This pipeline will be deprecated in future versions.", }, legacy_pipeline: { - label: "Legacy Render Pipeline (Deprecated)", - description: "Enable legacy render pipeline", + label: "Render Pipeline (Legacy)", + description: "The render pipeline used in previous versions. This pipeline will be deprecated in future versions.", }, websocket: { label: "WebSocket", diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index 151b8869a65..c1e84f49f52 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -1080,16 +1080,16 @@ module.exports = link(mixin({ description: "启用 XR 功能系统。", }, custom_pipeline: { - label: "自定义渲染管线 (Beta)", - description: "启用自定义渲染管线。", + label: "新渲染管线", + description: "面向数据的Render Graph渲染管线,可以自由构建跨平台的渲染算法,并针对目标平台优化。", }, custom_pipeline_post_process: { - label: "自定义渲染管线的后处理模块 (Deprecated)", - description: "启用自定义渲染管线的后处理模块", + label: "后处理模块(已废弃)", + description: "此选项用于兼容旧项目(Custom管线),新项目请使用 Builtin 自带的后处理流程。", }, legacy_pipeline: { - label: "废弃渲染管线 (Deprecated)", - description: "启用废弃渲染管线。", + label: "原渲染管线", + description: "原有的渲染管线,在后续的版本中会被移除。", }, websocket: { label: "WebSocket", From 3a5898d48839f8ceb2d0d23b422f2113eff5207b Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Tue, 3 Sep 2024 18:10:20 +0800 Subject: [PATCH 5/5] revert changes during pipeline replacing (#17597) --- .../post-process/color-grading.effect | 30 +++++++------------ .../effects/pipeline/post-process/fsr.effect | 10 +++++++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/editor/assets/effects/pipeline/post-process/color-grading.effect b/editor/assets/effects/pipeline/post-process/color-grading.effect index 88eefd6ee33..38195b66a06 100644 --- a/editor/assets/effects/pipeline/post-process/color-grading.effect +++ b/editor/assets/effects/pipeline/post-process/color-grading.effect @@ -8,6 +8,11 @@ CCEffect %{ pass: color-grading-nx1 rasterizerState: &rasterizerState cullMode: none + blendState: &blendState + targets: + - blend: false + blendSrc: one + blendDst: zero depthStencilState: &depthStencilState depthTest: false depthWrite: false @@ -16,6 +21,7 @@ CCEffect %{ pass: color-grading-8x8 rasterizerState: *rasterizerState depthStencilState: *depthStencilState + blendState: *blendState }% CCProgram ubo %{ @@ -35,8 +41,6 @@ CCProgram color-grading-vs %{ CCProgram color-grading-nx1-fs %{ precision highp float; - #include - #include #include in vec2 v_uv; @@ -58,20 +62,13 @@ CCProgram color-grading-nx1-fs %{ layout(location = 0) out vec4 fragColor; void main () { vec4 sceneColor = texture(sceneColorMap, v_uv); - // (Tone mapping + gamma correction) + Color grading - #if CC_USE_FLOAT_OUTPUT - sceneColor.rgb = HDRToLDR(sceneColor.rgb); - sceneColor.rgb = LinearToSRGB(sceneColor.rgb); - #endif vec3 gradeColor = ColorGrading(colorGradingMap, sceneColor.rgb); - fragColor = mix(sceneColor, vec4(gradeColor, sceneColor.a), contribute); + fragColor = mix(sceneColor, vec4(gradeColor, 1.0), contribute); } }% CCProgram color-grading-8x8-fs %{ precision highp float; - #include - #include #include in vec2 v_uv; #define EPS 0.000001 @@ -79,23 +76,18 @@ CCProgram color-grading-8x8-fs %{ #define SIZE 512.0 layout(location = 0) out vec4 fragColor; void main () { - vec4 origColor = texture(sceneColorMap, v_uv); - // (Tone mapping + gamma correction) + Color grading - #if CC_USE_FLOAT_OUTPUT - origColor.rgb = HDRToLDR(origColor.rgb); - origColor.rgb = LinearToSRGB(origColor.rgb); - #endif - float bValue = (origColor.b * 255.0) / 4.0; + vec3 orgColor = texture(sceneColorMap, v_uv).rgb; + float bValue = (orgColor.b * 255.0) / 4.0; vec2 mulB = clamp(floor(bValue) + vec2(0.0, 1.0), 0.0, 63.0); vec2 row = floor(mulB / 8.0 + EPS); vec4 row_col = vec4(row, mulB - row * 8.0); - vec4 lookup = origColor.ggrr * (63.0 / SIZE) + row_col * (TOTAL / SIZE) + (0.5 / SIZE); + vec4 lookup = orgColor.ggrr * (63.0 / SIZE) + row_col * (TOTAL / SIZE) + (0.5 / SIZE); float b1w = bValue - mulB.x; vec3 sampled1 = texture(colorGradingMap, lookup.zx).rgb; vec3 sampled2 = texture(colorGradingMap, lookup.wy).rgb; - fragColor = vec4(mix(origColor.rgb, mix(sampled1, sampled2, b1w), contribute), origColor.a); + fragColor = vec4(mix(orgColor, mix(sampled1, sampled2, b1w), contribute), 1.0); } }% diff --git a/editor/assets/effects/pipeline/post-process/fsr.effect b/editor/assets/effects/pipeline/post-process/fsr.effect index 1b0e5766334..5a088ede8c5 100644 --- a/editor/assets/effects/pipeline/post-process/fsr.effect +++ b/editor/assets/effects/pipeline/post-process/fsr.effect @@ -11,6 +11,11 @@ CCEffect %{ depthStencilState: depthTest: false depthWrite: false + blendState: + targets: + - blend: true + blendSrc: one + blendDst: zero - vert: vs frag: fs-rcas pass: post-process @@ -19,6 +24,11 @@ CCEffect %{ depthStencilState: depthTest: false depthWrite: false + blendState: + targets: + - blend: true + blendSrc: one + blendDst: zero }%