Skip to content

Conversation

@willeastcott
Copy link
Contributor

@willeastcott willeastcott commented Dec 21, 2025

Fixes #7534

When screenSpace: true is set on a particle system and CPU particles are used (either forced via device.supportsGpuParticles = false or when sorting is enabled), screen space particles were not rendering correctly.

Changes

  • Added SCREEN_SPACE handling to the CPU particle billboard function in both GLSL and WGSL shaders
  • Added SCREEN_SPACE handling to the CPU particle position output in both GLSL and WGSL shaders

Root Cause

The GPU particle shaders had proper SCREEN_SPACE conditional handling, but the CPU particle shaders were missing this logic entirely. This caused CPU particles to:

  1. Use view-inverse matrix billboarding instead of simple axis-aligned billboarding for screen space
  2. Transform positions through the view-projection matrix instead of outputting directly to normalized device coordinates

Testing

Tested with the user-interface/particle-system example with CPU particles forced via:

device.supportsGpuParticles = false;

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where screen space particles were not rendering correctly when CPU simulation was used (either forced or when sorting is enabled). The fix adds the missing SCREEN_SPACE conditional handling to the CPU particle shaders, making them consistent with the GPU particle shaders.

Key Changes:

  • Added SCREEN_SPACE handling to the CPU particle billboard function in both GLSL and WGSL
  • Added SCREEN_SPACE handling to the CPU particle position output in both GLSL and WGSL

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/scene/shader-lib/wgsl/chunks/particle/vert/particle_cpu_end.js Added conditional logic to output position directly to NDC for screen space particles instead of transforming through view-projection matrix
src/scene/shader-lib/wgsl/chunks/particle/vert/particle_cpu.js Added conditional logic to use axis-aligned billboarding for screen space particles instead of view-inverse matrix billboarding
src/scene/shader-lib/glsl/chunks/particle/vert/particle_cpu_end.js Added conditional logic to output position directly to NDC for screen space particles instead of transforming through view-projection matrix
src/scene/shader-lib/glsl/chunks/particle/vert/particle_cpu.js Added conditional logic to use axis-aligned billboarding for screen space particles instead of view-inverse matrix billboarding

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@willeastcott willeastcott merged commit cd76a62 into main Dec 21, 2025
13 checks passed
@willeastcott willeastcott deleted the screen-particles branch December 21, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue area: particles bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Screen Space particle issue when cpu particles are used

3 participants