From 67b8d4b953621445f6f1d8350edff76c9a8d5167 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 23 Aug 2024 14:41:20 +0800 Subject: [PATCH 01/12] rename event name to fix event name conflict with NodeEventType.MOUSE_ENTER/MOUSE_LEAVE (#17576) --- cocos/input/types/event-enum.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/input/types/event-enum.ts b/cocos/input/types/event-enum.ts index 40c0ecb1e8f..e8b8d52e216 100644 --- a/cocos/input/types/event-enum.ts +++ b/cocos/input/types/event-enum.ts @@ -343,14 +343,14 @@ export enum InputEventType { * trigger this event. * @zh 当鼠标离开窗口或者 canvas 时发出该消息。只有 Windows、macOS 或者 PC web 会触发该事件。 */ - MOUSE_LEAVE = 'mouse-leave', + MOUSE_LEAVE = 'mouse-leave-window', /** * @en The event type indicates mouse enters the window or canvas. Only Windows, macOS or web PC can * trigger this event. * @zh 当鼠标进入窗口或者 canvas 时发出该消息。只有 Windows、macOS 或者 PC web 会触发该事件。 */ - MOUSE_ENTER = 'mouse-enter', + MOUSE_ENTER = 'mouse-enter-window', /** * @en From 582e03aaf1e830a61efb18f12325516655884145 Mon Sep 17 00:00:00 2001 From: bofeng-song Date: Tue, 27 Aug 2024 10:11:26 +0800 Subject: [PATCH 02/12] Fix the issue where the cached animationCache object is using a released skeleton object due to asset release. (#17581) --- cocos/spine/skeleton-cache.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cocos/spine/skeleton-cache.ts b/cocos/spine/skeleton-cache.ts index f3e539f8c24..f9ada2e52f9 100644 --- a/cocos/spine/skeleton-cache.ts +++ b/cocos/spine/skeleton-cache.ts @@ -358,6 +358,9 @@ class SkeletonCache { } } + const skeletonInfo = this._skeletonCache[assetUuid]; + if (!skeletonInfo) return; + const sharedOperate = (aniKey: string, animationCache: AnimationCache): void => { this._animationPool[`${assetUuid}#${aniKey}`] = animationCache; animationCache.clear(); @@ -366,9 +369,6 @@ class SkeletonCache { animationCache.destroy(); }; const operate = this._privateMode ? privateOperate : sharedOperate; - - const skeletonInfo = this._skeletonCache[assetUuid]; - if (!skeletonInfo) return; const animationsCache = skeletonInfo.animationsCache; for (const aniKey in animationsCache) { // Clear cache texture, and put cache into pool. @@ -466,6 +466,14 @@ class SkeletonCache { delete animationPool[key]; } } + let skeletonInfo = this._skeletonCache[uuid]; + const skeleton = skeletonInfo && skeletonInfo.skeleton; + if (skeleton) { + spine.wasmUtil.destroySpineSkeleton(skeleton); + } + if (skeletonInfo) { + delete this._skeletonCache[uuid]; + } } else { const animationPool = this._animationPool; for (const key in animationPool) { 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 03/12] 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 04/12] 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 a0cdce8fbbf80ab7f18343601445dd171cc626db Mon Sep 17 00:00:00 2001 From: yoki0805 Date: Sat, 31 Aug 2024 16:03:38 +0800 Subject: [PATCH 05/12] Refine particle-simulator-2d.ts Remove ZERO_VEC2 & clampf. --- cocos/particle-2d/particle-simulator-2d.ts | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cocos/particle-2d/particle-simulator-2d.ts b/cocos/particle-2d/particle-simulator-2d.ts index 9918b20a1d0..649fde3c8cc 100644 --- a/cocos/particle-2d/particle-simulator-2d.ts +++ b/cocos/particle-2d/particle-simulator-2d.ts @@ -22,13 +22,12 @@ THE SOFTWARE. */ -import { Vec2, Color, js, misc, random, IColorLike, Vec4 } from '../core'; +import { Vec2, Color, js, misc, random, IColorLike, Vec4, clamp } from '../core'; import { vfmtPosUvColor, getComponentPerVertex } from '../2d/renderer/vertex-format'; import { PositionType, EmitterMode, START_SIZE_EQUAL_TO_END_SIZE, START_RADIUS_EQUAL_TO_END_RADIUS } from './define'; import { ParticleSystem2D } from './particle-system-2d'; import { MeshRenderData } from '../2d/renderer/render-data'; -const ZERO_VEC2 = new Vec2(0, 0); const _pos = new Vec2(); const _tpa = new Vec2(); const _tpb = new Vec2(); @@ -78,8 +77,8 @@ class ParticlePool extends js.Pool { } const pool = new ParticlePool((par: Particle): void => { - par.pos.set(ZERO_VEC2); - par.startPos.set(ZERO_VEC2); + par.pos.set(Vec2.ZERO); + par.startPos.set(Vec2.ZERO); par.color.set(0, 0, 0, 255); par.deltaColor.r = par.deltaColor.g = par.deltaColor.b = 0; par.deltaColor.a = 255; @@ -88,10 +87,10 @@ const pool = new ParticlePool((par: Particle): void => { par.rotation = 0; par.deltaRotation = 0; par.timeToLive = 0; - par.drawPos.set(ZERO_VEC2); + par.drawPos.set(Vec2.ZERO); par.aspectRatio = 1; // Mode A - par.dir.set(ZERO_VEC2); + par.dir.set(Vec2.ZERO); par.radialAccel = 0; par.tangentialAccel = 0; // Mode B @@ -169,14 +168,14 @@ export class Simulator { const endColor = psys.endColor; const endColorVar = psys.endColorVar; - particle.color.r = sr = misc.clampf(startColor.r + startColorVar.r * (random() - 0.5) * 2, 0, 255); - particle.color.g = sg = misc.clampf(startColor.g + startColorVar.g * (random() - 0.5) * 2, 0, 255); - particle.color.b = sb = misc.clampf(startColor.b + startColorVar.b * (random() - 0.5) * 2, 0, 255); - particle.color.a = sa = misc.clampf(startColor.a + startColorVar.a * (random() - 0.5) * 2, 0, 255); - particle.deltaColor.r = (misc.clampf(endColor.r + endColorVar.r * (random() - 0.5) * 2, 0, 255) - sr) / timeToLive; - particle.deltaColor.g = (misc.clampf(endColor.g + endColorVar.g * (random() - 0.5) * 2, 0, 255) - sg) / timeToLive; - particle.deltaColor.b = (misc.clampf(endColor.b + endColorVar.b * (random() - 0.5) * 2, 0, 255) - sb) / timeToLive; - particle.deltaColor.a = (misc.clampf(endColor.a + endColorVar.a * (random() - 0.5) * 2, 0, 255) - sa) / timeToLive; + particle.color.r = sr = clamp(startColor.r + startColorVar.r * (random() - 0.5) * 2, 0, 255); + particle.color.g = sg = clamp(startColor.g + startColorVar.g * (random() - 0.5) * 2, 0, 255); + particle.color.b = sb = clamp(startColor.b + startColorVar.b * (random() - 0.5) * 2, 0, 255); + particle.color.a = sa = clamp(startColor.a + startColorVar.a * (random() - 0.5) * 2, 0, 255); + particle.deltaColor.r = (clamp(endColor.r + endColorVar.r * (random() - 0.5) * 2, 0, 255) - sr) / timeToLive; + particle.deltaColor.g = (clamp(endColor.g + endColorVar.g * (random() - 0.5) * 2, 0, 255) - sg) / timeToLive; + particle.deltaColor.b = (clamp(endColor.b + endColorVar.b * (random() - 0.5) * 2, 0, 255) - sb) / timeToLive; + particle.deltaColor.a = (clamp(endColor.a + endColorVar.a * (random() - 0.5) * 2, 0, 255) - sa) / timeToLive; // size let startS = psys.startSize + psys.startSizeVar * (random() - 0.5) * 2; From 1b29b4516cde36ffcaaf265924c6b7e476bef49a Mon Sep 17 00:00:00 2001 From: yoki0805 Date: Sat, 31 Aug 2024 16:10:35 +0800 Subject: [PATCH 06/12] Remove misc Remove misc --- cocos/particle-2d/particle-simulator-2d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/particle-2d/particle-simulator-2d.ts b/cocos/particle-2d/particle-simulator-2d.ts index 649fde3c8cc..501ef233ece 100644 --- a/cocos/particle-2d/particle-simulator-2d.ts +++ b/cocos/particle-2d/particle-simulator-2d.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ -import { Vec2, Color, js, misc, random, IColorLike, Vec4, clamp } from '../core'; +import { Vec2, Color, js, random, IColorLike, Vec4, clamp, toRadian, toDegree } from '../core'; import { vfmtPosUvColor, getComponentPerVertex } from '../2d/renderer/vertex-format'; import { PositionType, EmitterMode, START_SIZE_EQUAL_TO_END_SIZE, START_RADIUS_EQUAL_TO_END_RADIUS } from './define'; import { ParticleSystem2D } from './particle-system-2d'; @@ -203,7 +203,7 @@ export class Simulator { particle.aspectRatio = psys.aspectRatio || 1; // direction - const a = misc.degreesToRadians(psys.angle + this._worldRotation + psys.angleVar * (random() - 0.5) * 2); + const a = toRadian(psys.angle + this._worldRotation + psys.angleVar * (random() - 0.5) * 2); // Mode Gravity: A if (psys.emitterMode === EmitterMode.GRAVITY) { const s = psys.speed + psys.speedVar * (random() - 0.5) * 2; @@ -217,7 +217,7 @@ export class Simulator { particle.tangentialAccel = psys.tangentialAccel + psys.tangentialAccelVar * (random() - 0.5) * 2; // rotation is dir if (psys.rotationIsDir) { - particle.rotation = -misc.radiansToDegrees(Math.atan2(particle.dir.y, particle.dir.x)); + particle.rotation = -toDegree(Math.atan2(particle.dir.y, particle.dir.x)); } } else { // Mode Radius: B @@ -227,7 +227,7 @@ export class Simulator { particle.radius = startRadius; particle.deltaRadius = (psys.endRadius === START_RADIUS_EQUAL_TO_END_RADIUS) ? 0 : (endRadius - startRadius) / timeToLive; particle.angle = a; - particle.degreesPerSecond = misc.degreesToRadians(psys.rotatePerS + psys.rotatePerSVar * (random() - 0.5) * 2); + particle.degreesPerSecond = toRadian(psys.rotatePerS + psys.rotatePerSVar * (random() - 0.5) * 2); } } @@ -276,7 +276,7 @@ export class Simulator { const y1 = -halfHeight; const x2 = halfWidth; const y2 = halfHeight; - const rad = -misc.degreesToRadians(particle.rotation as number); + const rad = -toRadian(particle.rotation as number); const cr = Math.cos(rad); const sr = Math.sin(rad); // bl From 6592b242c2e458469289b567b23d9f402d245348 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 23 Aug 2024 14:41:20 +0800 Subject: [PATCH 07/12] rename event name to fix event name conflict with NodeEventType.MOUSE_ENTER/MOUSE_LEAVE (#17576) --- cocos/input/types/event-enum.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/input/types/event-enum.ts b/cocos/input/types/event-enum.ts index 40c0ecb1e8f..e8b8d52e216 100644 --- a/cocos/input/types/event-enum.ts +++ b/cocos/input/types/event-enum.ts @@ -343,14 +343,14 @@ export enum InputEventType { * trigger this event. * @zh 当鼠标离开窗口或者 canvas 时发出该消息。只有 Windows、macOS 或者 PC web 会触发该事件。 */ - MOUSE_LEAVE = 'mouse-leave', + MOUSE_LEAVE = 'mouse-leave-window', /** * @en The event type indicates mouse enters the window or canvas. Only Windows, macOS or web PC can * trigger this event. * @zh 当鼠标进入窗口或者 canvas 时发出该消息。只有 Windows、macOS 或者 PC web 会触发该事件。 */ - MOUSE_ENTER = 'mouse-enter', + MOUSE_ENTER = 'mouse-enter-window', /** * @en From cef1028b4d89b4cd9441fef5d73b0cfc9939a2fe Mon Sep 17 00:00:00 2001 From: bofeng-song Date: Tue, 27 Aug 2024 10:11:26 +0800 Subject: [PATCH 08/12] Fix the issue where the cached animationCache object is using a released skeleton object due to asset release. (#17581) --- cocos/spine/skeleton-cache.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cocos/spine/skeleton-cache.ts b/cocos/spine/skeleton-cache.ts index f3e539f8c24..f9ada2e52f9 100644 --- a/cocos/spine/skeleton-cache.ts +++ b/cocos/spine/skeleton-cache.ts @@ -358,6 +358,9 @@ class SkeletonCache { } } + const skeletonInfo = this._skeletonCache[assetUuid]; + if (!skeletonInfo) return; + const sharedOperate = (aniKey: string, animationCache: AnimationCache): void => { this._animationPool[`${assetUuid}#${aniKey}`] = animationCache; animationCache.clear(); @@ -366,9 +369,6 @@ class SkeletonCache { animationCache.destroy(); }; const operate = this._privateMode ? privateOperate : sharedOperate; - - const skeletonInfo = this._skeletonCache[assetUuid]; - if (!skeletonInfo) return; const animationsCache = skeletonInfo.animationsCache; for (const aniKey in animationsCache) { // Clear cache texture, and put cache into pool. @@ -466,6 +466,14 @@ class SkeletonCache { delete animationPool[key]; } } + let skeletonInfo = this._skeletonCache[uuid]; + const skeleton = skeletonInfo && skeletonInfo.skeleton; + if (skeleton) { + spine.wasmUtil.destroySpineSkeleton(skeleton); + } + if (skeletonInfo) { + delete this._skeletonCache[uuid]; + } } else { const animationPool = this._animationPool; for (const key in animationPool) { From 9f82a1aab8873ce69cb092856f8181aab24b5f2e Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Thu, 29 Aug 2024 11:29:55 +0800 Subject: [PATCH 09/12] 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 b3a8179d7548d6704c3997979c0624e8c7667a6e Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Thu, 29 Aug 2024 11:30:41 +0800 Subject: [PATCH 10/12] 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 8c4a4788b677a8c29e2785a1e828ac6d0b21020c Mon Sep 17 00:00:00 2001 From: yoki0805 Date: Sat, 31 Aug 2024 16:03:38 +0800 Subject: [PATCH 11/12] Refine particle-simulator-2d.ts Remove ZERO_VEC2 & clampf. --- cocos/particle-2d/particle-simulator-2d.ts | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cocos/particle-2d/particle-simulator-2d.ts b/cocos/particle-2d/particle-simulator-2d.ts index 9918b20a1d0..649fde3c8cc 100644 --- a/cocos/particle-2d/particle-simulator-2d.ts +++ b/cocos/particle-2d/particle-simulator-2d.ts @@ -22,13 +22,12 @@ THE SOFTWARE. */ -import { Vec2, Color, js, misc, random, IColorLike, Vec4 } from '../core'; +import { Vec2, Color, js, misc, random, IColorLike, Vec4, clamp } from '../core'; import { vfmtPosUvColor, getComponentPerVertex } from '../2d/renderer/vertex-format'; import { PositionType, EmitterMode, START_SIZE_EQUAL_TO_END_SIZE, START_RADIUS_EQUAL_TO_END_RADIUS } from './define'; import { ParticleSystem2D } from './particle-system-2d'; import { MeshRenderData } from '../2d/renderer/render-data'; -const ZERO_VEC2 = new Vec2(0, 0); const _pos = new Vec2(); const _tpa = new Vec2(); const _tpb = new Vec2(); @@ -78,8 +77,8 @@ class ParticlePool extends js.Pool { } const pool = new ParticlePool((par: Particle): void => { - par.pos.set(ZERO_VEC2); - par.startPos.set(ZERO_VEC2); + par.pos.set(Vec2.ZERO); + par.startPos.set(Vec2.ZERO); par.color.set(0, 0, 0, 255); par.deltaColor.r = par.deltaColor.g = par.deltaColor.b = 0; par.deltaColor.a = 255; @@ -88,10 +87,10 @@ const pool = new ParticlePool((par: Particle): void => { par.rotation = 0; par.deltaRotation = 0; par.timeToLive = 0; - par.drawPos.set(ZERO_VEC2); + par.drawPos.set(Vec2.ZERO); par.aspectRatio = 1; // Mode A - par.dir.set(ZERO_VEC2); + par.dir.set(Vec2.ZERO); par.radialAccel = 0; par.tangentialAccel = 0; // Mode B @@ -169,14 +168,14 @@ export class Simulator { const endColor = psys.endColor; const endColorVar = psys.endColorVar; - particle.color.r = sr = misc.clampf(startColor.r + startColorVar.r * (random() - 0.5) * 2, 0, 255); - particle.color.g = sg = misc.clampf(startColor.g + startColorVar.g * (random() - 0.5) * 2, 0, 255); - particle.color.b = sb = misc.clampf(startColor.b + startColorVar.b * (random() - 0.5) * 2, 0, 255); - particle.color.a = sa = misc.clampf(startColor.a + startColorVar.a * (random() - 0.5) * 2, 0, 255); - particle.deltaColor.r = (misc.clampf(endColor.r + endColorVar.r * (random() - 0.5) * 2, 0, 255) - sr) / timeToLive; - particle.deltaColor.g = (misc.clampf(endColor.g + endColorVar.g * (random() - 0.5) * 2, 0, 255) - sg) / timeToLive; - particle.deltaColor.b = (misc.clampf(endColor.b + endColorVar.b * (random() - 0.5) * 2, 0, 255) - sb) / timeToLive; - particle.deltaColor.a = (misc.clampf(endColor.a + endColorVar.a * (random() - 0.5) * 2, 0, 255) - sa) / timeToLive; + particle.color.r = sr = clamp(startColor.r + startColorVar.r * (random() - 0.5) * 2, 0, 255); + particle.color.g = sg = clamp(startColor.g + startColorVar.g * (random() - 0.5) * 2, 0, 255); + particle.color.b = sb = clamp(startColor.b + startColorVar.b * (random() - 0.5) * 2, 0, 255); + particle.color.a = sa = clamp(startColor.a + startColorVar.a * (random() - 0.5) * 2, 0, 255); + particle.deltaColor.r = (clamp(endColor.r + endColorVar.r * (random() - 0.5) * 2, 0, 255) - sr) / timeToLive; + particle.deltaColor.g = (clamp(endColor.g + endColorVar.g * (random() - 0.5) * 2, 0, 255) - sg) / timeToLive; + particle.deltaColor.b = (clamp(endColor.b + endColorVar.b * (random() - 0.5) * 2, 0, 255) - sb) / timeToLive; + particle.deltaColor.a = (clamp(endColor.a + endColorVar.a * (random() - 0.5) * 2, 0, 255) - sa) / timeToLive; // size let startS = psys.startSize + psys.startSizeVar * (random() - 0.5) * 2; From a085a013ce4b48de42e4e96a88532ac0e495ed27 Mon Sep 17 00:00:00 2001 From: yoki0805 Date: Sat, 31 Aug 2024 16:10:35 +0800 Subject: [PATCH 12/12] Remove misc Remove misc --- cocos/particle-2d/particle-simulator-2d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/particle-2d/particle-simulator-2d.ts b/cocos/particle-2d/particle-simulator-2d.ts index 649fde3c8cc..501ef233ece 100644 --- a/cocos/particle-2d/particle-simulator-2d.ts +++ b/cocos/particle-2d/particle-simulator-2d.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ -import { Vec2, Color, js, misc, random, IColorLike, Vec4, clamp } from '../core'; +import { Vec2, Color, js, random, IColorLike, Vec4, clamp, toRadian, toDegree } from '../core'; import { vfmtPosUvColor, getComponentPerVertex } from '../2d/renderer/vertex-format'; import { PositionType, EmitterMode, START_SIZE_EQUAL_TO_END_SIZE, START_RADIUS_EQUAL_TO_END_RADIUS } from './define'; import { ParticleSystem2D } from './particle-system-2d'; @@ -203,7 +203,7 @@ export class Simulator { particle.aspectRatio = psys.aspectRatio || 1; // direction - const a = misc.degreesToRadians(psys.angle + this._worldRotation + psys.angleVar * (random() - 0.5) * 2); + const a = toRadian(psys.angle + this._worldRotation + psys.angleVar * (random() - 0.5) * 2); // Mode Gravity: A if (psys.emitterMode === EmitterMode.GRAVITY) { const s = psys.speed + psys.speedVar * (random() - 0.5) * 2; @@ -217,7 +217,7 @@ export class Simulator { particle.tangentialAccel = psys.tangentialAccel + psys.tangentialAccelVar * (random() - 0.5) * 2; // rotation is dir if (psys.rotationIsDir) { - particle.rotation = -misc.radiansToDegrees(Math.atan2(particle.dir.y, particle.dir.x)); + particle.rotation = -toDegree(Math.atan2(particle.dir.y, particle.dir.x)); } } else { // Mode Radius: B @@ -227,7 +227,7 @@ export class Simulator { particle.radius = startRadius; particle.deltaRadius = (psys.endRadius === START_RADIUS_EQUAL_TO_END_RADIUS) ? 0 : (endRadius - startRadius) / timeToLive; particle.angle = a; - particle.degreesPerSecond = misc.degreesToRadians(psys.rotatePerS + psys.rotatePerSVar * (random() - 0.5) * 2); + particle.degreesPerSecond = toRadian(psys.rotatePerS + psys.rotatePerSVar * (random() - 0.5) * 2); } } @@ -276,7 +276,7 @@ export class Simulator { const y1 = -halfHeight; const x2 = halfWidth; const y2 = halfHeight; - const rad = -misc.degreesToRadians(particle.rotation as number); + const rad = -toRadian(particle.rotation as number); const cr = Math.cos(rad); const sr = Math.sin(rad); // bl