From 1a0820fdb00991d6bd24cac687d2b73b39b9a3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=85=B5?= <49358166+xubing0906@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:00:04 +0800 Subject: [PATCH 01/90] reflection probe visibility no longer asynchronous with camera (#16115) --- .../reflection-probe-component.ts | 3 ++- cocos/render-scene/scene/reflection-probe.ts | 1 - .../render-reflection-probe-queue.ts | 25 +++++++------------ .../pipeline/ReflectionProbeBatchedQueue.cpp | 20 +++++++-------- native/cocos/scene/ReflectionProbe.cpp | 1 - 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/cocos/3d/reflection-probe/reflection-probe-component.ts b/cocos/3d/reflection-probe/reflection-probe-component.ts index 3708c0493a3..a4fe36a18c8 100644 --- a/cocos/3d/reflection-probe/reflection-probe-component.ts +++ b/cocos/3d/reflection-probe/reflection-probe-component.ts @@ -192,6 +192,7 @@ export class ReflectionProbe extends Component { * @zh 相机的缓冲清除标志位,指定帧缓冲的哪部分要每帧清除。 */ @type(Enum(ProbeClearFlag)) + @visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; }) set clearFlag (value: number) { this._clearFlag = value; this.probe.clearFlag = this._clearFlag; @@ -204,7 +205,7 @@ export class ReflectionProbe extends Component { * @en Clearing color of the camera. * @zh 相机的颜色缓冲默认值。 */ - @visible(function (this: ReflectionProbe) { return this._clearFlag === ProbeClearFlag.SOLID_COLOR; }) + @visible(function (this: ReflectionProbe) { return this._clearFlag === ProbeClearFlag.SOLID_COLOR && this.probeType === ProbeType.CUBE; }) @type(Color) set backgroundColor (val: Color) { this._backgroundColor = val; diff --git a/cocos/render-scene/scene/reflection-probe.ts b/cocos/render-scene/scene/reflection-probe.ts index 8b10802b7ca..c10d8548cc5 100644 --- a/cocos/render-scene/scene/reflection-probe.ts +++ b/cocos/render-scene/scene/reflection-probe.ts @@ -412,7 +412,6 @@ export class ReflectionProbe { this.camera.nearClip = camera.nearClip; this.camera.farClip = camera.farClip; this.camera.fov = camera.fov; - this.camera.visibility = camera.visibility; this.camera.clearFlag = camera.clearFlag; this.camera.clearColor = camera.clearColor; this.camera.priority = camera.priority - 1; diff --git a/cocos/rendering/render-reflection-probe-queue.ts b/cocos/rendering/render-reflection-probe-queue.ts index 4f78db4a021..c5c35f91873 100644 --- a/cocos/rendering/render-reflection-probe-queue.ts +++ b/cocos/rendering/render-reflection-probe-queue.ts @@ -34,11 +34,6 @@ import { Camera, SKYBOX_FLAG } from '../render-scene/scene/camera'; import { PipelineRuntime } from './custom/pipeline'; import { RenderInstancedQueue } from './render-instanced-queue'; import { cclegacy, geometry } from '../core'; -import { Layers } from '../scene-graph/layers'; - -// eslint-disable-next-line max-len -const REFLECTION_PROBE_DEFAULT_MASK = Layers.makeMaskExclude([Layers.BitMask.UI_2D, Layers.BitMask.UI_3D, Layers.BitMask.GIZMOS, Layers.BitMask.EDITOR, - Layers.BitMask.SCENE_GIZMO, Layers.BitMask.PROFILER]); const CC_USE_RGBE_OUTPUT = 'CC_USE_RGBE_OUTPUT'; let _phaseID = getPhaseID('default'); @@ -96,25 +91,23 @@ export class RenderReflectionProbeQueue { } const models = scene.models; - const visibility = probe.camera.visibility; + const visibility = probe.visibility; for (let i = 0; i < models.length; i++) { const model = models[i]; - if (scene.isCulledByLod(camera, model)) { + if (!model.node || scene.isCulledByLod(camera, model)) { + continue; + } + if (((visibility & model.node.layer) !== model.node.layer) && (!(visibility & model.visFlags))) { continue; } - // filter model by view visibility - if (model.enabled && model.node && model.worldBounds && model.bakeToReflectionProbe) { + if (model.enabled && model.worldBounds && model.bakeToReflectionProbe) { if (probe.probeType === ProbeType.CUBE) { - if ((((visibility & model.node.layer) === model.node.layer) || (visibility & model.visFlags)) - && geometry.intersect.aabbWithAABB(model.worldBounds, probe.boundingBox!)) { - this.add(model); - } - } else if (((model.node.layer & REFLECTION_PROBE_DEFAULT_MASK) === model.node.layer) - || (REFLECTION_PROBE_DEFAULT_MASK & model.visFlags)) { - if (geometry.intersect.aabbFrustum(model.worldBounds, probe.camera.frustum)) { + if (geometry.intersect.aabbWithAABB(model.worldBounds, probe.boundingBox!)) { this.add(model); } + } else if (geometry.intersect.aabbFrustum(model.worldBounds, probe.camera.frustum)) { + this.add(model); } } } diff --git a/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp b/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp index eceff371753..7e7ebc11cf8 100644 --- a/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp +++ b/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp @@ -41,7 +41,6 @@ #include "scene/Skybox.h" namespace cc { namespace pipeline { -const static uint32_t REFLECTION_PROBE_DEFAULT_MASK = ~static_cast(LayerList::UI_2D) & ~static_cast(LayerList::PROFILER) & ~static_cast(LayerList::UI_3D) & ~static_cast(LayerList::GIZMOS) & ~static_cast(LayerList::SCENE_GIZMO) & ~static_cast(LayerList::EDITOR); const ccstd::string CC_USE_RGBE_OUTPUT = "CC_USE_RGBE_OUTPUT"; const cc::scene::IMacroPatch MACRO_PATCH_RGBE_OUTPUT{CC_USE_RGBE_OUTPUT, true}; ReflectionProbeBatchedQueue::ReflectionProbeBatchedQueue(RenderPipeline *pipeline) @@ -80,19 +79,18 @@ void ReflectionProbeBatchedQueue::gatherRenderObjects(const scene::Camera *camer continue; } if (!node || !model->isEnabled() || !worldBounds || !model->getBakeToReflectionProbe()) continue; - uint32_t visibility = probe->getCamera()->getVisibility(); + + uint32_t visibility = probe->getVisibility(); + if (((visibility & node->getLayer()) != node->getLayer()) && (!(visibility & static_cast(model->getVisFlags())))) { + continue; + } if (probe->getProbeType() == scene::ReflectionProbe::ProbeType::CUBE) { - if (((visibility & node->getLayer()) == node->getLayer()) || - (visibility & static_cast(model->getVisFlags()))) { - if (aabbWithAABB(*worldBounds, *probe->getBoundingBox())) { - add(model); - } + if (aabbWithAABB(*worldBounds, *probe->getBoundingBox())) { + add(model); } } else { - if (((node->getLayer() & REFLECTION_PROBE_DEFAULT_MASK) == node->getLayer()) || (REFLECTION_PROBE_DEFAULT_MASK & static_cast(model->getVisFlags()))) { - if (worldBounds->aabbFrustum(probe->getCamera()->getFrustum())) { - add(model); - } + if (worldBounds->aabbFrustum(probe->getCamera()->getFrustum())) { + add(model); } } } diff --git a/native/cocos/scene/ReflectionProbe.cpp b/native/cocos/scene/ReflectionProbe.cpp index 58fe46f8ef2..3eb4392fb52 100644 --- a/native/cocos/scene/ReflectionProbe.cpp +++ b/native/cocos/scene/ReflectionProbe.cpp @@ -101,7 +101,6 @@ void ReflectionProbe::syncCameraParams(const Camera* camera) { _camera->setNearClip(camera->getNearClip()); _camera->setFarClip(camera->getFarClip()); _camera->setFov(camera->getFov()); - _camera->setVisibility(camera->getVisibility()); _camera->setClearFlag(camera->getClearFlag()); _camera->setClearColor(camera->getClearColor()); _camera->setPriority(camera->getPriority() - 1); From 6aa24564f23302464ae1883ab7c2a43f35f6171d Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Tue, 29 Aug 2023 11:07:25 +0800 Subject: [PATCH 02/90] fixed serialized post process parameters (#16116) --- cocos/rendering/post-process/components/blit-screen.ts | 9 +++++++-- cocos/rendering/post-process/components/post-process.ts | 6 ++++-- cocos/rendering/post-process/components/taa.ts | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cocos/rendering/post-process/components/blit-screen.ts b/cocos/rendering/post-process/components/blit-screen.ts index ebd4a3fc2f7..08eacda5502 100644 --- a/cocos/rendering/post-process/components/blit-screen.ts +++ b/cocos/rendering/post-process/components/blit-screen.ts @@ -1,12 +1,13 @@ import { EDITOR } from 'internal:constants'; import { Material } from '../../../asset/assets'; -import { property } from '../../../core/data/class-decorator'; +import { property, serializable } from '../../../core/data/class-decorator'; import { ccclass, disallowMultiple, executeInEditMode, help, menu } from '../../../core/data/decorators'; import { PostProcessSetting } from './post-process-setting'; @ccclass('cc.BlitScreenMaterial') class BlitScreenMaterial { @property(Material) + @serializable protected _material: Material | undefined; @property(Material) @@ -17,7 +18,9 @@ class BlitScreenMaterial { this._material = v; } - @property + @property({ + serializable: true + }) enable = true; } @@ -28,6 +31,7 @@ class BlitScreenMaterial { @executeInEditMode export class BlitScreen extends PostProcessSetting { @property(Material) + @serializable protected _activeMaterials: Material[] = []; @property({ type: Material, visible: false }) get activeMaterials (): Material[] { @@ -47,6 +51,7 @@ export class BlitScreen extends PostProcessSetting { } @property(BlitScreenMaterial) + @serializable protected _materials: BlitScreenMaterial[] = []; @property(BlitScreenMaterial) diff --git a/cocos/rendering/post-process/components/post-process.ts b/cocos/rendering/post-process/components/post-process.ts index ef98e92990f..dc284766106 100644 --- a/cocos/rendering/post-process/components/post-process.ts +++ b/cocos/rendering/post-process/components/post-process.ts @@ -1,5 +1,5 @@ import { EDITOR } from 'internal:constants'; -import { property } from '../../../core/data/class-decorator'; +import { property, serializable } from '../../../core/data/class-decorator'; import { ccclass, disallowMultiple, executeInEditMode, help, range, slide, tooltip } from '../../../core/data/decorators'; import { Director, director } from '../../../game'; import { Component } from '../../../scene-graph'; @@ -14,9 +14,10 @@ export class PostProcess extends Component { @tooltip('i18n:postprocess.global') @property + @serializable global = true; - @property + @serializable protected _shadingScale = 1; @tooltip('i18n:postprocess.shadingScale') @slide @@ -36,6 +37,7 @@ export class PostProcess extends Component { @tooltip('i18n:postprocess.enableShadingScaleInEditor') @property + @serializable enableShadingScaleInEditor = false; settings: Map = new Map(); diff --git a/cocos/rendering/post-process/components/taa.ts b/cocos/rendering/post-process/components/taa.ts index 8622b429542..d0a84d199e4 100644 --- a/cocos/rendering/post-process/components/taa.ts +++ b/cocos/rendering/post-process/components/taa.ts @@ -1,4 +1,4 @@ -import { property } from '../../../core/data/class-decorator'; +import { property, serializable } from '../../../core/data/class-decorator'; import { ccclass, disallowMultiple, executeInEditMode, help, menu, range, slide, tooltip } from '../../../core/data/decorators'; import { PostProcessSetting } from './post-process-setting'; @@ -8,7 +8,7 @@ import { PostProcessSetting } from './post-process-setting'; @disallowMultiple @executeInEditMode export class TAA extends PostProcessSetting { - @property + @serializable protected _sampleScale = 1; @tooltip('i18n:taa.sampleScale') @@ -22,7 +22,7 @@ export class TAA extends PostProcessSetting { this._sampleScale = v; } - @property + @serializable protected _feedback = 0.95; @tooltip('i18n:taa.feedback') @slide From aa3b35e9f01226790a259e635f221366123373fb Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Tue, 29 Aug 2023 11:42:51 +0800 Subject: [PATCH 03/90] remove default setting for post process pipeline (#16120) --- .../post-process/components/post-process-setting.ts | 8 -------- cocos/rendering/post-process/passes/setting-pass.ts | 7 ++----- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/cocos/rendering/post-process/components/post-process-setting.ts b/cocos/rendering/post-process/components/post-process-setting.ts index 9f27b5bc50e..90d60b12106 100644 --- a/cocos/rendering/post-process/components/post-process-setting.ts +++ b/cocos/rendering/post-process/components/post-process-setting.ts @@ -6,14 +6,6 @@ import { PostProcess } from './post-process'; @requireComponent(PostProcess) @executeInEditMode export class PostProcessSetting extends Component { - protected static _default: PostProcessSetting | undefined; - static get default (): PostProcessSetting { - if (!this._default) { - this._default = new this(); - } - return this._default; - } - onEnable (): void { const pp = this.getComponent(PostProcess); pp?.addSetting(this); diff --git a/cocos/rendering/post-process/passes/setting-pass.ts b/cocos/rendering/post-process/passes/setting-pass.ts index 66dd313f000..4530d5b2131 100644 --- a/cocos/rendering/post-process/passes/setting-pass.ts +++ b/cocos/rendering/post-process/passes/setting-pass.ts @@ -5,11 +5,8 @@ import { BasePass } from './base-pass'; export function getSetting (settingClass: new () => T): T { const cls: typeof PostProcessSetting = settingClass as any; - let setting = passContext.postProcess && passContext.postProcess.getSetting(cls) as T; - if (!setting) { - setting = cls.default as T; - } - return setting; + const setting = passContext.postProcess && passContext.postProcess.getSetting(cls) as T; + return setting!; } export abstract class SettingPass extends BasePass { From 1a9b23222143d7c77aa8992891d868a8da6fba7d Mon Sep 17 00:00:00 2001 From: bofeng-song Date: Tue, 29 Aug 2023 17:50:25 +0800 Subject: [PATCH 04/90] fix audio can not reset to position 0 after call stop operation on web platform (#16122) * fix audio can not reset to position 0 after call stop operation on web platform --- pal/audio/minigame/player-web.ts | 14 +++++++++----- pal/audio/web/player-web.ts | 27 +++++++++++++++++---------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/pal/audio/minigame/player-web.ts b/pal/audio/minigame/player-web.ts index 869da1306cb..56a07672a44 100644 --- a/pal/audio/minigame/player-web.ts +++ b/pal/audio/minigame/player-web.ts @@ -25,6 +25,7 @@ import { minigame } from 'pal/minigame'; import { systemInfo } from 'pal/system-info'; import { clamp01 } from '../../../cocos/core'; +import * as debug from '../../../cocos/core/platform/debug'; import { EventTarget } from '../../../cocos/core/event'; import { audioBufferManager } from '../audio-buffer-manager'; import AudioTimer from '../audio-timer'; @@ -133,7 +134,7 @@ export class AudioPlayerWeb implements OperationQueueable { this._state = AudioState.INTERRUPTED; this._readyToHandleOnShow = true; this._eventTarget.emit(AudioEvent.INTERRUPTION_BEGIN); - }).catch((e) => {}); + }).catch((e) => { debug.warn('_onInterruptedBegin error', e); }); } } private _onInterruptedEnd (): void { @@ -145,7 +146,7 @@ export class AudioPlayerWeb implements OperationQueueable { if (this._state === AudioState.INTERRUPTED) { this.play().then(() => { this._eventTarget.emit(AudioEvent.INTERRUPTION_END); - }).catch((e) => {}); + }).catch((e) => { debug.warn('_onInterruptedEnd error', e); }); } this._readyToHandleOnShow = false; } @@ -153,7 +154,7 @@ export class AudioPlayerWeb implements OperationQueueable { return new Promise((resolve) => { AudioPlayerWeb.loadNative(url).then((audioBuffer) => { resolve(new AudioPlayerWeb(audioBuffer, url)); - }).catch((e) => {}); + }).catch((e) => { debug.warn('load error', url, e); }); }); } static loadNative (url: string): Promise { @@ -175,7 +176,7 @@ export class AudioPlayerWeb implements OperationQueueable { audioContext!.decodeAudioData(arrayBuffer).then((decodedAudioBuffer) => { audioBufferManager.addCache(url, decodedAudioBuffer); resolve(decodedAudioBuffer); - }).catch((e) => {}); + }).catch((e) => { debug.warn('loadNative error', url, e); }); }); }); } @@ -185,6 +186,7 @@ export class AudioPlayerWeb implements OperationQueueable { AudioPlayerWeb.loadNative(url).then((audioBuffer) => { // HACK: AudioPlayer should be a friend class in OneShotAudio const oneShotAudio = new (OneShotAudioWeb as any)(audioBuffer, volume, url); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument resolve(oneShotAudio); }).catch(reject); }); @@ -238,7 +240,7 @@ export class AudioPlayerWeb implements OperationQueueable { if (this._state === AudioState.PLAYING) { // one AudioBufferSourceNode can't start twice // need to create a new one to start from the offset - this._doPlay().then(resolve).catch((e) => {}); + this._doPlay().then(resolve).catch((e) => { debug.warn('seek error', e); }); } else { resolve(); } @@ -302,6 +304,8 @@ export class AudioPlayerWeb implements OperationQueueable { @enqueueOperation stop (): Promise { if (!this._sourceNode) { + this._audioTimer.stop(); + this._state = AudioState.STOPPED; return Promise.resolve(); } this._audioTimer.stop(); diff --git a/pal/audio/web/player-web.ts b/pal/audio/web/player-web.ts index 5d703d35d63..410e305d8d9 100644 --- a/pal/audio/web/player-web.ts +++ b/pal/audio/web/player-web.ts @@ -26,6 +26,7 @@ import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; import { AudioPCMDataView, AudioEvent, AudioState, AudioType } from '../type'; import { EventTarget } from '../../../cocos/core/event'; import { clamp01 } from '../../../cocos/core'; +import * as debug from '../../../cocos/core/platform/debug'; import { enqueueOperation, OperationInfo, OperationQueueable } from '../operation-queue'; import AudioTimer from '../audio-timer'; import { audioBufferManager } from '../audio-buffer-manager'; @@ -76,9 +77,10 @@ export class AudioContextAgent { resolve(audioBuffer); }, (err) => { // TODO: need to reject the error. + // eslint-disable-next-line no-console console.error('failed to load Web Audio', err); }); - promise?.catch((e) => {}); // Safari doesn't support the promise based decodeAudioData + promise?.catch((e) => { debug.warn('decodeAudioData error', e); }); // Safari doesn't support the promise based decodeAudioData }); } @@ -93,7 +95,7 @@ export class AudioContextAgent { resolve(); return; } - context.resume().catch((e) => {}); + context.resume().catch((e) => { debug.warn('runContext error', e); }); if (context.state === 'running') { resolve(); return; @@ -106,7 +108,7 @@ export class AudioContextAgent { canvas?.removeEventListener('touchend', onGesture, { capture: true }); canvas?.removeEventListener('mouseup', onGesture, { capture: true }); resolve(); - }).catch((e) => {}); + }).catch((e) => { debug.warn('onGesture resume error', e); }); }; canvas?.addEventListener('touchend', onGesture, { capture: true }); canvas?.addEventListener('mouseup', onGesture, { capture: true }); @@ -199,7 +201,7 @@ export class OneShotAudioWeb { audioBufferManager.tryReleasingCache(this._url); this.onEnd?.(); }, this._duration * 1000); - }).catch((e) => {}); + }).catch((e) => { debug.warn('play error', e); }); } public stop (): void { @@ -257,7 +259,7 @@ export class AudioPlayerWeb implements OperationQueueable { return new Promise((resolve) => { AudioPlayerWeb.loadNative(url).then((audioBuffer) => { resolve(new AudioPlayerWeb(audioBuffer, url)); - }).catch((e) => {}); + }).catch((e) => { debug.warn('load error', url, e); }); }); } static loadNative (url: string): Promise { @@ -275,10 +277,11 @@ export class AudioPlayerWeb implements OperationQueueable { xhr.onload = (): void => { if (xhr.status === 200 || xhr.status === 0) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument audioContextAgent!.decodeAudioData(xhr.response).then((decodedAudioBuffer) => { audioBufferManager.addCache(url, decodedAudioBuffer); resolve(decodedAudioBuffer); - }).catch((e) => {}); + }).catch((e) => { debug.warn('loadNative error', url, e); }); } else { reject(new Error(`${errInfo}${xhr.status}(no response)`)); } @@ -295,6 +298,7 @@ export class AudioPlayerWeb implements OperationQueueable { AudioPlayerWeb.loadNative(url).then((audioBuffer) => { // HACK: AudioPlayer should be a friend class in OneShotAudio const oneShotAudio = new (OneShotAudioWeb as any)(audioBuffer, volume, url); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument resolve(oneShotAudio); }).catch(reject); }); @@ -313,14 +317,14 @@ export class AudioPlayerWeb implements OperationQueueable { this.pause().then(() => { this._state = AudioState.INTERRUPTED; this._eventTarget.emit(AudioEvent.INTERRUPTION_BEGIN); - }).catch((e) => {}); + }).catch((e) => { debug.warn('_onInterruptedBegin error', e); }); } } private _onInterruptedEnd (): void { if (this._state === AudioState.INTERRUPTED) { this.play().then(() => { this._eventTarget.emit(AudioEvent.INTERRUPTION_END); - }).catch((e) => {}); + }).catch((e) => { debug.warn('_onInterruptedEnd error', e); }); } } @@ -371,7 +375,7 @@ export class AudioPlayerWeb implements OperationQueueable { if (this._state === AudioState.PLAYING) { // one AudioBufferSourceNode can't start twice // need to create a new one to start from the offset - this._doPlay().then(resolve).catch((e) => {}); + this._doPlay().then(resolve).catch((e) => { debug.warn('seek error', e); }); } else { resolve(); } @@ -405,7 +409,7 @@ export class AudioPlayerWeb implements OperationQueueable { // - system automatically resume audio context when enter foreground from background. audioContextAgent!.onceRunning(this._runningCallback); // Ensure resume context. - audioContextAgent!.runContext().catch((e) => {}); + audioContextAgent!.runContext().catch((e) => { debug.warn('doPlay error', e); }); } }); } @@ -415,6 +419,7 @@ export class AudioPlayerWeb implements OperationQueueable { this._stopSourceNode(); this._sourceNode = audioContextAgent!.createBufferSource(this._audioBuffer, this.loop); this._sourceNode.connect(this._gainNode); + this._sourceNode.loop = this._loop; this._sourceNode.start(0, this._audioTimer.currentTime); this._state = AudioState.PLAYING; this._audioTimer.start(); @@ -465,6 +470,8 @@ export class AudioPlayerWeb implements OperationQueueable { stop (): Promise { this.offRunning(); if (!this._sourceNode) { + this._audioTimer.stop(); + this._state = AudioState.STOPPED; return Promise.resolve(); } this._audioTimer.stop(); From 8e8951e05f306247928d2ac3b2d1f4864f3bc560 Mon Sep 17 00:00:00 2001 From: PP Date: Wed, 30 Aug 2023 10:35:31 +0800 Subject: [PATCH 05/90] set spine module as separate engine module (#16133) --- editor/engine-features/render-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json index a562f3bd67e..59f4a6093b9 100644 --- a/editor/engine-features/render-config.json +++ b/editor/engine-features/render-config.json @@ -234,7 +234,7 @@ "label": "i18n:ENGINE.features.spine.label", "description": "i18n:ENGINE.features.spine.description", "native": "USE_SPINE", - "wechatPlugin": false, + "wechatPlugin": true, "category": "2d" }, "dragon-bones": { From d10253e60fcc8529317c13549bc4ddf9770c3f81 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Wed, 30 Aug 2023 11:23:25 +0800 Subject: [PATCH 06/90] add missing default viewType (#16121) * add missing default viewType * add missing color attachment --- .../pipeline/custom/FrameGraphDispatcher.cpp | 2 ++ .../pipeline/custom/NativePipeline.cpp | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp b/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp index e6087402ac8..4d0f5afe176 100644 --- a/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp +++ b/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp @@ -326,6 +326,7 @@ RenderingInfo FrameGraphDispatcher::getRenderPassAndFrameBuffer(RenderGraph::ver CC_EXPECTS(fb->getColorTextures().at(0)); // render window attaches a depthStencil by default, which may differs from renderpassInfo here. // data.framebuffer = fb; + fbInfo.colorTextures.emplace_back(fb->getColorTextures().at(0)); }, [&](const RenderSwapchain &sc) { fbInfo.colorTextures.emplace_back(sc.swapchain->getColorTexture()); @@ -338,6 +339,7 @@ RenderingInfo FrameGraphDispatcher::getRenderPassAndFrameBuffer(RenderGraph::ver [&](const SubresourceView &view) { fbInfo.colorTextures.emplace_back(view.textureView); }); + CC_EXPECTS(!fbInfo.colorTextures.empty()); } else { // ds or ds resolve if (!info.isResolveView) { diff --git a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp index 7896ae83828..004765b67e4 100644 --- a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp +++ b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp @@ -47,19 +47,26 @@ void addSubresourceNode(ResourceGraph::vertex_descriptor v, const ccstd::string template <> void addSubresourceNode(ResourceGraph::vertex_descriptor v, const ccstd::string &name, ResourceGraph &resg) { + const auto& desc = get(ResourceGraph::DescTag{}, resg, v); + const auto& traits = get(ResourceGraph::TraitsTag{}, resg, v); + const auto& samplerInfo = get(ResourceGraph::SamplerTag{}, resg, v); + SubresourceView view{ nullptr, gfx::Format::DEPTH_STENCIL, - 0, 1, 0, 1, 0, 1}; - - auto desc = get(ResourceGraph::DescTag{}, resg, v); - auto traits = get(ResourceGraph::TraitsTag{}, resg, v); - auto samplerInfo = get(ResourceGraph::SamplerTag{}, resg, v); + 0, // indexOrFirstMipLevel + 1, // numMipLevels + 0, // firstArraySlice + 1, // numArraySlices + 0, // firstPlane + 1, // numPlanes + desc.viewType, + }; ccstd::string depthName{name}; depthName += "/"; depthName += DEPTH_PLANE_NAME; - auto depthID = addVertex( + const auto depthID = addVertex( SubresourceViewTag{}, std::forward_as_tuple(depthName.c_str()), std::forward_as_tuple(desc), @@ -74,7 +81,7 @@ void addSubresourceNode(ResourceGraph::vertex_descri ccstd::string stencilName{name}; stencilName += "/"; stencilName += STENCIL_PLANE_NAME; - auto stencilID = addVertex( + const auto stencilID = addVertex( SubresourceViewTag{}, std::forward_as_tuple(stencilName.c_str()), std::forward_as_tuple(desc), From 63d4ed68f85241fef35bdbd5870234928ac00d51 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Wed, 30 Aug 2023 11:23:46 +0800 Subject: [PATCH 07/90] fix addRangedDirLight interface error (#16135) --- native/cocos/scene/RenderScene.cpp | 2 +- native/cocos/scene/RenderScene.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/native/cocos/scene/RenderScene.cpp b/native/cocos/scene/RenderScene.cpp index f0ae11498c6..f31babe063d 100644 --- a/native/cocos/scene/RenderScene.cpp +++ b/native/cocos/scene/RenderScene.cpp @@ -320,7 +320,7 @@ void RenderScene::removePointLights() { _pointLights.clear(); } -void RenderScene::addRangedDirlLight(RangedDirectionalLight *rangedDirLight) { +void RenderScene::addRangedDirLight(RangedDirectionalLight *rangedDirLight) { _rangedDirLights.emplace_back(rangedDirLight); } diff --git a/native/cocos/scene/RenderScene.h b/native/cocos/scene/RenderScene.h index 55544e420a9..5ab7f64fe13 100644 --- a/native/cocos/scene/RenderScene.h +++ b/native/cocos/scene/RenderScene.h @@ -95,7 +95,7 @@ class RenderScene : public RefCounted { void removePointLight(PointLight *); void removePointLights(); - void addRangedDirlLight(RangedDirectionalLight *); + void addRangedDirLight(RangedDirectionalLight *); void removeRangedDirLight(RangedDirectionalLight *); void removeRangedDirLights(); From 93ff89c85576493a33552fc23cc1f529c06f5207 Mon Sep 17 00:00:00 2001 From: Yiwen <15225434259xue@gmail.com> Date: Wed, 30 Aug 2023 12:00:11 +0800 Subject: [PATCH 08/90] fix asmjs subpackage problem on minigame platform, fix gui (#16123) * fix asmjs subpackage problem on minigame platform, fix gui --- cocos/3d/misc/mesh-codec.ts | 77 +++++++++++++++------------- editor/inspector/assets/fbx/model.js | 1 - 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/cocos/3d/misc/mesh-codec.ts b/cocos/3d/misc/mesh-codec.ts index b6ed3862bc2..ba9f5088c9d 100644 --- a/cocos/3d/misc/mesh-codec.ts +++ b/cocos/3d/misc/mesh-codec.ts @@ -21,13 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -import meshopt_asm_factory from 'external:emscripten/meshopt/meshopt_decoder.asm.js'; -import meshopt_wasm_factory from 'external:emscripten/meshopt/meshopt_decoder.wasm.js'; -import meshopt_wasm_url from 'external:emscripten/meshopt/meshopt_decoder.wasm.wasm'; - import { WASM_SUPPORT_MODE } from 'internal:constants'; -import { instantiateWasm } from 'pal/wasm'; +import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm'; import { sys, logID } from '../../core'; @@ -36,51 +31,63 @@ import { WebAssemblySupportMode } from '../../misc/webassembly-support'; export const MeshoptDecoder = {} as any; -function initDecoderASM (): Promise { - const Module = meshopt_asm_factory; - return Promise.all([Module.ready]).then(() => { - MeshoptDecoder.supported = true; +function initDecoderASM (asm_factory: any): Promise { + return Promise.all([asm_factory.ready]).then(() => { + MeshoptDecoder.supported = asm_factory.supported; MeshoptDecoder.ready = Promise.resolve(); - MeshoptDecoder.decodeVertexBuffer = Module.decodeVertexBuffer; - MeshoptDecoder.decodeIndexBuffer = Module.decodeIndexBuffer; - MeshoptDecoder.decodeIndexSequence = Module.decodeIndexSequence; - MeshoptDecoder.decodeGltfBuffer = Module.decodeGltfBuffer; - MeshoptDecoder.useWorkers = Module.useWorkers; - MeshoptDecoder.decodeGltfBufferAsync = Module.decodeGltfBufferAsync; + MeshoptDecoder.decodeVertexBuffer = asm_factory.decodeVertexBuffer; + MeshoptDecoder.decodeIndexBuffer = asm_factory.decodeIndexBuffer; + MeshoptDecoder.decodeIndexSequence = asm_factory.decodeIndexSequence; + MeshoptDecoder.decodeGltfBuffer = asm_factory.decodeGltfBuffer; + MeshoptDecoder.useWorkers = asm_factory.useWorkers; + MeshoptDecoder.decodeGltfBufferAsync = asm_factory.decodeGltfBufferAsync; logID(14202); }); } -function initDecoderWASM (): Promise { - const Module = meshopt_wasm_factory; +function initDecoderWASM (wasm_factory: any, wasm_url: string): Promise { function instantiate (importObject: WebAssembly.Imports): any { - return instantiateWasm(meshopt_wasm_url, importObject) as any; + return instantiateWasm(wasm_url, importObject) as any; } - return Promise.all([Module.ready(instantiate)]).then(() => { - MeshoptDecoder.supported = true; + return Promise.all([wasm_factory.ready(instantiate)]).then(() => { + MeshoptDecoder.supported = wasm_factory.supported; MeshoptDecoder.ready = Promise.resolve(); - MeshoptDecoder.decodeVertexBuffer = Module.decodeVertexBuffer; - MeshoptDecoder.decodeIndexBuffer = Module.decodeIndexBuffer; - MeshoptDecoder.decodeIndexSequence = Module.decodeIndexSequence; - MeshoptDecoder.decodeGltfBuffer = Module.decodeGltfBuffer; - MeshoptDecoder.useWorkers = Module.useWorkers; - MeshoptDecoder.decodeGltfBufferAsync = Module.decodeGltfBufferAsync; + MeshoptDecoder.decodeVertexBuffer = wasm_factory.decodeVertexBuffer; + MeshoptDecoder.decodeIndexBuffer = wasm_factory.decodeIndexBuffer; + MeshoptDecoder.decodeIndexSequence = wasm_factory.decodeIndexSequence; + MeshoptDecoder.decodeGltfBuffer = wasm_factory.decodeGltfBuffer; + MeshoptDecoder.useWorkers = wasm_factory.useWorkers; + MeshoptDecoder.decodeGltfBufferAsync = wasm_factory.decodeGltfBufferAsync; logID(14203); }); } -export function InitDecoder (): Promise { +function shouldUseWasmModule (): boolean { if (WASM_SUPPORT_MODE === (WebAssemblySupportMode.MAYBE_SUPPORT as number)) { - if (sys.hasFeature(sys.Feature.WASM)) { - return initDecoderWASM(); - } else { - return initDecoderASM(); - } + return sys.hasFeature(sys.Feature.WASM); } else if (WASM_SUPPORT_MODE === (WebAssemblySupportMode.SUPPORT as number)) { - return initDecoderWASM(); + return true; } else { - return initDecoderASM(); + return false; } } +export function InitDecoder (): Promise { + return ensureWasmModuleReady().then(() => Promise.all([ + import('external:emscripten/meshopt/meshopt_decoder.asm.js'), + import('external:emscripten/meshopt/meshopt_decoder.wasm.js'), + import('external:emscripten/meshopt/meshopt_decoder.wasm.wasm'), + ]).then(([ + { default: meshopt_asm_factory }, + { default: meshopt_wasm_factory }, + { default: meshopt_wasm_url }, + ]) => { + if (shouldUseWasmModule()) { + return initDecoderWASM(meshopt_wasm_factory, meshopt_wasm_url); + } else { + return initDecoderASM(meshopt_asm_factory); + } + })); +} + game.onPostInfrastructureInitDelegate.add(InitDecoder); diff --git a/editor/inspector/assets/fbx/model.js b/editor/inspector/assets/fbx/model.js index 8c524043019..770af79969d 100644 --- a/editor/inspector/assets/fbx/model.js +++ b/editor/inspector/assets/fbx/model.js @@ -888,7 +888,6 @@ const Elements = { Elements.normals.update.call(panel); Elements.tangents.update.call(panel); Elements.morphNormals.update.call(panel); - Elements.meshOptimizerAlgorithm.update.call(panel); }, }, }; From 44ca8eaf1a0684b502bbf87d73d35b77208880a7 Mon Sep 17 00:00:00 2001 From: PP Date: Wed, 30 Aug 2023 15:12:09 +0800 Subject: [PATCH 09/90] support taobaoMinigamePlugin in render-config.json (#16138) --- editor/engine-features/render-config.json | 55 +++++++++++++++++------ editor/engine-features/schema.json | 6 +++ editor/engine-features/types.ts | 12 +++++ 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json index 59f4a6093b9..1e1f468623a 100644 --- a/editor/engine-features/render-config.json +++ b/editor/engine-features/render-config.json @@ -6,7 +6,8 @@ "description": "i18n:ENGINE.features.core.description", "required": true, "default": ["base"], - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "graphcis": { "label": "i18n:ENGINE.features.graphics.label", @@ -18,12 +19,14 @@ "required": true, "label": "i18n:ENGINE.features.gfx_webgl.label", "description": "i18n:ENGINE.features.gfx_webgl.description", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "gfx-webgl2": { "label": "i18n:ENGINE.features.gfx_webgl2.label", "description": "i18n:ENGINE.features.gfx_webgl2.description", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true } } }, @@ -44,6 +47,7 @@ "label": "i18n:ENGINE.features.base_3d.label", "description": "i18n:ENGINE.features.base_3d.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "3d" }, "2d": { @@ -51,27 +55,31 @@ "label": "i18n:ENGINE.features.base_2d.label", "description": "i18n:ENGINE.features.base_2d.description", "category": "2d", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "xr": { "default": [], "label": "i18n:ENGINE.features.xr.label", "description": "i18n:ENGINE.features.xr.description", - "wechatPlugin": false + "wechatPlugin": false, + "taobaoMinigamePlugin": false }, "ui": { "default": ["ui"], "label": "i18n:ENGINE.features.ui.label", "description": "i18n:ENGINE.features.ui.description", "category": "2d", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "particle": { "default": ["particle"], "label": "i18n:ENGINE.features.particle.label", "description": "i18n:ENGINE.features.particle.description", "category": "3d", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "physics": { "label": "i18n:ENGINE.features.physics.label", @@ -119,6 +127,7 @@ "label": "i18n:ENGINE.features.intersection_2d.label", "description": "i18n:ENGINE.features.intersection_2d.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "2d" }, "primitive": { @@ -126,13 +135,15 @@ "label": "i18n:ENGINE.features.primitives.label", "description": "i18n:ENGINE.features.primitives.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "3d" }, "profiler": { "default": ["profiler"], "label": "i18n:ENGINE.features.profiler.label", "description": "i18n:ENGINE.features.profiler.description", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "occlusion-query": { "default": [], @@ -140,6 +151,7 @@ "description": "i18n:ENGINE.features.occlusion_query.description", "native": "USE_OCCLUSION_QUERY", "wechatPlugin": false, + "taobaoMinigamePlugin": false, "category": "3d" }, "geometry-renderer": { @@ -148,6 +160,7 @@ "description": "i18n:ENGINE.features.geometry_renderer.description", "native": "USE_GEOMETRY_RENDERER", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "3d" }, "debug-renderer": { @@ -156,6 +169,7 @@ "description": "i18n:ENGINE.features.debug_renderer.description", "native": "USE_DEBUG_RENDERER", "wechatPlugin": false, + "taobaoMinigamePlugin": false, "category": "3d" }, "particle-2d": { @@ -163,6 +177,7 @@ "label": "i18n:ENGINE.features.particle_2d.label", "description": "i18n:ENGINE.features.particle_2d.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "2d" }, "audio": { @@ -170,27 +185,31 @@ "label": "i18n:ENGINE.features.audio.label", "description": "i18n:ENGINE.features.audio.description", "native": "USE_AUDIO", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "video": { "default": ["video"], "label": "i18n:ENGINE.features.video.label", "description": "i18n:ENGINE.features.video.description", "native": "USE_VIDEO", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "webview": { "default": ["webview"], "label": "i18n:ENGINE.features.webview.label", "description": "i18n:ENGINE.features.webview.description", "native": "USE_WEBVIEW", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "tween": { "default": ["tween"], "label": "i18n:ENGINE.features.tween.label", "description": "i18n:ENGINE.features.tween.description", - "wechatPlugin": true + "wechatPlugin": true, + "taobaoMinigamePlugin": true }, "websocket": { "default": ["websocket"], @@ -198,6 +217,7 @@ "description": "i18n:ENGINE.features.websocket.description", "native": "USE_SOCKET", "wechatPlugin": false, + "taobaoMinigamePlugin": false, "category": "network" }, "websocket-server": { @@ -206,6 +226,7 @@ "description": "i18n:ENGINE.features.websocket_server.description", "native": "USE_WEBSOCKET_SERVER", "wechatPlugin": false, + "taobaoMinigamePlugin": false, "category": "network" }, "terrain": { @@ -213,6 +234,7 @@ "label": "i18n:ENGINE.features.terrain.label", "description": "i18n:ENGINE.features.terrain.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "3d" }, "light-probe": { @@ -220,6 +242,7 @@ "label": "i18n:ENGINE.features.light_probe.label", "description": "i18n:ENGINE.features.light_probe.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "3d" }, "tiled-map": { @@ -227,6 +250,7 @@ "label": "i18n:ENGINE.features.tiled_map.label", "description": "i18n:ENGINE.features.tiled_map.description", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "2d" }, "spine": { @@ -235,6 +259,7 @@ "description": "i18n:ENGINE.features.spine.description", "native": "USE_SPINE", "wechatPlugin": true, + "taobaoMinigamePlugin": false, "category": "2d" }, "dragon-bones": { @@ -243,6 +268,7 @@ "description": "i18n:ENGINE.features.dragon_bones.description", "native": "USE_DRAGONBONES", "wechatPlugin": true, + "taobaoMinigamePlugin": true, "category": "2d" }, "marionette": { @@ -250,6 +276,7 @@ "label": "i18n:ENGINE.features.marionette.label", "description": "i18n:ENGINE.features.marionette.description", "wechatPlugin": false, + "taobaoMinigamePlugin": false, "category": "animation" }, "procedural-animation": { @@ -257,13 +284,15 @@ "label": "i18n:ENGINE.features.procedural_animation.label", "description": "i18n:ENGINE.features.procedural_animation.description", "wechatPlugin": false, + "taobaoMinigamePlugin": false, "category": "animation" }, "custom-pipeline": { "default": [], "label": "i18n:ENGINE.features.custom_pipeline.label", "description": "i18n:ENGINE.features.custom_pipeline.description", - "wechatPlugin": false + "wechatPlugin": false, + "taobaoMinigamePlugin": false } }, "categories": { diff --git a/editor/engine-features/schema.json b/editor/engine-features/schema.json index b6934c7e5dc..dc9bffeac50 100644 --- a/editor/engine-features/schema.json +++ b/editor/engine-features/schema.json @@ -33,6 +33,9 @@ }, "wechatPlugin": { "type": "boolean" + }, + "taobaoMinigamePlugin": { + "type": "boolean" } }, "type": "object" @@ -195,6 +198,9 @@ }, "wechatPlugin": { "type": "boolean" + }, + "taobaoMinigamePlugin": { + "type": "boolean" } }, "type": "object" diff --git a/editor/engine-features/types.ts b/editor/engine-features/types.ts index 9c069d75e6f..90579fe56ec 100644 --- a/editor/engine-features/types.ts +++ b/editor/engine-features/types.ts @@ -66,6 +66,12 @@ export interface FlagBaseItem { wechatPlugin?: boolean; + /** + * Different with wechat plugin, taobao plugin can't read buffer from local wasm. + * So we need another config item for taobao minigame plugin. + */ + taobaoMinigamePlugin?: boolean; + default?: string[]; } @@ -86,6 +92,12 @@ export interface BaseItem { wechatPlugin?: boolean; + /** + * Different with wechat plugin, taobao plugin can't read buffer from local wasm. + * So we need another config item for taobao minigame plugin. + */ + taobaoMinigamePlugin?: boolean; + default?: string[]; category?: string; From 49ce3235c8710362f177de0df8e91e7e0ae324e6 Mon Sep 17 00:00:00 2001 From: qiuguohua Date: Wed, 30 Aug 2023 16:11:23 +0800 Subject: [PATCH 10/90] Update to use sdl static library (#16101) --- native/external-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/external-config.json b/native/external-config.json index ec906e37394..58e7de228dc 100644 --- a/native/external-config.json +++ b/native/external-config.json @@ -3,6 +3,6 @@ "type": "github", "owner": "cocos-creator", "name": "engine-native-external", - "checkout": "v3.8.1-17" + "checkout": "v3.8.1-18" } } \ No newline at end of file From 77d3f7cde74cb8ee5110f3664f2f8b51786595d4 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Wed, 30 Aug 2023 17:07:28 +0800 Subject: [PATCH 11/90] fix alpha blend error with custom pipeline and add bloom masks (#16125) --- cc.config.json | 1 + .../post-process/components/bloom.ts | 30 +++++++++++- .../post-process/passes/bloom-pass.ts | 10 +++- .../passes/float-output-process-pass.ts | 7 ++- cocos/rendering/post-process/passes/index.ts | 1 + .../post-process/passes/post-final-pass.ts | 47 +++++++++++++++++++ .../post-process/post-process-builder.ts | 10 +++- .../pipeline/post-process/bloom.effect | 31 ++++++++---- .../pipeline/post-process/post-final.effect | 40 ++++++++++++++++ .../post-process/post-final.effect.meta | 11 +++++ editor/i18n/en/localization.js | 2 + editor/i18n/zh/localization.js | 2 + 12 files changed, 176 insertions(+), 16 deletions(-) create mode 100644 cocos/rendering/post-process/passes/post-final-pass.ts create mode 100644 editor/assets/effects/pipeline/post-process/post-final.effect create mode 100644 editor/assets/effects/pipeline/post-process/post-final.effect.meta diff --git a/cc.config.json b/cc.config.json index ad9f279be52..7b51e5dd86e 100644 --- a/cc.config.json +++ b/cc.config.json @@ -187,6 +187,7 @@ "modules": ["custom-pipeline"], "dependentAssets": [ "15049ccd-4dd7-451e-a8ae-af66735c929e", + "521c5f6e-1a26-42e2-8108-4400c912d9bf", "4c3ce6de-e6d1-47f7-aa36-36b9b58f72d3", "4361db28-3f24-44cc-8e51-32ee5fd651ac", "cafd95c9-c558-46f9-9812-1224b65c09ee", diff --git a/cocos/rendering/post-process/components/bloom.ts b/cocos/rendering/post-process/components/bloom.ts index 43fa0451467..5432f2a93bd 100644 --- a/cocos/rendering/post-process/components/bloom.ts +++ b/cocos/rendering/post-process/components/bloom.ts @@ -1,5 +1,8 @@ -import { ccclass, disallowMultiple, executeInEditMode, help, menu, range, rangeMin, serializable, slide, tooltip, type } from '../../../core/data/decorators'; -import { CCFloat, CCInteger } from '../../../core/data/utils/attribute'; +import { cclegacy } from '../../../core'; +import { ccclass, disallowMultiple, executeInEditMode, help, menu, range, rangeMin, + serializable, slide, tooltip, type, visible } from '../../../core/data/decorators'; +import { CCBoolean, CCFloat, CCInteger } from '../../../core/data/utils/attribute'; +import { Root } from '../../../root'; import { PostProcessSetting } from './post-process-setting'; @ccclass('cc.Bloom') @@ -8,6 +11,10 @@ import { PostProcessSetting } from './post-process-setting'; @disallowMultiple @executeInEditMode export class Bloom extends PostProcessSetting { + @serializable + protected _enableAlphaMask = false; + @serializable + protected _useHdrIlluminance: boolean = false; @serializable protected _threshold = 0.8; @serializable @@ -15,6 +22,25 @@ export class Bloom extends PostProcessSetting { @serializable protected _intensity = 2.3; + @tooltip('i18n:bloom.enableAlphaMask') + @type(CCBoolean) + set enableAlphaMask (value: boolean) { + this._enableAlphaMask = value; + } + get enableAlphaMask (): boolean { + return this._enableAlphaMask; + } + + @tooltip('i18n:bloom.useHdrIlluminance') + @visible(() => (cclegacy.director.root as Root).pipeline.getMacroBool('CC_USE_FLOAT_OUTPUT')) + @type(CCBoolean) + set useHdrIlluminance (value: boolean) { + this._useHdrIlluminance = value; + } + get useHdrIlluminance (): boolean { + return this._useHdrIlluminance; + } + @tooltip('i18n:bloom.threshold') @rangeMin(0) @type(CCFloat) diff --git a/cocos/rendering/post-process/passes/bloom-pass.ts b/cocos/rendering/post-process/passes/bloom-pass.ts index 85330ea852f..e3895ada6ff 100644 --- a/cocos/rendering/post-process/passes/bloom-pass.ts +++ b/cocos/rendering/post-process/passes/bloom-pass.ts @@ -27,6 +27,11 @@ export class BloomPass extends SettingPass { name = 'BloomPass'; effectName = 'pipeline/post-process/bloom'; outputNames = ['BloomColor']; + private _hdrInputName: string = ''; + + set hdrInputName (name: string) { + this._hdrInputName = name; + } public render (camera: Camera, ppl: Pipeline): void { const cameraID = getCameraUniqueID(camera); @@ -44,11 +49,14 @@ export class BloomPass extends SettingPass { const output = `BLOOM_PREFILTER_COLOR${cameraID}`; // prefilter pass let shadingScale = 1 / 2; - passContext.material.setProperty('texSize', new Vec4(0, 0, setting.threshold, 0), 0); + const enableAlphaMask = setting.enableAlphaMask as unknown as number; + const useHDRIntensity = setting.useHdrIlluminance as unknown as number; + passContext.material.setProperty('texSize', new Vec4(useHDRIntensity, 0, setting.threshold, enableAlphaMask), 0); passContext .updatePassViewPort(shadingScale) .addRenderPass('bloom-prefilter', `bloom-prefilter${cameraID}`) .setPassInput(input, 'outputResultMap') + .setPassInput(this._hdrInputName, 'hdrInputMap') .addRasterView(output, Format.RGBA8) .blitScreen(0) .version(); diff --git a/cocos/rendering/post-process/passes/float-output-process-pass.ts b/cocos/rendering/post-process/passes/float-output-process-pass.ts index 169d26d2afa..d48c97c47e0 100644 --- a/cocos/rendering/post-process/passes/float-output-process-pass.ts +++ b/cocos/rendering/post-process/passes/float-output-process-pass.ts @@ -37,12 +37,15 @@ export class FloatOutputProcessPass extends SettingPass { effectName = 'pipeline/float-output-process'; outputNames = ['FloatOutputProcess']; + hdrInputName: string = ''; + enableInAllEditorCamera = true; enable = true; checkEnable (camera: Camera): boolean { const ppl = (cclegacy.director.root as Root).pipeline; return ppl.getMacroBool('CC_USE_FLOAT_OUTPUT'); } + getHDRInputName (): string { return this.hdrInputName; } onGlobalPipelineStateChanged (): void { passContext.material = this.material; @@ -81,7 +84,7 @@ export class FloatOutputProcessPass extends SettingPass { } passIndx = 1; - const input = this.lastPass!.slotName(camera, 0); + this.hdrInputName = this.lastPass!.slotName(camera, 0); const output = this.slotName(camera, 0); const layoutName = 'tone-mapping'; const passName = `tone-mapping${cameraID}`; @@ -89,7 +92,7 @@ export class FloatOutputProcessPass extends SettingPass { Vec4.set(passContext.clearColor, camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w); passContext.updatePassViewPort() .addRenderPass(layoutName, passName) - .setPassInput(input, 'u_texSampler') + .setPassInput(this.hdrInputName, 'u_texSampler') .setPassInput(copyDS, 'DepthTex') .addRasterView(output, Format.RGBA8) .blitScreen(passIndx) diff --git a/cocos/rendering/post-process/passes/index.ts b/cocos/rendering/post-process/passes/index.ts index 00009f2f35a..c1e94dfb424 100644 --- a/cocos/rendering/post-process/passes/index.ts +++ b/cocos/rendering/post-process/passes/index.ts @@ -13,3 +13,4 @@ export * from './float-output-process-pass'; export * from './forward-transparency-pass'; export * from './forward-transparency-simple-pass'; export * from './skin-pass'; +export * from './post-final-pass'; diff --git a/cocos/rendering/post-process/passes/post-final-pass.ts b/cocos/rendering/post-process/passes/post-final-pass.ts new file mode 100644 index 00000000000..a29b52f4ec4 --- /dev/null +++ b/cocos/rendering/post-process/passes/post-final-pass.ts @@ -0,0 +1,47 @@ +import { Vec4 } from '../../../core'; +import { ClearFlagBit, Format } from '../../../gfx'; +import { Camera } from '../../../render-scene/scene'; +import { getCameraUniqueID } from '../../custom/define'; +import { Pipeline } from '../../custom/pipeline'; +import { passContext } from '../utils/pass-context'; +import { BasePass } from './base-pass'; + +export class PostFinalPass extends BasePass { + name = 'PostFinalPass'; + outputNames = ['PostFinalColor']; + effectName = 'pipeline/post-process/post-final'; + + enableInAllEditorCamera = true; + + public render (camera: Camera, ppl: Pipeline): void { + if (!this.lastPass) { + return; + } + + passContext.clearFlag = camera.clearFlag & ClearFlagBit.COLOR; + Vec4.set(passContext.clearColor, camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w); + + passContext.material = this.material; + + const cameraID = getCameraUniqueID(camera); + + const input0 = this.lastPass.slotName(camera, 0); + const slot0 = this.slotName(camera, 0); + + const isOffScreen = false;//director.root!.mainWindow !== camera.window; + + const fb = camera.window.framebuffer; + const ct = fb && fb.colorTextures[0]; + const format = ct ? ct.format : Format.RGBA8; + + const shadingScale = passContext.shadingScale; + passContext + .updatePassViewPort(1 / shadingScale, 1 / shadingScale) + .addRenderPass('post-final', `${this.name}${cameraID}`) + .setPassInput(input0, 'inputTexture') + .addRasterView(slot0, format, isOffScreen) + .blitScreen(0); + + this.renderProfiler(camera); + } +} diff --git a/cocos/rendering/post-process/post-process-builder.ts b/cocos/rendering/post-process/post-process-builder.ts index c9174157a04..fa656a459b1 100644 --- a/cocos/rendering/post-process/post-process-builder.ts +++ b/cocos/rendering/post-process/post-process-builder.ts @@ -20,7 +20,7 @@ import { director } from '../../game'; import { Camera as CameraComponent } from '../../misc'; import { BloomPass, ColorGradingPass, FloatOutputProcessPass, ForwardTransparencyPass, - ForwardTransparencySimplePass, FxaaPass, SkinPass } from './passes'; + ForwardTransparencySimplePass, FxaaPass, PostFinalPass, SkinPass } from './passes'; import { PipelineEventType } from '../pipeline-event'; export class PostProcessBuilder implements PipelineBuilder { @@ -79,7 +79,7 @@ export class PostProcessBuilder implements PipelineBuilder { // final output this.addPass(new FSRPass()); // fsr should be final - this.addPass(forwardFinal); + this.addPass(new PostFinalPass()); } getPass (passClass: typeof BasePass, pipelineName = 'forward'): BasePass | undefined { @@ -223,6 +223,8 @@ export class PostProcessBuilder implements PipelineBuilder { taaPass.updateSample(); } + const floatOutputPass = passes.find((p): boolean => p instanceof FloatOutputProcessPass) as FloatOutputProcessPass; + let lastPass: BasePass | undefined; for (let i = 0; i < passes.length; i++) { const pass = passes[i]; @@ -234,6 +236,10 @@ export class PostProcessBuilder implements PipelineBuilder { passContext.isFinalPass = true; } + if (pass.name === 'BloomPass') { + (pass as BloomPass).hdrInputName = floatOutputPass.getHDRInputName(); + } + pass.lastPass = lastPass; pass.render(camera, ppl); diff --git a/editor/assets/effects/pipeline/post-process/bloom.effect b/editor/assets/effects/pipeline/post-process/bloom.effect index 7a8c4f8d9e0..88537d3c012 100644 --- a/editor/assets/effects/pipeline/post-process/bloom.effect +++ b/editor/assets/effects/pipeline/post-process/bloom.effect @@ -112,14 +112,17 @@ CCProgram prefilter-fs %{ precision highp float; #include #include + #include in vec2 v_uv; uniform BloomUBO { - mediump vec4 texSize; + mediump vec4 texSize;// x: useHDRIlluminance,z: threshold, w: enableAlphaMask }; #pragma rate outputResultMap pass - uniform sampler2D outputResultMap; + uniform sampler2D outputResultMap; // ldr input + #pragma rate hdrInputMap pass + uniform sampler2D hdrInputMap; // hdr input layout(location = 0) out vec4 fragColor; @@ -128,13 +131,23 @@ CCProgram prefilter-fs %{ } void main() { - vec3 color = texture(outputResultMap, v_uv).xyz; - - if (luminance(SRGBToLinear(color)) > texSize.z) { - fragColor = vec4(color, 1.0); - } else { - fragColor = vec4(0.0, 0.0, 0.0, 1.0); - } + vec4 color = vec4(0.0, 0.0, 0.0, 1.0); + #if CC_USE_FLOAT_OUTPUT + if(texSize.x > 0.0) { + color = texture(hdrInputMap, v_uv); + } else { + color = texture(outputResultMap, v_uv); + // color.xyz = SRGBToLinear(color.xyz); + } + #else + color = texture(outputResultMap, v_uv); + // color.xyz = SRGBToLinear(color.xyz); + #endif + + float contribute = step(texSize.z, luminance(color.rgb)); + contribute *= mix(1.0, step(253.0 / 255.0, color.a), texSize.w); + + fragColor = vec4(color.xyz * contribute, 1.0); } }% diff --git a/editor/assets/effects/pipeline/post-process/post-final.effect b/editor/assets/effects/pipeline/post-process/post-final.effect new file mode 100644 index 00000000000..a1c6e08c4d2 --- /dev/null +++ b/editor/assets/effects/pipeline/post-process/post-final.effect @@ -0,0 +1,40 @@ +// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. + +CCEffect %{ + techniques: + - passes: + - vert: vs + frag: fs + pass: post-final + rasterizerState: + cullMode: none + depthStencilState: + depthTest: false + depthWrite: false +}% + + +CCProgram vs %{ + #include <./chunks/vs> +}% + + +CCProgram fs %{ + precision highp float; + + in vec2 v_uv; + + uniform UBO { + vec4 inputViewPort; + }; + #pragma rate inputTexture pass + uniform sampler2D inputTexture; + + layout(location = 0) out vec4 fragColor; + + void main () { + fragColor = vec4(texture(inputTexture, v_uv).rgb, 1.0); + } + +}% + diff --git a/editor/assets/effects/pipeline/post-process/post-final.effect.meta b/editor/assets/effects/pipeline/post-process/post-final.effect.meta new file mode 100644 index 00000000000..5de7cf6eb07 --- /dev/null +++ b/editor/assets/effects/pipeline/post-process/post-final.effect.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.7.1", + "importer": "effect", + "imported": true, + "uuid": "521c5f6e-1a26-42e2-8108-4400c912d9bf", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index c3b05125f0a..0b1adaa5577 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -1305,6 +1305,8 @@ module.exports = link(mixin({ needBlur: 'Turn on for a softer effect with less noise, but it consumes some performance.', }, bloom: { + enableAlphaMask: 'Transparent channel flag bit, if you turn on this function, please also reduce the object material intrinsic color a channel output, a value of less than 1 object will not have a flood light', + useHdrIlluminance: 'To use scene HDR brightness to filter flooded areas, both HDR mode and the CC_USE_FLOAT_OUTPUT macro must be enabled.', threshold: 'The brightness threshold, brighter area will produce bloom, this value unit is the LDR brightness seen by the human eye, independent of exposure.', iterations: 'The number of blur iterations, the higher the value that results in a larger and softer flare range, but with reduced performance.', intensity: 'Flood intensity, the higher the value, the brighter the halo, please adjust it moderately.', diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index cd3a0881867..b1047daed39 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -1279,6 +1279,8 @@ module.exports = link(mixin({ needBlur: '开启可以获得更柔和的效果,噪点更少,但会耗费一些性能', }, bloom: { + enableAlphaMask: '透明通道标志位,如果开启此功能,请同时降低物体材质的固有色a通道输出,a 值小于 1 的物体将不会有泛光', + useHdrIlluminance: '使用场景 HDR 亮度来筛选泛光区域,必须同时开启 HDR 模式和 CC_USE_FLOAT_OUTPUT 宏', threshold: '光晕的亮度阈值,大于此亮度的区域才会产生泛光,该值单位是人眼所见的 LDR 亮度,和曝光无关', iterations: '模糊迭代次数,该值越大则光晕范围越大、越柔和,但性能也会有所降低', intensity: '泛光强度,该值越大则光晕越亮,请适度调节', From 442f7402b7fba89a62d798c8b503e31c1f3383d3 Mon Sep 17 00:00:00 2001 From: Zeqiang Li Date: Thu, 31 Aug 2023 15:03:42 +0800 Subject: [PATCH 12/90] macos 10.x -> 11+ api change (#16153) --- native/cocos/renderer/gfx-metal/MTLTexture.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/native/cocos/renderer/gfx-metal/MTLTexture.mm b/native/cocos/renderer/gfx-metal/MTLTexture.mm index 2359cd99697..028baba2a35 100644 --- a/native/cocos/renderer/gfx-metal/MTLTexture.mm +++ b/native/cocos/renderer/gfx-metal/MTLTexture.mm @@ -235,6 +235,7 @@ of this software and associated engine source code (the "Software"), a limited, descriptor.arrayLength = _info.type == TextureType::CUBE ? 1 : _info.layerCount; bool memoryless = false; +#if !(CC_PLATFORM == CC_PLATFORM_MACOS && __MAC_OS_X_VERSION_MIN_REQUIRED < 110000) if (@available(macos 11.0, ios 10.0, *)) { memoryless = hasFlag(_info.flags, TextureFlagBit::LAZILY_ALLOCATED) && hasAllFlags(TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT | TextureUsageBit::INPUT_ATTACHMENT, _info.usage); @@ -243,7 +244,7 @@ of this software and associated engine source code (the "Software"), a limited, _allocateMemory = false; } } - +#endif if (!memoryless && !_isPVRTC) { // pvrtc can not use blit encoder to upload data. descriptor.storageMode = MTLStorageModePrivate; From 2b275816fcb651fb1ee890ed54447d17044eaabf Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Thu, 31 Aug 2023 16:00:36 +0800 Subject: [PATCH 13/90] post-final pass keep alpha channel (#16149) --- editor/assets/effects/pipeline/post-process/post-final.effect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/assets/effects/pipeline/post-process/post-final.effect b/editor/assets/effects/pipeline/post-process/post-final.effect index a1c6e08c4d2..3d8aa313f37 100644 --- a/editor/assets/effects/pipeline/post-process/post-final.effect +++ b/editor/assets/effects/pipeline/post-process/post-final.effect @@ -33,7 +33,7 @@ CCProgram fs %{ layout(location = 0) out vec4 fragColor; void main () { - fragColor = vec4(texture(inputTexture, v_uv).rgb, 1.0); + fragColor = texture(inputTexture, v_uv); } }% From 4d213938e972e84ba718e18927e8be6dfbe01727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=A3=AE=E6=96=8C?= Date: Thu, 31 Aug 2023 16:22:24 +0800 Subject: [PATCH 14/90] fix update widget occur error (#16139) * fix update widget occur error * update expression --- editor/inspector/components/widget.js | 8 ++++++-- editor/inspector/contributions/node.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/editor/inspector/components/widget.js b/editor/inspector/components/widget.js index a4b52964acd..85e97d536a5 100644 --- a/editor/inspector/components/widget.js +++ b/editor/inspector/components/widget.js @@ -8,6 +8,7 @@ const Vue = require('vue/dist/vue.min.js'); const propUtils = require('../utils/prop'); const cssMediaWidth = 340; +let layout = 'vertical'; exports.template = `