diff --git a/cocos/particle/noise.ts b/cocos/particle/noise.ts index 3b0908b5d7..d0995a165e 100644 --- a/cocos/particle/noise.ts +++ b/cocos/particle/noise.ts @@ -29,7 +29,8 @@ import { Vec2, Vec3 } from '../core/math'; * @zh 此类生成噪声纹理。 */ export class ParticleNoise { - private permutation: number[] = [151, 160, 137, 91, 90, 15, + private static readonly DEFAULT_PERMUTATION: readonly number[] = [ + 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, @@ -44,9 +45,19 @@ export class ParticleNoise { 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180, ]; + private static build512 (src: readonly number[] | number[]): Uint8Array { + const p = new Uint8Array(512); + for (let i = 0; i < 256; i++) { p[256 + i] = p[i] = src[i]; } + return p; + } + + private permutation: number[] = ParticleNoise.DEFAULT_PERMUTATION as number[]; + private permutation512: Uint8Array = ParticleNoise.build512(ParticleNoise.DEFAULT_PERMUTATION); + constructor (permutation?: number[]) { if (permutation) { - this.permutation = permutation; + this.permutation = permutation.slice(); + this.permutation512 = ParticleNoise.build512(this.permutation); } } @@ -61,8 +72,7 @@ export class ParticleNoise { * @returns @en Texture pixel generated. @zh 返回生成的噪声纹理值。 */ public noise (x: number, y: number, z: number, min = 0, max = 1): number { - const p: number[] = new Array(512); - for (let i = 0; i < 256; i++) { p[256 + i] = p[i] = this.permutation[i]; } + const p: Uint8Array = this.permutation512; const X = Math.floor(x) & 255; // FIND UNIT CUBE THAT const Y = Math.floor(y) & 255; // CONTAINS POINT. diff --git a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp index f5463596b5..e79c5f7def 100644 --- a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp @@ -698,15 +698,15 @@ struct RenderGraphVisitor : boost::dfs_visitor<> { ctx.cmdBuff, ctx.currentPass, ctx.subpassIndex, sceneData.flags); #if CC_USE_GEOMETRY_RENDERER - const auto& renderData = get(RenderGraph::DataTag{}, ctx.g, sceneID); - if (!renderData.custom.empty()) { - const auto& commands = ctx.ppl->custom.renderCommands; - auto iter = commands.find(renderData.custom); - if (iter != commands.end()) { - ctx.customContext.currentRenderPass = ctx.currentPass; - iter->second->beginRenderCommand(ctx.customContext, sceneID); + const auto& renderData = get(RenderGraph::DataTag{}, ctx.g, sceneID); + if (!renderData.custom.empty()) { + const auto& commands = ctx.ppl->custom.renderCommands; + auto iter = commands.find(renderData.custom); + if (iter != commands.end()) { + ctx.customContext.currentRenderPass = ctx.currentPass; + iter->second->beginRenderCommand(ctx.customContext, sceneID); + } } - } #endif if (any(sceneData.flags & SceneFlags::REFLECTION_PROBE)) { diff --git a/package-lock.json b/package-lock.json index b5b11ef79d..aa54f61e6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cocos-creator", - "version": "4.0.0-alpha.33", + "version": "4.0.0-alpha.34", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cocos-creator", - "version": "4.0.0-alpha.33", + "version": "4.0.0-alpha.34", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index d1ca9f06cf..ab5d19d392 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cocos-creator", - "version": "4.0.0-alpha.33", + "version": "4.0.0-alpha.34", "description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.", "homepage": "http://www.cocos.com", "license": "MIT",