No description
Find a file
2026-05-16 17:50:48 +01:00
pkg fixing the web build 2026-05-16 17:45:22 +01:00
src fixing the web build 2026-05-16 17:45:22 +01:00
tutorial-website l 2026-04-04 16:19:11 +01:00
.gitignore Remove /pkg from .gitignore to allow package tracking 2026-01-13 12:53:33 +01:00
Cargo.lock Rename crate to particle-system 2026-01-13 20:55:57 +01:00
Cargo.toml l 2026-04-04 16:19:11 +01:00
compute_shader.wgsl l 2026-04-04 16:19:11 +01:00
draw_shader.wgsl Track particle lifecycle and alive count 2026-01-11 22:07:50 +01:00
en.subject.md l 2026-04-04 16:19:11 +01:00
en.subject.pdf l 2026-04-04 16:19:11 +01:00
index.html fixing the web build 2026-05-16 17:45:22 +01:00
logs Refactor code structure for improved readability and maintainability 2025-12-26 19:44:15 +01:00
logs.txt Refactor code structure for improved readability and maintainability 2025-12-26 19:44:15 +01:00
Makefile Rename crate to particle-system 2026-01-13 20:55:57 +01:00
re Rename crate to particle-system 2026-01-13 20:55:57 +01:00
README.md Update README.md 2026-05-16 18:14:00 +02:00
run Rename crate to particle-system 2026-01-13 20:55:57 +01:00
tmp tmp 2026-05-16 17:50:48 +01:00

Unreal Majid - Particle System

A high-performance GPU particle simulation written in Rust using wgpu. This project demonstrates the power of Compute Shaders to handle physics calculations for millions of particles in real-time, rendering them efficiently on both native desktop platforms and the web via WebAssembly.

Live Demo

Run in Browser

Note: You need a desktop and a browser that support WebGPU. Mobile devices are not supported.

Features

  • GPU Compute Shaders: Physics calculations (position, velocity, acceleration) are offloaded to the GPU for massive parallelism.
  • Cross-Platform: Runs natively on Windows/Linux/macOS and in modern web browsers supporting WebGPU.
  • Interactive Camera: Fly-cam style movement with mouse-look controls.
  • Dynamic Simulation:
    • Gravity Control: Toggle gravity on/off.
    • Mouse Attraction: Make gravity pull particles towards the mouse cursor.
    • Shape Resets: instantly arrange particles into Sphere or Cube formations.

Controls

Key Action
W Move Camera Forward
S Move Camera Backward
A Move Camera Left
D Move Camera Right
Space / Q Move Camera Up
Left Shift / E Move Camera Down
R Reset particles to Sphere shape
T Reset particles to Cube shape
G Toggle Gravity
F Toggle Gravity Follows Mouse
Esc Exit Application

Mouse: Click and hold Left Mouse Button + Drag to rotate the camera.

Building and Running

Prerequisites

Native (Desktop)

To run the simulation natively on your machine:

  1. Run with Cargo:

    cargo run --release
    

    Note: The --release flag is highly recommended for performance, especially with many particles.

  2. Using Makefile:

    make
    ./target/release/particle-system
    

Web (WebAssembly)

To build and view the project in a browser:

  1. Build:

    wasm-pack build --release --target web --out-name Unreal_Majid
    
  2. Serve: Due to browser security restrictions (CORS), you must serve the files via a local web server.

    # Using Python 3
    python3 -m http.server
    
  3. View: Open your browser to http://localhost:8000. Ensure your browser supports WebGPU.

Project Structure

  • src/main.rs: Entry point for native desktop execution.
  • src/lib.rs: Entry point for WASM/Web execution.
  • src/core/renderer.rs: Handles WGPU context, pipeline setup, and the main render loop.
  • src/core/window.rs: Manages the application window and input events using winit.
  • compute_shader.wgsl: WGSL shader responsible for particle physics updates.
  • draw_shader.wgsl: WGSL shader responsible for drawing the particles.