From 8a9e239abbfada9312db0ade9414fb47d80fa9c1 Mon Sep 17 00:00:00 2001 From: zxx43 Date: Tue, 30 Aug 2022 11:51:32 +0800 Subject: [PATCH] add random to noise sample point (#12534) --- cocos/particle/animator/noise-module.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos/particle/animator/noise-module.ts b/cocos/particle/animator/noise-module.ts index 1e8251d68a..9132a9573b 100644 --- a/cocos/particle/animator/noise-module.ts +++ b/cocos/particle/animator/noise-module.ts @@ -234,6 +234,8 @@ export class NoiseModule extends ParticleModuleBase { private noise: ParticleNoise = new ParticleNoise(); + private samplePosition: Vec3 = new Vec3(); + public animate (particle: Particle, dt: number) { this.noise.setTime(particle.particleSystem.time); this.noise.setSpeed(this.noiseSpeedX, this.noiseSpeedY, this.noiseSpeedZ); @@ -241,7 +243,10 @@ export class NoiseModule extends ParticleModuleBase { this.noise.setAbs(this.remapX, this.remapY, this.remapZ); this.noise.setAmplititude(this.strengthX, this.strengthY, this.strengthZ); this.noise.setOctaves(this.octaves, this.octaveMultiplier, this.octaveScale); - this.noise.setSamplePoint(particle.position); + + this.samplePosition.set(particle.position); + this.samplePosition.add3f(Math.random() * 1.0, Math.random() * 1.0, Math.random() * 1.0); + this.noise.setSamplePoint(this.samplePosition); this.noise.getNoiseParticle(); const noisePosition: Vec3 = this.noise.getResult();