From 7e2c6c0f0a42033cc5cf3a4087486b9fd3a1d4ed Mon Sep 17 00:00:00 2001 From: Liam Don Date: Tue, 24 Jun 2025 20:04:23 +0000 Subject: [PATCH 1/2] Fix particle system with unlit mesh emitter --- src/scene/particle-system/particle-material.js | 3 ++- .../shader-lib/glsl/chunks/particle/frag/particle-shader.js | 2 +- src/scene/shader-lib/programs/particle.js | 1 + .../shader-lib/wgsl/chunks/particle/frag/particle-shader.js | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/scene/particle-system/particle-material.js b/src/scene/particle-system/particle-material.js index c2c0e46664f..3fc1f1474c5 100644 --- a/src/scene/particle-system/particle-material.js +++ b/src/scene/particle-system/particle-material.js @@ -44,7 +44,8 @@ class ParticleMaterial extends Material { defines: ShaderUtils.getCoreDefines(this, params), pass: SHADER_FORWARD, useCpu: this.emitter.useCpu, - normal: emitter.lighting ? ((emitter.normalMap !== null) ? 2 : 1) : 0, + lighting: emitter.lighting, + normal: emitter.lighting ? ((emitter.normalMap !== null) ? 2 : 1) : (this.emitter.useMesh ? 1 : 0), halflambert: this.emitter.halfLambert, stretch: this.emitter.stretch, alignToMotion: this.emitter.alignToMotion, diff --git a/src/scene/shader-lib/glsl/chunks/particle/frag/particle-shader.js b/src/scene/shader-lib/glsl/chunks/particle/frag/particle-shader.js index e2d5c59100b..86e21ade0c4 100644 --- a/src/scene/shader-lib/glsl/chunks/particle/frag/particle-shader.js +++ b/src/scene/shader-lib/glsl/chunks/particle/frag/particle-shader.js @@ -39,7 +39,7 @@ export default /* glsl */` #include "particle_normalMapPS" #endif - #if NORMAL != NONE + #if LIGHTING && NORMAL != NONE #ifdef HALF_LAMBERT #include "particle_halflambertPS" #else diff --git a/src/scene/shader-lib/programs/particle.js b/src/scene/shader-lib/programs/particle.js index 860486ef439..b7105c33bac 100644 --- a/src/scene/shader-lib/programs/particle.js +++ b/src/scene/shader-lib/programs/particle.js @@ -54,6 +54,7 @@ class ShaderGeneratorParticle extends ShaderGenerator { const fDefines = new Map(options.defines); if (options.soft > 0) fDefines.set('SOFT', ''); + if (options.lighting) fDefines.set('LIGHTING', ''); if (options.halflambert) fDefines.set('HALF_LAMBERT', ''); fDefines.set('NORMAL', normalTypeNames[options.normal]); diff --git a/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js b/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js index f944ec3adf5..39fbc4a834a 100644 --- a/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js +++ b/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js @@ -42,7 +42,7 @@ export default /* wgsl */` #include "particle_normalMapPS" #endif - #if NORMAL != NONE + #if LIGHTING &&NORMAL != NONE #ifdef HALF_LAMBERT #include "particle_halflambertPS" #else From bfcc2edbcc8238f5ec94a75d8164318e68062750 Mon Sep 17 00:00:00 2001 From: Liam Don Date: Tue, 24 Jun 2025 20:15:46 +0000 Subject: [PATCH 2/2] Fix typo --- .../shader-lib/wgsl/chunks/particle/frag/particle-shader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js b/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js index 39fbc4a834a..7c91d4b58d6 100644 --- a/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js +++ b/src/scene/shader-lib/wgsl/chunks/particle/frag/particle-shader.js @@ -42,7 +42,7 @@ export default /* wgsl */` #include "particle_normalMapPS" #endif - #if LIGHTING &&NORMAL != NONE + #if LIGHTING && NORMAL != NONE #ifdef HALF_LAMBERT #include "particle_halflambertPS" #else